This commit is contained in:
“ddf” 2025-01-16 12:45:51 +08:00
parent f15e9f0c85
commit 344234cbdb
3 changed files with 173 additions and 9 deletions

View File

@ -594,6 +594,10 @@ inherited frmCustomer: TfrmCustomer
ClientRectTop = 0
end
inherited cxProgressBar2: TcxProgressBar
Left = 363
Top = 227
ExplicitLeft = 363
ExplicitTop = 227
ExplicitHeight = 29
end
inherited ADOQueryBaseCmd: TADOQuery

View File

@ -396,6 +396,7 @@ inherited frmTradeClothTotalInInput1: TfrmTradeClothTotalInInput1
Width = 534
Height = 422
Align = alClient
PopupMenu = PopupMenu1
TabOrder = 0
object Tv1: TcxGridDBTableView
Navigator.Buttons.CustomButtons = <>
@ -620,4 +621,12 @@ inherited frmTradeClothTotalInInput1: TfrmTradeClothTotalInInput1
Left = 522
Top = 338
end
object PopupMenu1: TPopupMenu
Left = 734
Top = 330
object N1: TMenuItem
Caption = #40655#36148
OnClick = N1Click
end
end
end

View File

@ -4,15 +4,15 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, ComCtrls, ToolWin,
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxClasses, cxControls, cxGridCustomView, cxGrid, cxGridCustomPopupMenu,
cxGridPopupMenu, ADODB, DBClient, cxButtonEdit, cxTextEdit, StdCtrls, ExtCtrls,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxDateRanges,
dxBarBuiltInMenu, U_BaseInput, System.ImageList, Vcl.ImgList, ComObj,
dxScrollbarAnnotations, cxContainer, dxCore, cxDateUtils, cxMaskEdit,
cxImageList, cxCurrencyEdit;
System.Types, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, ComCtrls,
ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxButtonEdit,
cxTextEdit, StdCtrls, ExtCtrls, cxLookAndFeels, cxLookAndFeelPainters,
cxNavigator, dxDateRanges, dxBarBuiltInMenu, U_BaseInput, System.ImageList,
Vcl.ImgList, ComObj, dxScrollbarAnnotations, cxContainer, dxCore, cxDateUtils,
cxMaskEdit, cxImageList, cxCurrencyEdit, Vcl.Menus;
type
TfrmTradeClothTotalInInput1 = class(TfrmBaseInput)
@ -84,6 +84,8 @@ type
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
btndaoru: TToolButton;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBAddClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
@ -105,10 +107,13 @@ type
procedure inQtyKeyPress(Sender: TObject; var Key: Char);
procedure StkCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure btndaoruClick(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
function SaveCKData(): Boolean;
procedure JSKC();
procedure NianTie();
function Split(const s: string; Separator: char): TStringDynArray;
public
{ Public declarations }
FBCId, canshu3, FSTKName, FKHName: string;
@ -123,6 +128,152 @@ uses
U_DataLink, U_RTFun, U_ZDYHelp, U_CompanySel, U_TradePlanSel, U_ClothInfoSel;
{$R *.dfm}
function TfrmTradeClothTotalInInput1.Split(const s: string; Separator: char): TStringDynArray;
var
i, ItemIndex: Integer;
len: Integer;
SeparatorCount: Integer;
Start: Integer;
begin
len := Length(s);
if len = 0 then
begin
Result := nil;
exit;
end;
SeparatorCount := 0;
for i := 1 to len do
begin
if s[i] = Separator then
begin
inc(SeparatorCount);
end;
end;
SetLength(Result, SeparatorCount + 1);
ItemIndex := 0;
Start := 1;
for i := 1 to len do
begin
if s[i] = Separator then
begin
Result[ItemIndex] := Copy(s, Start, i - Start);
inc(ItemIndex);
Start := i + 1;
end;
end;
Result[ItemIndex] := Copy(s, Start, len - Start + 1);
end;
procedure TfrmTradeClothTotalInInput1.N1Click(Sender: TObject);
var
hmem: THandle;
ClipboardText: PChar;
Lines: TStringDynArray;
Cells: TStringDynArray;
i: Integer;
begin
// 假设已经从剪贴板获取到了文本存放在ClipboardText变量中
OpenClipboard(0);
hmem := GetClipboardData(CF_TEXT);
ClipboardText := GlobalLock(hmem);
// 首先按换行符拆分成行
Lines := Split(ClipboardText, #13); // Windows系统中换行符通常是#13#10
// 遍历每一行
for i := 0 to Length(Lines) - 1 do
begin
// 按逗号拆分成单元格数据
Cells := Split(Lines[i], ',');
// 此时Cells数组中就存储了每一行的单元格数据
// 例如第一行拆分后Cells[0]='姓名'Cells[1]='年龄'Cells[2]='性别'
// 可以根据需要将这些数据导入到cxGrid中
end;
end;
procedure TfrmTradeClothTotalInInput1.NianTie();
var
hmem: THandle;
pstr: PChar;
ArrStr: TStringList;
i, x, h, Row, Z: Integer;
FColumn: string;
begin
//检查剪贴板类容类型
if IsClipboardFormatAvailable(CF_TEXT) then
begin
OpenClipboard(0);
hmem := GetClipboardData(CF_TEXT);
pstr := GlobalLock(hmem);
// Memo1.Text := pstr;
pstr := PChar(StringReplace(pstr, #$A, #$A#$3F, [rfReplaceAll]));
// pstr := PAnsiChar(StringReplace(pstr, #$D#$A#$D, #$D#$A#$20#$D, [rfReplaceAll]));
ArrStr := TStringList.Create;
ArrStr.Clear;
ExtractStrings([#13], [], PChar(pstr), ArrStr);
GlobalUnlock(hmem);
CloseClipboard;
end;
ArrStr.Delete(ArrStr.Count - 1);
Row := Tv1.Controller.FocusedRowIndex;
CDS_Sub.Locate('xhno', Row + 1, []);
x := (Tv1.DataController.RowCount - (Row + 1));
// showmessage(ArrStr.Text);
//自动增行
if x < ArrStr.count then
begin
for i := x to ArrStr.count - 2 do
begin
if VarIsNull(Tv1.DataController.Summary.FooterSummaryValues[0]) = True then
begin
h := 0;
end
else
h := Tv1.DataController.Summary.FooterSummaryValues[0];
h := h + 1;
with CDS_Sub do
begin
Append;
FieldByName('XHNO').Value := IntToStr(h);
Post;
end;
end;
end;
CDS_Sub.Locate('xhno', Row + 1, []);
i := 0;
Z := 0;
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
with CDS_Sub do
begin
DisableControls;
while not Eof do
begin
edit;
if ArrStr.Count > i then
begin
CDS_Sub.FieldByName(FColumn).Value := StringReplace(ArrStr[i], '?', '', [rfReplaceAll]);
end
else
Break;
i := i + 1;
Post;
Next;
end;
EnableControls;
end;
end;
procedure TfrmTradeClothTotalInInput1.JSKC();
begin