371 lines
10 KiB
ObjectPascal
371 lines
10 KiB
ObjectPascal
![]() |
unit U_DyeFormulaLargeList;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, strUtils, SysUtils, Variants, Classes, Graphics, Controls,
|
|||
|
Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
cxDataStorage, cxEdit, DB, cxDBData, cxCurrencyEdit, cxTextEdit,
|
|||
|
cxDropDownEdit, Menus, cxLookAndFeelPainters, StdCtrls, ComCtrls, BtnEdit,
|
|||
|
Buttons, cxButtons, cxContainer, cxListBox, ExtCtrls, cxGridLevel,
|
|||
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
|
|||
|
cxControls, cxGridCustomView, cxGrid, ToolWin, cxLookAndFeels, cxNavigator,
|
|||
|
ADODB, DBClient, RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset,
|
|||
|
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, cxCustomListBox, U_BaseList,
|
|||
|
cxButtonEdit, dxBarBuiltInMenu, cxGridCustomPopupMenu, cxGridPopupMenu, cxPC,
|
|||
|
RM_BarCode;
|
|||
|
|
|||
|
type
|
|||
|
TfrmDyeFormulaLargeList = class(TfrmBaseList)
|
|||
|
ToolBar2: TToolBar;
|
|||
|
TMdy: TToolButton;
|
|||
|
TDel: TToolButton;
|
|||
|
Tprint: TToolButton;
|
|||
|
Tclose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
CDS_SheetDye: TClientDataSet;
|
|||
|
DS_SheetDye: TDataSource;
|
|||
|
RM1: TRMGridReport;
|
|||
|
Panel8: TPanel;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
TBfind: TToolButton;
|
|||
|
begdate: TDateTimePicker;
|
|||
|
enddate: TDateTimePicker;
|
|||
|
C_ColorNo: TEdit;
|
|||
|
PCID: TEdit;
|
|||
|
Label26: TLabel;
|
|||
|
Label29: TLabel;
|
|||
|
CustName: TEdit;
|
|||
|
Label30: TLabel;
|
|||
|
Label31: TLabel;
|
|||
|
C_Name: TEdit;
|
|||
|
Label32: TLabel;
|
|||
|
Label33: TLabel;
|
|||
|
C_Color: TEdit;
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
GPM_2: TcxGridPopupMenu;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
CheckBox1: TCheckBox;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
cxGridDBColumn1: TcxGridDBColumn;
|
|||
|
TV1DyeCode: TcxGridDBColumn;
|
|||
|
TV1dyeName: TcxGridDBColumn;
|
|||
|
cxGridDBColumn2: TcxGridDBColumn;
|
|||
|
TV1dyeStyle: TcxGridDBColumn;
|
|||
|
TV1curUnitDyeNum: TcxGridDBColumn;
|
|||
|
TV1pbUnit: TcxGridDBColumn;
|
|||
|
TV1sumNum: TcxGridDBColumn;
|
|||
|
TV1sumNum_KG: TcxGridDBColumn;
|
|||
|
cxGridLevel2: TcxGridLevel;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
tv1: TcxGridDBTableView;
|
|||
|
tv1gangNo: TcxGridDBColumn;
|
|||
|
tv1sheetNo: TcxGridDBColumn;
|
|||
|
tv1sheetStyle: TcxGridDBColumn;
|
|||
|
tv1filltime: TcxGridDBColumn;
|
|||
|
tv1Column4: TcxGridDBColumn;
|
|||
|
tv1Column1: TcxGridDBColumn;
|
|||
|
tv1Column2: TcxGridDBColumn;
|
|||
|
tv1Column3: TcxGridDBColumn;
|
|||
|
tv1Column6: TcxGridDBColumn;
|
|||
|
tv1DeviceNo: TcxGridDBColumn;
|
|||
|
tv1curNum: TcxGridDBColumn;
|
|||
|
tv1YB: TcxGridDBColumn;
|
|||
|
tv1Volume: TcxGridDBColumn;
|
|||
|
tv1filler: TcxGridDBColumn;
|
|||
|
tv1beizhu: TcxGridDBColumn;
|
|||
|
tv1Column7: TcxGridDBColumn;
|
|||
|
tv1Column8: TcxGridDBColumn;
|
|||
|
tv1Column9: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
DS_1: TDataSource;
|
|||
|
TV2Column1: TcxGridDBColumn;
|
|||
|
TV2Column2: TcxGridDBColumn;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TcloseClick(Sender: TObject);
|
|||
|
procedure TDelClick(Sender: TObject);
|
|||
|
procedure TprintClick(Sender: TObject);
|
|||
|
procedure TBfindClick(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure PCIDKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
procedure TMdyClick(Sender: TObject);
|
|||
|
private
|
|||
|
procedure InitGrid();
|
|||
|
procedure InitSub(MDFLMID: string);
|
|||
|
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
fdept, Fbuzhong: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
const
|
|||
|
gFactor = 10;
|
|||
|
|
|||
|
var
|
|||
|
frmDyeFormulaLargeList: TfrmDyeFormulaLargeList;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_LabelPrint, U_DyeFormulaLargeInput;
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.InitGrid();
|
|||
|
var
|
|||
|
WSql: string;
|
|||
|
mDFLMID: string;
|
|||
|
begin
|
|||
|
if not CDS_Main.IsEmpty then
|
|||
|
mDFLMID := CDS_Main.FieldByName('DFLMID').AsString;
|
|||
|
|
|||
|
WSql := SGetFilters(Panel8, 1, 2);
|
|||
|
if trim(WSql) <> '' then
|
|||
|
begin
|
|||
|
WSql := ' and ' + trim(WSql);
|
|||
|
end;
|
|||
|
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
close;
|
|||
|
filtered := false;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Dye_Formula_Large_Main ');
|
|||
|
sql.Add('where 1=1 ');
|
|||
|
|
|||
|
if CheckBox1.Checked then
|
|||
|
begin
|
|||
|
sql.Add('and DFLDate>=''' + formatdateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
|
|||
|
sql.Add('and DFLDate<''' + formatdateTime('yyyy-MM-dd', enddate.DateTime + 1) + ''' ');
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
sql.Add('and FDFLDate>DATEADD(dd,-180,GETDATE())');
|
|||
|
end;
|
|||
|
|
|||
|
sql.Add(WSql);
|
|||
|
|
|||
|
sql.Add('order by DFLMID DESC');
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_Main);
|
|||
|
|
|||
|
if not CDS_Main.Locate('DFLMID', mDFLMID, []) then
|
|||
|
CDS_Main.First;
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.InitSub(MDFLMID: string);
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Dye_Formula_Large_Sub where DFLMID=''' + trim(MDFLMID) + ''' ');
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_SheetDye);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_SheetDye);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.PCIDKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmDyeFormulaLargeList := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := cafree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
|
|||
|
begdate.DateTime := DServerDate - 7;
|
|||
|
enddate.DateTime := DServerDate;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
begin
|
|||
|
InitSub(trim(CDS_Main.fieldByName('DFLMID').AsString));
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
ReadCxGrid(self.Caption + tv1.Name, Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
|
|||
|
ReadCxGrid(self.Caption + tv2.Name + '2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.TcloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(self.Caption + tv1.Name, Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
|
|||
|
WriteCxGrid(self.Caption + tv2.Name + '2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmDyeFormulaLargeInput := TfrmDyeFormulaLargeInput.create(self);
|
|||
|
with frmDyeFormulaLargeInput do
|
|||
|
begin
|
|||
|
FDFLMID := '';
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
Self.InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmDyeFormulaLargeInput.free;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.TDelClick(Sender: TObject);
|
|||
|
var
|
|||
|
mcurSheetNo: string;
|
|||
|
mCarNo: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
if Trim(CDS_Main.fieldbyname('FillId').AsString) <> Trim(Dcode) then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
mcurSheetNo := trim(CDS_Main.fieldByName('DFLMID').asString);
|
|||
|
|
|||
|
if application.MessageBox(pchar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>' + mcurSheetNo + '<27><><EFBFBD><EFBFBD>?'), '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', 1 + mb_defButton2) = 2 then
|
|||
|
exit;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
|
|||
|
sql.Add('update Dye_Formula_Large_Main set DelId=' + quotedstr(DCode) + ',Deler=' + quotedstr(DName) + ',Deltime=getdate() where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
sql.Add('insert into Dye_Formula_Large_Main_Del select * from Dye_Formula_Large_Main where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
sql.Add('delete Dye_Formula_Large_Main where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
|
|||
|
sql.Add('update Dye_Formula_Large_Sub set DelId=' + quotedstr(DCode) + ',Deler=' + quotedstr(DName) + ',Deltime=getdate() where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
sql.Add('insert into Dye_Formula_Large_Sub_Del select * from Dye_Formula_Large_Sub where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
sql.Add('delete Dye_Formula_Large_Sub where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.TMdyClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if Trim(CDS_Main.fieldbyname('FillId').AsString) <> Trim(Dcode) then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
try
|
|||
|
frmDyeFormulaLargeInput := TfrmDyeFormulaLargeInput.create(self);
|
|||
|
with frmDyeFormulaLargeInput do
|
|||
|
begin
|
|||
|
FDFLMID := trim(CDS_Main.fieldbyName('DFLMID').AsString);
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
Self.InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmDyeFormulaLargeInput.free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.TprintClick(Sender: TObject);
|
|||
|
var
|
|||
|
WSql: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
WSql := QuotedStr(Trim(CDS_Main.fieldbyname('DFLMID').AsString));
|
|||
|
try
|
|||
|
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
|||
|
with frmLabelPrint do
|
|||
|
begin
|
|||
|
FLMType := 'DyeFormulaLarge';
|
|||
|
FFiltration1 := WSql;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('update Dye_Formula_Large_Main set PrtNum=PrtNum+1,PrtTime=getdate(),Prter=' + quotedstr(Trim(DName)));
|
|||
|
sql.Add('where DFLMID=' + quotedstr(trim(CDS_Main.fieldByName('DFLMID').AsString)));
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmLabelPrint.Free;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDyeFormulaLargeList.TBfindClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active = False then
|
|||
|
Exit;
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel8, 1, 2));
|
|||
|
SCreateCDS(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_Main);
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|