This commit is contained in:
“ddf” 2025-02-22 13:21:24 +08:00
parent b9f63eed70
commit 913f33e99a
5 changed files with 114 additions and 76 deletions

View File

@ -3,11 +3,11 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
Top = 4 Top = 4
Caption = #35746#21333#24405#20837 Caption = #35746#21333#24405#20837
ClientHeight = 593 ClientHeight = 593
ClientWidth = 938 ClientWidth = 1040
Font.Charset = GB2312_CHARSET Font.Charset = GB2312_CHARSET
Font.Height = -16 Font.Height = -16
Position = poMainFormCenter Position = poMainFormCenter
ExplicitWidth = 954 ExplicitWidth = 1056
ExplicitHeight = 632 ExplicitHeight = 632
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 21 TextHeight = 21
@ -15,7 +15,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
Tag = 1 Tag = 1
Left = 0 Left = 0
Top = 0 Top = 0
Width = 938 Width = 1040
Height = 30 Height = 30
AutoSize = True AutoSize = True
ButtonHeight = 30 ButtonHeight = 30
@ -27,7 +27,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
List = True List = True
ShowCaptions = True ShowCaptions = True
TabOrder = 0 TabOrder = 0
ExplicitWidth = 850 ExplicitWidth = 938
object TBSave: TToolButton object TBSave: TToolButton
Left = 0 Left = 0
Top = 0 Top = 0
@ -57,7 +57,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
Tag = 1 Tag = 1
Left = 0 Left = 0
Top = 193 Top = 193
Width = 938 Width = 1040
Height = 30 Height = 30
ButtonHeight = 30 ButtonHeight = 30
ButtonWidth = 99 ButtonWidth = 99
@ -68,7 +68,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
List = True List = True
ShowCaptions = True ShowCaptions = True
TabOrder = 1 TabOrder = 1
ExplicitWidth = 850 ExplicitWidth = 938
object ToolButton1: TToolButton object ToolButton1: TToolButton
Left = 0 Left = 0
Top = 0 Top = 0
@ -98,31 +98,30 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
object Panel2: TPanel [2] object Panel2: TPanel [2]
Left = 0 Left = 0
Top = 223 Top = 223
Width = 938 Width = 1040
Height = 370 Height = 370
Align = alClient Align = alClient
Caption = 'Panel2' Caption = 'Panel2'
TabOrder = 2 TabOrder = 2
ExplicitWidth = 850 ExplicitWidth = 938
object Panel3: TPanel object Panel3: TPanel
Left = 1 Left = 1
Top = 1 Top = 1
Width = 936 Width = 1038
Height = 368 Height = 368
Align = alClient Align = alClient
Caption = 'Panel2' Caption = 'Panel2'
TabOrder = 0 TabOrder = 0
ExplicitWidth = 848 ExplicitWidth = 936
object cxGrid1: TcxGrid object cxGrid1: TcxGrid
Left = 1 Left = 1
Top = 1 Top = 1
Width = 934 Width = 1036
Height = 366 Height = 366
Align = alClient Align = alClient
PopupMenu = PopupMenu2 PopupMenu = PopupMenu2
TabOrder = 0 TabOrder = 0
ExplicitLeft = -1 ExplicitWidth = 934
ExplicitTop = 5
object Tv1: TcxGridDBTableView object Tv1: TcxGridDBTableView
OnDblClick = Tv1DblClick OnDblClick = Tv1DblClick
OnMouseDown = Tv1MouseDown OnMouseDown = Tv1MouseDown
@ -199,6 +198,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
Default = True Default = True
Kind = bkEllipsis Kind = bkEllipsis
end> end>
Properties.ReadOnly = True
Properties.OnButtonClick = Tv1Column1PropertiesButtonClick Properties.OnButtonClick = Tv1Column1PropertiesButtonClick
HeaderAlignmentHorz = taCenter HeaderAlignmentHorz = taCenter
Width = 89 Width = 89
@ -308,7 +308,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
object ScrollBox1: TScrollBox [3] object ScrollBox1: TScrollBox [3]
Left = 0 Left = 0
Top = 30 Top = 30
Width = 938 Width = 1040
Height = 163 Height = 163
Align = alTop Align = alTop
BevelInner = bvNone BevelInner = bvNone
@ -317,7 +317,7 @@ inherited frmItemizedListInPut: TfrmItemizedListInPut
Ctl3D = False Ctl3D = False
ParentCtl3D = False ParentCtl3D = False
TabOrder = 3 TabOrder = 3
ExplicitWidth = 850 ExplicitWidth = 938
object Label3: TLabel object Label3: TLabel
Left = 377 Left = 377
Top = 11 Top = 11

