This commit is contained in:
DESKTOP-E401PHE\Administrator 2025-06-25 15:16:04 +08:00
parent 0170d3fdce
commit afd57e285f
8 changed files with 402 additions and 30 deletions

View File

@ -26,6 +26,8 @@ uses
/////////////////////////////////////////////////////////////////
function GetDllForm(App: Tapplication; FormH: hwnd; FormID: integer; Language: integer; WinStyle: integer; GCode: Pchar; GName: Pchar; DataBase: Pchar; Title: PChar; Parameters1: PChar; Parameters2: PChar; Parameters3: PChar; Parameters4: PChar; Parameters5: PChar; Parameters6: PChar; Parameters7: PChar; Parameters8: PChar; Parameters9: PChar; Parameters10: PChar; DataBaseStr: PChar): hwnd;
var
i: Integer;
bFound: Boolean;
mnewHandle: hwnd;
mstyle: TFormStyle; // 0:子窗口; 1:普通窗口
mstate: TWindowState;
@ -120,6 +122,69 @@ begin
mnewHandle := frmZdyAttachment.Handle;
end;
21: //供应商资料维护(坯布厂管理)
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '坯布厂管理' then
begin
BringWindowToTop(frmZdyAttachGYS.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmZdyAttachGYS := TfrmZdyAttachGYS.Create(application.MainForm);
with frmZdyAttachGYS do
begin
fDEFstr5 := trim(DParameters2);
Title := '坯布厂管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachGYS.BringToFront;
//句柄
mnewHandle := frmZdyAttachGYS.Handle;
end;
22: //供应商资料维护(加工厂管理 染厂)
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '加工厂管理' then
begin
BringWindowToTop(frmZdyAttachGYS.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmZdyAttachGYS := TfrmZdyAttachGYS.Create(application.MainForm);
with frmZdyAttachGYS do
begin
fDEFstr5 := trim(DParameters2);
Title := '加工厂管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachGYS.BringToFront;
//句柄
mnewHandle := frmZdyAttachGYS.Handle;
end;
2: //供应商资料维护
begin
if frmZdyAttachGYS = nil then
@ -128,7 +193,7 @@ begin
with frmZdyAttachGYS do
begin
caption := Trim(Title);
fDEFstr5:=trim(DParameters2);
fDEFstr5 := trim(DParameters2);
// fDEFstr5 := trim(DataBase);
FormStyle := mstyle;
windowState := mstate;
@ -140,7 +205,6 @@ begin
frmZdyAttachGYS.BringToFront;
//句柄
mnewHandle := frmZdyAttachGYS.Handle;
end;
3: //产品资料维护
begin

View File

@ -159,14 +159,14 @@ end;
procedure TfrmZdyAttInputCP.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('产品资料录入1', Tv2, '客户自定义');
WriteCxGrid('成品资料录入1', Tv2, '成品自定义');
Close;
ModalResult := 1;
end;
procedure TfrmZdyAttInputCP.FormShow(Sender: TObject);
begin
ReadCxGrid('产品资料录入1', Tv2, '客户自定义');
ReadCxGrid('成品资料录入1', Tv2, '成品自定义');
InitGrid();
Initsub();
if Trim(FCYID) = '' then

View File

@ -120,14 +120,14 @@ end;
procedure TfrmZdyAttInputPB.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('产品资料录入1', Tv2, '客户自定义');
WriteCxGrid('Å÷²¼×ÊÁϼÈë1', Tv2, 'Å÷²¼×Ô¶¨Òå');
Close;
ModalResult := 1;
end;
procedure TfrmZdyAttInputPB.FormShow(Sender: TObject);
begin
ReadCxGrid('产品资料录入1', Tv2, '客户自定义');
ReadCxGrid('Å÷²¼×ÊÁϼÈë1', Tv2, 'Å÷²¼×Ô¶¨Òå');
InitGrid();
if Trim(FCYID) = '' then
begin

View File

@ -22,7 +22,7 @@ object frmZdyAttachCP: TfrmZdyAttachCP
Width = 1135
Height = 31
ButtonHeight = 30
ButtonWidth = 113
ButtonWidth = 125
Caption = 'ToolBar1'
Color = clSkyBlue
DisabledImages = DataLink_BaseInfo.ThreeImgList
@ -72,15 +72,24 @@ object frmZdyAttachCP: TfrmZdyAttachCP
ImageIndex = 17
OnClick = TBDelClick
end
object ToolButton5: TToolButton
object ToolButton7: TToolButton
Left = 315
Top = 0
AutoSize = True
Caption = #25552#21462'Excel'#25968#25454
ImageIndex = 106
OnClick = ToolButton7Click
end
object ToolButton5: TToolButton
Left = 432
Top = 0
Caption = #25552#21462'Excel'#25968#25454'12'
ImageIndex = 106
Visible = False
OnClick = ToolButton5Click
end
object ToolButton1: TToolButton
Left = 428
Left = 557
Top = 0
AutoSize = True
Caption = #23548#20986
@ -88,7 +97,7 @@ object frmZdyAttachCP: TfrmZdyAttachCP
OnClick = ToolButton1Click
end
object ToolButton6: TToolButton
Left = 491
Left = 620
Top = 0
AutoSize = True
Caption = #25171#21360#26631#31614
@ -97,7 +106,7 @@ object frmZdyAttachCP: TfrmZdyAttachCP
OnClick = ToolButton6Click
end
object TBClose: TToolButton
Left = 578
Left = 707
Top = 0
AutoSize = True
Caption = #20851#38381
@ -540,4 +549,10 @@ object frmZdyAttachCP: TfrmZdyAttachCP
Left = 1083
Top = 551
end
object CDS_LM: TClientDataSet
Aggregates = <>
Params = <>
Left = 208
Top = 392
end
end

View File

@ -95,6 +95,8 @@ type
Tv2Column4: TcxGridDBColumn;
Tv2Column5: TcxGridDBColumn;
Tv2Column6: TcxGridDBColumn;
ToolButton7: TToolButton;
CDS_LM: TClientDataSet;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
@ -111,6 +113,7 @@ type
procedure cxButton1Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
procedure ToolButton7Click(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
@ -166,7 +169,7 @@ end;
procedure TfrmZdyAttachCP.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('产品资料13', Tv2, '客户自定义');
WriteCxGrid('成品资料13', Tv2, '成品自定义');
Close;
end;
@ -193,7 +196,7 @@ end;
procedure TfrmZdyAttachCP.FormShow(Sender: TObject);
begin
ReadCxGrid('产品资料13', Tv2, '客户自定义');
ReadCxGrid('成品资料13', Tv2, '成品自定义');
InitGrid();
end;
@ -267,7 +270,6 @@ var
i, j, k, ExcelRowCount: integer;
maxId: string;
begin
try
excelApp := CreateOleObject('Excel.Application');
openDialog1.Filter := '*.CSV;*.xls';
@ -469,5 +471,161 @@ begin
end;
end;
procedure TfrmZdyAttachCP.ToolButton7Click(Sender: TObject);
var
excelApp, WorkBook: Variant;
i, j, k, LX, ExcelRowCount: integer;
maxId, FCPID, FCPName, t1, t2, t3, FFID: string;
begin
with CDS_LM do
begin
FieldDefs.Clear;
FieldDefs.Add('LXH', ftInteger, 0);
FieldDefs.Add('lCode', ftString, 40);
FieldDefs.Add('LName', ftString, 40);
close;
CreateDataSet;
end;
try
excelApp := CreateOleObject('Excel.Application');
openDialog1.Filter := '*.CSV;*.xls';
if opendialog1.Execute then
begin
WorkBook := excelApp.WorkBooks.Open(OpenDialog1.FileName);
end
else
exit;
excelApp.Visible := false;
ExcelRowCount := WorkBook.WorkSheets[1].UsedRange.Rows.Count;
except
application.MessageBox('加载EXCEL错误', '错误信息', MB_ICONERROR);
exit;
end;
CDS_LM.EmptyDataSet;
for j := 0 to Tv2.ColumnCount - 1 do
begin
with CDS_LM do
begin
Append;
FieldByName('LCode').Value := trim(Tv2.Columns[j].DataBinding.FieldName);
FieldByName('LName').Value := trim(Tv2.Columns[j].Caption);
Post;
end;
end;
try
for i := 1 to 50 do
begin
if trim(WorkBook.WorkSheets[1].Cells[1, i].value) = '' then
continue;
if CDS_LM.Locate('LName', trim(WorkBook.WorkSheets[1].Cells[1, i].value), []) then
begin
with CDS_LM do
begin
Edit;
FieldByName('LXH').Value := i;
Post;
end;
end;
end;
except
application.MessageBox('加载数组错误!', '错误信息', MB_ICONERROR);
exit;
end;
ADOQueryCmd.Connection.BeginTrans;
try
for i := 2 to ExcelRowCount do
begin
if GetLSNo(ADOQueryCmd, maxId, 'AT', 'KH_Zdy_Attachment', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('取最大号失败!', '提示', 0);
Exit;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from KH_Zdy_Attachment where 1=2');
open;
end;
ADOQueryCmd.Append;
with CDS_HZ do
begin
Append;
CDS_LM.First;
while not CDS_LM.Eof do
begin
if CDS_LM.FieldByName('LXH').AsInteger > 0 then
ADOQueryCmd.fieldbyname(CDS_LM.FieldByName('LCode').AsString).Value := WorkBook.WorkSheets[1].Cells[i, CDS_LM.FieldByName('LXH').AsInteger].Value;
ADOQueryCmd.FieldByName('ATID').Value := Trim(maxId);
ADOQueryCmd.FieldByName('Filler').Value := Trim(DName);
ADOQueryCmd.FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
ADOQueryCmd.FieldByName('Type').Value := 'CP';
CDS_LM.Next;
end;
ADOQueryCmd.Post;
end;
// for j := 0 to k - 1 do
// begin
// ADOQueryCmd.fieldbyname(dFdDy[j].FDdys).Value := excelApp.Cells[i, dFdDy[j].inc].Value;
// end;
// ADOQueryCmd.FieldByName('ATID').Value := Trim(maxId);
// ADOQueryCmd.FieldByName('zdyCode').Value := Trim(maxId);
// ADOQueryCmd.FieldByName('khType').Value := Trim(fkhType);
// ADOQueryCmd.FieldByName('Type').Value := 'CP';
// ADOQueryCmd.FieldByName('Filler').Value := Trim(DName);
// ADOQueryCmd.Post;
end;
WorkBook.Close;
excelApp.Quit;
excelApp := Unassigned;
WorkBook := Unassigned;
ADOQueryCmd.Connection.CommitTrans;
InitGrid();
except
WorkBook.Close;
excelApp.Quit;
excelApp := Unassigned;
WorkBook := Unassigned;
ADOQueryCmd.Connection.RollbackTrans;
end;
// try
// for i := 2 to ExcelRowCount do
// begin
// with CDS_HZ do
// begin
// Append;
// CDS_LM.First;
// while not CDS_LM.Eof do
// begin
// if CDS_LM.FieldByName('LXH').AsInteger > 0 then
// CDS_HZ.fieldbyname(CDS_LM.FieldByName('LCode').AsString).Value := WorkBook.WorkSheets[1].Cells[i, CDS_LM.FieldByName('LXH').AsInteger].Value;
// CDS_LM.Next;
// end;
//// CDS_Import.fieldbyname('OurCoNo').Value := '91330602MA2JTEXX4B';
//// CDS_Import.fieldbyname('OurCoName').Value := '圆中圆';
// Post;
//
// end;
// end;
// WorkBook.Close;
// excelApp.Quit;
// excelApp := Unassigned;
// WorkBook := Unassigned;
// except
// WorkBook.Close;
// excelApp.Quit;
// excelApp := Unassigned;
// WorkBook := Unassigned;
// exit;
// end;
end;
end.

View File

@ -22,7 +22,7 @@ object frmZdyAttachPB: TfrmZdyAttachPB
Width = 1059
Height = 31
ButtonHeight = 30
ButtonWidth = 113
ButtonWidth = 125
Caption = 'ToolBar1'
Color = clSkyBlue
DisabledImages = DataLink_BaseInfo.ThreeImgList
@ -72,15 +72,24 @@ object frmZdyAttachPB: TfrmZdyAttachPB
ImageIndex = 17
OnClick = TBDelClick
end
object ToolButton5: TToolButton
object ToolButton7: TToolButton
Left = 315
Top = 0
AutoSize = True
Caption = #25552#21462'Excel'#25968#25454
ImageIndex = 106
OnClick = ToolButton7Click
end
object ToolButton5: TToolButton
Left = 432
Top = 0
Caption = #25552#21462'Excel'#25968#25454'12'
ImageIndex = 106
Visible = False
OnClick = ToolButton5Click
end
object ToolButton1: TToolButton
Left = 428
Left = 557
Top = 0
AutoSize = True
Caption = #23548#20986
@ -88,7 +97,7 @@ object frmZdyAttachPB: TfrmZdyAttachPB
OnClick = ToolButton1Click
end
object ToolButton6: TToolButton
Left = 491
Left = 620
Top = 0
AutoSize = True
Caption = #25171#21360#26631#31614
@ -97,7 +106,7 @@ object frmZdyAttachPB: TfrmZdyAttachPB
OnClick = ToolButton6Click
end
object TBClose: TToolButton
Left = 578
Left = 707
Top = 0
AutoSize = True
Caption = #20851#38381
@ -452,4 +461,10 @@ object frmZdyAttachPB: TfrmZdyAttachPB
Left = 936
Top = 41
end
object CDS_LM: TClientDataSet
Aggregates = <>
Params = <>
Left = 96
Top = 224
end
end

View File

@ -85,6 +85,8 @@ type
Tv2Column3: TcxGridDBColumn;
Tv2Column4: TcxGridDBColumn;
Tv2Column5: TcxGridDBColumn;
ToolButton7: TToolButton;
CDS_LM: TClientDataSet;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
@ -100,6 +102,7 @@ type
procedure cxButton2Click(Sender: TObject);
procedure cxButton1Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton7Click(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
@ -154,7 +157,7 @@ end;
procedure TfrmZdyAttachPB.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('产品资料131', Tv2, '客户自定义131');
WriteCxGrid('坯布资料131', Tv2, '坯布自定义131');
Close;
end;
@ -180,7 +183,7 @@ end;
procedure TfrmZdyAttachPB.FormShow(Sender: TObject);
begin
ReadCxGrid('产品资料131', Tv2, '客户自定义131');
ReadCxGrid('坯布资料131', Tv2, '坯布自定义131');
InitGrid();
end;
@ -433,5 +436,122 @@ begin
Panel2.Visible := true;
end;
procedure TfrmZdyAttachPB.ToolButton7Click(Sender: TObject);
var
excelApp, WorkBook: Variant;
i, j, k, LX, ExcelRowCount: integer;
maxId, FCPID, FCPName, t1, t2, t3, FFID: string;
begin
with CDS_LM do
begin
FieldDefs.Clear;
FieldDefs.Add('LXH', ftInteger, 0);
FieldDefs.Add('lCode', ftString, 40);
FieldDefs.Add('LName', ftString, 40);
close;
CreateDataSet;
end;
try
excelApp := CreateOleObject('Excel.Application');
openDialog1.Filter := '*.CSV;*.xls';
if opendialog1.Execute then
begin
WorkBook := excelApp.WorkBooks.Open(OpenDialog1.FileName);
end
else
exit;
excelApp.Visible := false;
ExcelRowCount := WorkBook.WorkSheets[1].UsedRange.Rows.Count;
except
application.MessageBox('加载EXCEL错误', '错误信息', MB_ICONERROR);
exit;
end;
CDS_LM.EmptyDataSet;
for j := 0 to Tv2.ColumnCount - 1 do
begin
with CDS_LM do
begin
Append;
FieldByName('LCode').Value := trim(Tv2.Columns[j].DataBinding.FieldName);
FieldByName('LName').Value := trim(Tv2.Columns[j].Caption);
Post;
end;
end;
try
for i := 1 to 50 do
begin
if trim(WorkBook.WorkSheets[1].Cells[1, i].value) = '' then
continue;
if CDS_LM.Locate('LName', trim(WorkBook.WorkSheets[1].Cells[1, i].value), []) then
begin
with CDS_LM do
begin
Edit;
FieldByName('LXH').Value := i;
Post;
end;
end;
end;
except
application.MessageBox('加载数组错误!', '错误信息', MB_ICONERROR);
exit;
end;
ADOQueryCmd.Connection.BeginTrans;
try
for i := 2 to ExcelRowCount do
begin
if GetLSNo(ADOQueryCmd, maxId, 'AT', 'KH_Zdy_Attachment', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('取最大号失败!', '提示', 0);
Exit;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from KH_Zdy_Attachment where 1=2');
open;
end;
ADOQueryCmd.Append;
with CDS_HZ do
begin
Append;
CDS_LM.First;
while not CDS_LM.Eof do
begin
if CDS_LM.FieldByName('LXH').AsInteger > 0 then
ADOQueryCmd.fieldbyname(CDS_LM.FieldByName('LCode').AsString).Value := WorkBook.WorkSheets[1].Cells[i, CDS_LM.FieldByName('LXH').AsInteger].Value;
ADOQueryCmd.FieldByName('ATID').Value := Trim(maxId);
ADOQueryCmd.FieldByName('Filler').Value := Trim(DName);
ADOQueryCmd.FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
ADOQueryCmd.FieldByName('Type').Value := 'CP';
CDS_LM.Next;
end;
ADOQueryCmd.Post;
end;
end;
WorkBook.Close;
excelApp.Quit;
excelApp := Unassigned;
WorkBook := Unassigned;
ADOQueryCmd.Connection.CommitTrans;
InitGrid();
except
WorkBook.Close;
excelApp.Quit;
excelApp := Unassigned;
WorkBook := Unassigned;
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
end.