D7wmguihua/坯布码单待检(PBMDDJ.dll)/U_MDChkFLZhengYiCLList.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

465 lines
14 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_MDChkFLZhengYiCLList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxClasses, cxControls, cxGridCustomView, cxGrid, cxButtonEdit,
cxDropDownEdit, cxSplitter, cxCheckBox, cxCalendar, Menus,
cxGridCustomPopupMenu, cxGridPopupMenu, DBClient, ADODB, cxPC, cxTextEdit;
type
TfrmMDChkFLZhengYiCLList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBExport: TToolButton;
ToolButton2: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label2: TLabel;
Label5: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
orderNo: TEdit;
Panel2: TPanel;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column7: TcxGridDBColumn;
v1GenDan: TcxGridDBColumn;
v1SOrddefstr1: TcxGridDBColumn;
V1OrderNo: TcxGridDBColumn;
cxGridDBColumn28: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1FactoryName: TcxGridDBColumn;
v1ToFactoryName: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v72Column1: TcxGridDBColumn;
v72Column2: TcxGridDBColumn;
v72Column3: TcxGridDBColumn;
v72Column4: TcxGridDBColumn;
v72Column5: TcxGridDBColumn;
v72Column6: TcxGridDBColumn;
v72Column7: TcxGridDBColumn;
v72Column8: TcxGridDBColumn;
v72Column9: TcxGridDBColumn;
Label7: TLabel;
FactoryName: TEdit;
DataSource1: TDataSource;
ClientDataSet1: TClientDataSet;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryMain: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQuery1: TADOQuery;
v1Column1: TcxGridDBColumn;
v1PSName: TcxGridDBColumn;
cxTabControl2: TcxTabControl;
ToolButton4: TToolButton;
ToolButton7: TToolButton;
ComboBox4: TComboBox;
v1Column2: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
Panel5: TPanel;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
v3Column20: TcxGridDBColumn;
v3Column1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
v3Column12: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
v3Column17: TcxGridDBColumn;
v3Column18: TcxGridDBColumn;
v3Column16: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
v3Column19: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
Tv3Column1: TcxGridDBColumn;
v3Column24: TcxGridDBColumn;
v3Column3: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
v3Column13: TcxGridDBColumn;
v3Column21: TcxGridDBColumn;
v3Column22: TcxGridDBColumn;
v3Column23: TcxGridDBColumn;
v3Column4: TcxGridDBColumn;
v3Column5: TcxGridDBColumn;
Tv3Column2: TcxGridDBColumn;
Tv3Column3: TcxGridDBColumn;
v3Column6: TcxGridDBColumn;
v3Column7: TcxGridDBColumn;
v3Column8: TcxGridDBColumn;
v3Column9: TcxGridDBColumn;
v3Column10: TcxGridDBColumn;
v3Column11: TcxGridDBColumn;
v3Column15: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
cxSplitter2: TcxSplitter;
DataSource3: TDataSource;
ClientDataSet3: TClientDataSet;
cxGridPopupMenu3: TcxGridPopupMenu;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton7Click(Sender: TObject);
procedure cxTabControl2Change(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure orderNoChange(Sender: TObject);
procedure FactoryNameChange(Sender: TObject);
procedure v1Column9PropertiesEditValueChanged(Sender: TObject);
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
FMHId:String;
procedure InitGrid();
public
{ Public declarations }
end;
var
frmMDChkFLZhengYiCLList: TfrmMDChkFLZhengYiCLList;
implementation
uses
U_DataLink,U_RTFun, U_GYSList,U_ZDYHelp, U_ModuleNote;
{$R *.dfm}
procedure TfrmMDChkFLZhengYiCLList.FormDestroy(Sender: TObject);
begin
frmMDChkFLZhengYiCLList:=nil;
end;
procedure TfrmMDChkFLZhengYiCLList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmMDChkFLZhengYiCLList.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('Tv1',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>');
WriteCxGrid('Tv3',Tv3,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>');
close;
end;
procedure TfrmMDChkFLZhengYiCLList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main_MD_HZ where 1=1 ');
if cxTabControl2.TabIndex<>0 then
begin
if ComboBox4.ItemIndex=0 then
begin
sql.Add(' and MHDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
sql.Add(' and MHDate<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1))+'''');
end else
if ComboBox4.ItemIndex=1 then
begin
sql.Add(' and FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
sql.Add(' and FillTime<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1))+'''');
end else
if ComboBox4.ItemIndex=2 then
begin
sql.Add(' and YFDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
sql.Add(' and YFDate<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1))+'''');
end;
end;
sql.Add(' and isnull(ChkStatus,'''')<>'''' ');
if cxTabControl2.TabIndex=0 then
begin
sql.Add(' and isnull(ChkStatus,'''') in(''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'',''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'') ');
end else
if cxTabControl2.TabIndex=1 then
begin
sql.Add(' and isnull(ChkStatus,'''') in(''<27>Ѵ<EFBFBD><D1B4><EFBFBD>'',''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'')');
end;
Open;
end;
SCreateCDS20(ADOQueryMain,ClientDataSet1);
SInitCDSData20(ADOQueryMain,ClientDataSet1);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmMDChkFLZhengYiCLList.FormShow(Sender: TObject);
begin
cxTabControl2.TabIndex:=0;
EndDate.DateTime:=SGetServerDate(ADOQueryTemp);
BegDate.Date:=EndDate.Date-30;
ReadCxGrid('Tv1',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>');
ReadCxGrid('Tv3',Tv3,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>');
InitGrid();
end;
procedure TfrmMDChkFLZhengYiCLList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmMDChkFLZhengYiCLList.TBExportClick(Sender: TObject);
begin
if ClientDataSet1.IsEmpty then Exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>',cxGrid1);
end;
procedure TfrmMDChkFLZhengYiCLList.ToolButton2Click(Sender: TObject);
begin
try
frmModuleNote:=TfrmModuleNote.Create(Application);
with frmModuleNote do
begin
flag:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
end;
end;
finally
frmModuleNote.Free;
end;
end;
procedure TfrmMDChkFLZhengYiCLList.ToolButton4Click(Sender: TObject);
begin
if ClientDataSet1.IsEmpty then Exit;
if cxTabControl2.TabIndex<>0 then Exit;
BegDate.SetFocus;
if ClientDataSet1.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if ClientDataSet1.Locate('SSel;CLQty',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if ClientDataSet1.Locate('SSel;CLPrice',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if ClientDataSet1.Locate('SSel;CLMoney',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
ClientDataSet1.DisableControls;
with ClientDataSet1 do
begin
First;
while ClientDataSet1.Locate('SSel',True,[]) do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update JYOrder_Main_MD_HZ Set CLTime=Getdate(),');
SQL.Add('CLPerson='''+Trim(DName)+''',ChkStatus=''<27>Ѵ<EFBFBD><D1B4><EFBFBD>'' ' );
if Trim(ClientDataSet1.fieldbyname('CLQty').AsString)<>'' then
begin
SQL.Add(',CLQty='+Trim(ClientDataSet1.fieldbyname('CLQty').AsString));
end;
if Trim(ClientDataSet1.fieldbyname('CLPrice').AsString)<>'' then
begin
SQL.Add(',CLPrice='+Trim(ClientDataSet1.fieldbyname('CLPrice').AsString));
end;
if Trim(ClientDataSet1.fieldbyname('CLMoney').AsString)<>'' then
begin
SQL.Add(',CLMoney='+Trim(ClientDataSet1.fieldbyname('CLMoney').AsString));
end;
sql.Add(' where MHID='''+Trim(ClientDataSet1.fieldbyname('MHID').AsString)+'''');
ExecSQL;
end;
{Edit;
FieldByName('CLPerson').Value:=Trim(DName);
FieldByName('CLTime').Value:=Now;
Post; }
ClientDataSet1.Delete;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
ClientDataSet1.EnableControls;
except
ClientDataSet1.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmMDChkFLZhengYiCLList.ToolButton7Click(Sender: TObject);
begin
if ClientDataSet1.IsEmpty then Exit;
if cxTabControl2.TabIndex<>1 then Exit;
BegDate.SetFocus;
if ClientDataSet1.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if ClientDataSet1.Locate('SSel;ChkStatus',VarArrayOf([True,'<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>']),[loPartialKey]) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>в<EFBFBD><D0B2><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
ClientDataSet1.DisableControls;
with ClientDataSet1 do
begin
First;
while ClientDataSet1.Locate('SSel',True,[]) do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update JYOrder_Main_MD_HZ Set CLTime=Null,');
SQL.Add('CLPerson=Null,ChkStatus=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'',CLQty=Null,CLPrice=Null,CLMoney=Null ' );
sql.Add(' where MHID='''+Trim(ClientDataSet1.fieldbyname('MHID').AsString)+'''');
ExecSQL;
end;
ClientDataSet1.Delete;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
ClientDataSet1.EnableControls;
except
ClientDataSet1.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmMDChkFLZhengYiCLList.cxTabControl2Change(Sender: TObject);
var
fsj:string;
begin
InitGrid();
if ClientDataSet1.IsEmpty=True then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('exec P_View_MDTJ_JS :begdate,:enddate,:orderno,:MDType,:WSql');
Parameters.ParamByName('orderno').Value:='www324567';
fsj:=' and isnull(MHID,'''')=''1234567ytrty'' ';
Parameters.ParamByName('WSql').Value:=fsj;
Open;
end;
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
end;
end;
procedure TfrmMDChkFLZhengYiCLList.TBFindClick(Sender: TObject);
begin
if ADOQueryMain.Active=False then Exit;
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,ClientDataSet1);
SInitCDSData20(ADOQueryMain,ClientDataSet1);
end;
procedure TfrmMDChkFLZhengYiCLList.orderNoChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmMDChkFLZhengYiCLList.FactoryNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmMDChkFLZhengYiCLList.v1Column9PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FName,Qty,Price:string;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
FName:=Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
with ClientDataSet1 do
begin
Edit;
FieldByName(FName).Value:=mvalue;
Post;
end;
Qty:=Trim(ClientDataSet1.fieldbyname('CLQty').AsString);
if Trim(Qty)='' then
begin
Qty:='0';
end;
Price:=Trim(ClientDataSet1.fieldbyname('CLPrice').AsString);
if Trim(Price)='' then
begin
Price:='0';
end;
with ClientDataSet1 do
begin
Edit;
FieldByName('CLMoney').Value:=StrToFloat(Qty)*StrToFloat(Price);
Post;
end;
end;
procedure TfrmMDChkFLZhengYiCLList.Tv1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
fsj:String;
begin
if ClientDataSet1.IsEmpty then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('exec P_View_MDTJ_JS :begdate,:enddate,:orderno,:MDType,:WSql');
Parameters.ParamByName('orderno').Value:=Trim(ClientDataSet1.fieldbyname('OrderNo').AsString);
fsj:=' and isnull(MHID,'''')='''+Trim(ClientDataSet1.fieldbyname('MHID').AsString)+'''';
Parameters.ParamByName('WSql').Value:=fsj;
Open;
end;
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
end;
end.