View File

@ -308,7 +308,7 @@ begin
begin begin
Close; Close;
sql.Clear; sql.Clear;
sql.Add(' SELECT C_Code,C_Name FROM Bs_Cloth_Info'); sql.Add(' SELECT C_Code,C_Name,qtyunit FROM Bs_Cloth_Info');
Open; Open;
end; end;
end; end;
@ -964,6 +964,7 @@ begin
ADO_PM.Locate('C_Name', mvalue, []); ADO_PM.Locate('C_Name', mvalue, []);
Edit; Edit;
FieldByName('C_Code').Value := ADO_PM.FieldByName('C_Code').Value; FieldByName('C_Code').Value := ADO_PM.FieldByName('C_Code').Value;
FieldByName('TISUnit').Value := ADO_PM.FieldByName('qtyunit').Value;
Post; Post;
end; end;

View File

@ -227,8 +227,6 @@ inherited frmItemizedListList: TfrmItemizedListList
Height = 584 Height = 584
Align = alClient Align = alClient
TabOrder = 5 TabOrder = 5
ExplicitLeft = 2
ExplicitTop = 158
object TV1: TcxGridDBTableView object TV1: TcxGridDBTableView
Navigator.Buttons.CustomButtons = <> Navigator.Buttons.CustomButtons = <>
ScrollbarAnnotations.CustomAnnotations = <> ScrollbarAnnotations.CustomAnnotations = <>
@ -368,7 +366,7 @@ inherited frmItemizedListList: TfrmItemizedListList
end end
object Tv1Column8: TcxGridDBColumn object Tv1Column8: TcxGridDBColumn
Caption = #21333#20301 Caption = #21333#20301
DataBinding.FieldName = 'TMSUnit' DataBinding.FieldName = 'TISUnit'
DataBinding.IsNullValueType = True DataBinding.IsNullValueType = True
PropertiesClassName = 'TcxComboBoxProperties' PropertiesClassName = 'TcxComboBoxProperties'
Properties.Items.Strings = ( Properties.Items.Strings = (

View File

@ -3,33 +3,36 @@ inherited frmItemizedListQtyInPut: TfrmItemizedListQtyInPut
Top = 126 Top = 126
Caption = #26126#32454#20837#24211#30331#35760 Caption = #26126#32454#20837#24211#30331#35760
ClientHeight = 499 ClientHeight = 499
ClientWidth = 629 ClientWidth = 917
Font.Charset = GB2312_CHARSET Font.Charset = GB2312_CHARSET
Font.Height = -16 Font.Height = -16
Position = poScreenCenter Position = poScreenCenter
OnClose = FormClose OnClose = FormClose
ExplicitWidth = 645 ExplicitWidth = 933
ExplicitHeight = 538 ExplicitHeight = 538
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 21 TextHeight = 21
object pnl1: TPanel [0] object pnl1: TPanel [0]
Left = 0 Left = 0
Top = 0 Top = 0
Width = 629 Width = 917
Height = 499 Height = 499
Align = alClient Align = alClient
Caption = 'pnl1' Caption = 'pnl1'
TabOrder = 0 TabOrder = 0
ExplicitTop = 2
object cxGrid1: TcxGrid object cxGrid1: TcxGrid
Tag = 2 Tag = 2
Left = 1 Left = 1
Top = 72 Top = 72
Width = 627 Width = 915
Height = 426 Height = 426
Align = alClient Align = alClient
PopupMenu = PopupMenu1 PopupMenu = PopupMenu1
TabOrder = 0 TabOrder = 0
ExplicitWidth = 627
object Tv1: TcxGridDBTableView object Tv1: TcxGridDBTableView
OnKeyDown = Tv1KeyDown
Navigator.Buttons.CustomButtons = <> Navigator.Buttons.CustomButtons = <>
ScrollbarAnnotations.CustomAnnotations = <> ScrollbarAnnotations.CustomAnnotations = <>
DataController.DataSource = DataSource3 DataController.DataSource = DataSource3
@ -57,6 +60,10 @@ inherited frmItemizedListQtyInPut: TfrmItemizedListQtyInPut
DataController.Summary.SummaryGroups = <> DataController.Summary.SummaryGroups = <>
OptionsBehavior.GoToNextCellOnEnter = True OptionsBehavior.GoToNextCellOnEnter = True
OptionsCustomize.ColumnFiltering = False OptionsCustomize.ColumnFiltering = False
OptionsCustomize.ColumnSorting = False
OptionsSelection.MultiSelect = True
OptionsSelection.CellMultiSelect = True
OptionsSelection.InvertSelect = False
OptionsView.Footer = True OptionsView.Footer = True
OptionsView.GroupByBox = False OptionsView.GroupByBox = False
OptionsView.Indicator = True OptionsView.Indicator = True
@ -106,7 +113,7 @@ inherited frmItemizedListQtyInPut: TfrmItemizedListQtyInPut
Tag = 1 Tag = 1
Left = 1 Left = 1
Top = 1 Top = 1
Width = 627 Width = 915
Height = 30 Height = 30
AutoSize = True AutoSize = True
ButtonHeight = 30 ButtonHeight = 30
@ -124,6 +131,8 @@ inherited frmItemizedListQtyInPut: TfrmItemizedListQtyInPut
ParentFont = False ParentFont = False
ShowCaptions = True ShowCaptions = True
TabOrder = 1 TabOrder = 1
ExplicitWidth = 627
ExplicitHeight = 60
object TBSave: TToolButton object TBSave: TToolButton
Left = 0 Left = 0
Top = 0 Top = 0
@ -179,22 +188,15 @@ inherited frmItemizedListQtyInPut: TfrmItemizedListQtyInPut
ImageIndex = 7 ImageIndex = 7
OnClick = ToolButton5Click OnClick = ToolButton5Click
end end
object btn2: TToolButton
Left = 489
Top = 0
Caption = 'btn2'
ImageIndex = 17
Visible = False
OnClick = btn2Click
end
end end
object pnl2: TPanel object pnl2: TPanel
Left = 1 Left = 1
Top = 31 Top = 31
Width = 627 Width = 915
Height = 41 Height = 41
Align = alTop Align = alTop
TabOrder = 2 TabOrder = 2
ExplicitWidth = 627
object Label9: TLabel object Label9: TLabel
Left = 33 Left = 33
Top = 7 Top = 7

View File

@ -44,7 +44,6 @@ type
btndaoru: TToolButton; btndaoru: TToolButton;
PopupMenu1: TPopupMenu; PopupMenu1: TPopupMenu;
N1: TMenuItem; N1: TMenuItem;
btn2: TToolButton;
ToolButton2: TToolButton; ToolButton2: TToolButton;
TBSave: TToolButton; TBSave: TToolButton;
TBClose: TToolButton; TBClose: TToolButton;
@ -56,11 +55,11 @@ type
procedure inQtyKeyPress(Sender: TObject; var Key: Char); procedure inQtyKeyPress(Sender: TObject; var Key: Char);
procedure btndaoruClick(Sender: TObject); procedure btndaoruClick(Sender: TObject);
procedure N1Click(Sender: TObject); procedure N1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject);
procedure TBSaveClick(Sender: TObject); procedure TBSaveClick(Sender: TObject);
procedure btnAddClick(Sender: TObject); procedure btnAddClick(Sender: TObject);
procedure Tv1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private private
{ Private declarations } { Private declarations }
function SaveData(): Boolean; function SaveData(): Boolean;
@ -82,6 +81,7 @@ uses
{$R *.dfm} {$R *.dfm}
// 分割字符串函数
function TfrmItemizedListQtyInPut.Split(const s: string; Separator: char): TStringDynArray; function TfrmItemizedListQtyInPut.Split(const s: string; Separator: char): TStringDynArray;
var var
i, ItemIndex: Integer; i, ItemIndex: Integer;
@ -93,28 +93,30 @@ begin
if len = 0 then if len = 0 then
begin begin
Result := nil; Result := nil;
exit; Exit;
end; end;
// 计算分隔符数量
SeparatorCount := 0; SeparatorCount := 0;
for i := 1 to len do for i := 1 to len do
begin
if s[i] = Separator then if s[i] = Separator then
begin Inc(SeparatorCount);
inc(SeparatorCount);
end;
end;
SetLength(Result, SeparatorCount + 1); SetLength(Result, SeparatorCount + 1);
ItemIndex := 0; ItemIndex := 0;
Start := 1; Start := 1;
// 拆分字符串
for i := 1 to len do for i := 1 to len do
begin begin
if s[i] = Separator then if s[i] = Separator then
begin begin
Result[ItemIndex] := Copy(s, Start, i - Start); Result[ItemIndex] := Copy(s, Start, i - Start);
inc(ItemIndex); Inc(ItemIndex);
Start := i + 1; Start := i + 1;
end; end;
end; end;
Result[ItemIndex] := Copy(s, Start, len - Start + 1); Result[ItemIndex] := Copy(s, Start, len - Start + 1);
end; end;
@ -255,40 +257,6 @@ begin
end; end;
end; end;
procedure TfrmItemizedListQtyInPut.btn2Click(Sender: TObject);
var
RowData: TArray<string>;
rowColData: TArray<string>;
RowIndex, ColIndex, i: Integer;
clipboardText, rowStr: string;
lRect: TRect;
begin
if Clipboard.HasFormat(CF_TEXT) then
begin
clipboardText := Clipboard.AsText;
RowData := clipboardText.Split([#13#10]); // 根据换行符拆分行数据
// 遍历行数据
for RowIndex := Low(RowData) to High(RowData) do
begin
rowStr := RowData[RowIndex];
if trim(rowStr) = '' then
continue;
rowColData := rowStr.Split([#9]);
ShowMessage(rowStr);
// lRect := FGrid.Selection;
// ColIndex := 0;
// for i := lRect.Left to lRect.Right do
// begin
// if lRect.Top + RowIndex < FGrid.RowCount then
// begin
// FGrid.Cells[i, lRect.Top + RowIndex].Text := trim(rowColData[ColIndex]);
// ColIndex := ColIndex + 1;
// end;
// end;
end;
end;
end;
procedure TfrmItemizedListQtyInPut.btndaoruClick(Sender: TObject); procedure TfrmItemizedListQtyInPut.btndaoruClick(Sender: TObject);
var var
excelApp, WorkBook: Variant; excelApp, WorkBook: Variant;
@ -702,5 +670,74 @@ begin
Close; Close;
end; end;
procedure TfrmItemizedListQtyInPut.Tv1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
SelectedCount: Integer;
ClipboardText: string;
StringList: TStringList;
RowData: TStringDynArray;
i, j: Integer;
begin
// 检测是否按下 Ctrl+V
if (Key = Ord('V')) and (Shift = [ssCtrl]) then
begin
// ToolButton1.Click;
// SelectedCount := TV1.DataController.GetSelectedCount;
// ShowMessage('选中的行数: ' + IntToStr(SelectedCount));
// 检查剪贴板是否包含文本格式
if not Clipboard.HasFormat(CF_TEXT) then
begin
ShowMessage('剪贴板中没有文本内容!');
Exit;
end;
// 获取剪贴板中的文本
ClipboardText := Clipboard.AsText;
// 将文本按行拆分
StringList := TStringList.Create;
try
StringList.Text := ClipboardText;
// 遍历每一行
for i := 0 to StringList.Count - 1 do
begin
// 将每行按制表符(或其他分隔符)拆分为单元格数据
RowData := Split(StringList[i], #9); // 假设使用制表符作为分隔符
// 遍历每一列并将数据填充到cxGrid
for j := 0 to Length(RowData) - 1 do
begin
// 假设cxGrid已经初始化且有足够的行和列
Tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[i];
TV1.DataController.Values[i, j] := RowData[j];
// if Tv1.DataController.DataSet.State in [dsInsert, dsEdit] then
// begin
// Tv1.DataController.DataSet.FieldByName(Tv1.Columns[j].DataBinding.FieldName).AsString := RowData[j];
// end
// else
begin
Tv1.DataController.DataSet.Edit;
Tv1.DataController.DataSet.FieldByName(Tv1.Columns[j].DataBinding.FieldName).AsString := RowData[j];
Tv1.DataController.DataSet.Post;
end;
TV1.Controller.EditingController.ShowEdit;
end;
end;
finally
StringList.Free;
end;
end;
end;
end. end.