D7wmguihua/桂华管理系统/U_ProductionAnPai.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

667 lines
18 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_ProductionAnPai;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, ExtCtrls, cxGridLevel,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
cxControls, cxGridCustomView, cxGrid, ADODB, DBClient, cxTextEdit, cxPC,
cxCalendar, ComCtrls, cxButtonEdit, cxGridCustomPopupMenu,
cxGridPopupMenu;
type
TfrmProductionAnPai = class(TForm)
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1OrderNo: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1PRTMF: TcxGridDBColumn;
v1PRTKZ: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
Panel1: TPanel;
Label1: TLabel;
Label15: TLabel;
Label16: TLabel;
orderno: TEdit;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
CDS_Main: TClientDataSet;
DataSource1: TDataSource;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
v1Column13: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
Button1: TButton;
Button2: TButton;
Button3: TButton;
v1Column15: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
v1Column16: TcxGridDBColumn;
Label2: TLabel;
Label3: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
Button4: TButton;
Button5: TButton;
v1Column17: TcxGridDBColumn;
Panel2: TPanel;
SmalMF1: TEdit;
SmalMF2: TEdit;
SmalMF3: TEdit;
SmalMF4: TEdit;
SmalMF5: TEdit;
SmalMF6: TEdit;
Label4: TLabel;
SmalMF7: TEdit;
SmalMF8: TEdit;
SmalMF9: TEdit;
SmalMF10: TEdit;
SmalMF11: TEdit;
SmalMF12: TEdit;
v1Column18: TcxGridDBColumn;
v1Column19: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column21: TcxGridDBColumn;
v1Column22: TcxGridDBColumn;
v1Column23: TcxGridDBColumn;
Button6: TButton;
v1Column24: TcxGridDBColumn;
v1Column25: TcxGridDBColumn;
cxGridPopupMenu1: TcxGridPopupMenu;
Button7: TButton;
v1Column26: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ordernoChange(Sender: TObject);
procedure v1Column4PropertiesEditValueChanged(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Tv1DblClick(Sender: TObject);
procedure v1Column19PropertiesEditValueChanged(Sender: TObject);
procedure v1Column23PropertiesEditValueChanged(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure v1Column24PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column24PropertiesEditValueChanged(Sender: TObject);
procedure v1Column25PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column25PropertiesEditValueChanged(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
procedure VisbleControl(Panel55:TWinControl;XS:Boolean;SXCount:Integer);
public
{ Public declarations }
end;
var
frmProductionAnPai: TfrmProductionAnPai;
implementation
uses
U_DataLink,U_Fun,U_OrderAttachment,U_ZDYHelpSel,U_JiangLiaoSet;
{$R *.dfm}
procedure TfrmProductionAnPai.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
orderno.SetFocus;
Action:=caFree;
end;
procedure TfrmProductionAnPai.FormDestroy(Sender: TObject);
begin
frmProductionAnPai:=nil;
end;
procedure TfrmProductionAnPai.FormCreate(Sender: TObject);
begin
cxGrid1.Align:=alClient;
if Trim(DParameters1)='<27><><EFBFBD><EFBFBD>' then
begin
Button5.Visible:=True;
Button4.Visible:=True;
end else
begin
Button5.Visible:=False;
Button4.Visible:=False;
end;
end;
procedure TfrmProductionAnPai.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' exec P_ProductAnPai :begdate,:enddate,:pstate,:Wsql');
if cxTabControl1.TabIndex=0 then
begin
Parameters.ParamByName('begdate').Value:='';
Parameters.ParamByName('enddate').Value:='';
Parameters.ParamByName('pstate').Value:=1;
end else
if cxTabControl1.TabIndex=1 then
begin
Parameters.ParamByName('begdate').Value:='';
Parameters.ParamByName('enddate').Value:='';
Parameters.ParamByName('pstate').Value:=2;
end else
if cxTabControl1.TabIndex=2 then
begin
Parameters.ParamByName('begdate').Value:=FormatDateTime('yyyy-MM-dd',BegDate.Date) ;
Parameters.ParamByName('enddate').Value:=FormatDateTime('yyyy-MM-dd',EndDate.Date+1);
Parameters.ParamByName('pstate').Value:=3;
end;
Parameters.ParamByName('Wsql').Value:='';
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmProductionAnPai.Button1Click(Sender: TObject);
begin
orderno.SetFocus;
InitGrid();
end;
procedure TfrmProductionAnPai.FormShow(Sender: TObject);
begin
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10',Tv1,'<27>޷IJ<DEB7><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
EndDate.Date:=SGetServerDate(ADOQueryTemp);
BegDate.Date:=EndDate.Date-30;
if cxTabControl1.TabIndex=1 then
begin
Tv1.OptionsSelection.CellSelect:=False;
end else
Tv1.OptionsSelection.CellSelect:=True;
if Trim(DParameters1)='<27><><EFBFBD><EFBFBD>' then
begin
Tv1.OptionsSelection.CellSelect:=False;
end;
InitGrid();
end;
procedure TfrmProductionAnPai.ordernoChange(Sender: TObject);
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
end;
procedure TfrmProductionAnPai.v1Column4PropertiesEditValueChanged(
Sender: TObject);
var
mvalue:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
with CDS_Main do
begin
Edit;
FieldByName('SCOrder').Value:=Trim(mvalue);
FieldByName('AnPaiDate').Value:=Now;
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set SCOrder='''+Trim(mvalue)+'''');
SQL.Add(',AnPaiDate=getdate()');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmProductionAnPai.Button2Click(Sender: TObject);
begin
orderno.SetFocus;
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10',Tv1,'<27>޷IJ<DEB7><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmProductionAnPai.Button3Click(Sender: TObject);
begin
if CDS_Main.IsEmpty then Exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',cxGrid1);
end;
procedure TfrmProductionAnPai.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
if cxTabControl1.TabIndex=0 then
begin
Tv1.OptionsSelection.CellSelect:=True;
end else
Tv1.OptionsSelection.CellSelect:=False;
if Trim(DParameters1)='<27><><EFBFBD><EFBFBD>' then
begin
Tv1.OptionsSelection.CellSelect:=False;
end;
VisbleControl(Panel2,False,Panel2.ControlCount);
end;
procedure TfrmProductionAnPai.Button4Click(Sender: TObject);
begin
if cxTabControl1.TabIndex<>0 then Exit;
if Trim(DName)=Trim(CDS_Main.fieldbyname('AnPaiPerson').AsString) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set AnPaiChker='''+Trim(DName)+'''');
sql.Add(',AnPaiChkStatus=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>''');
sql.add(',AnPaiChkDate=getdate()');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
CDS_Main.Delete;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
Exit;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmProductionAnPai.Button5Click(Sender: TObject);
begin
if cxTabControl1.TabIndex<>1 then Exit;
if Trim(DName)=Trim(CDS_Main.fieldbyname('AnPaiPerson').AsString) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set AnPaiChker='''+Trim(DName)+'''');
sql.Add(',AnPaiChkStatus=''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'',');
sql.add('AnPaiChkDate=getdate()');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
CDS_Main.Delete;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
Exit;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmProductionAnPai.Tv1DblClick(Sender: TObject);
begin
try
frmOrderAttachment:=TfrmOrderAttachment.Create(Application);
with frmOrderAttachment do
begin
FAMainId:=Trim(Self.CDS_Main.fieldbyname('MainId').AsString);
Panel1.Enabled:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmOrderAttachment.Free;
end;
end;
procedure TfrmProductionAnPai.v1Column19PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FFieldName:String;
i:Integer;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
mvalue:='0';
FFieldName:=Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_Main do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set '+FFieldName+'='+Trim(mvalue));
SQL.Add(',AnPaiPerson='''+Trim(DName)+'''');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
if Trim(FFieldName)='SmalCount' then
begin
VisbleControl(Panel2,False,Panel2.ControlCount);
VisbleControl(Panel2,True,strtoint(mvalue)+1);
end;
if strtoint(mvalue)+1>0 then
begin
Button6.Visible:=True;
end;
end;
procedure TfrmProductionAnPai.v1Column23PropertiesEditValueChanged(
Sender: TObject);
var
mvalue:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
mvalue:='';
with CDS_Main do
begin
Edit;
FieldByName('SmalPC').Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set SmalPC='''+Trim(mvalue)+'''');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmProductionAnPai.VisbleControl(Panel55:TWinControl;XS:Boolean;SXCount:Integer);
var
i:Integer;
begin
with Panel55 do
begin
for i:=0 to SXCount-1 do
begin
Controls[i].Visible:=XS;
end;
end;
end;
procedure TfrmProductionAnPai.Button6Click(Sender: TObject);
var
i,j:Integer;
FFname,FFnameValue,FSubId:string;
begin
//FSubId:=Trim(CDS_Main.fieldbyname('SubId').AsString);
try
j:=0;
ADOQueryCmd.Connection.BeginTrans;
with Panel2 do
begin
for i:=0 to Panel2.ControlCount-1 do
begin
if Controls[i] is TLabel then Continue;
if Controls[i] is TButton then Continue;
if Controls[i].Visible=True then
begin
FFname:=Trim(Controls[i].Name);
if Trim(TEdit(Controls[i]).Text)='' then
begin
ADOQueryCmd.Connection.RollbackTrans;
j:=9;
Break;
end;
if StrToFloat((TEdit(Controls[i]).Text))=0 then
begin
ADOQueryCmd.Connection.RollbackTrans;
j:=10;
Break;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update WFBOrder_Sub Set '+FFname+'='+Trim(TEdit(Controls[i]).Text));
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
end;
end;
if j=0 then
ADOQueryCmd.Connection.CommitTrans
else
if j=9 then
begin
//ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
Exit;
end else
if j=10 then
begin
//ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>㣡','<27><>ʾ',0);
Exit;
end;
end;
//InitGrid();
// CDS_Main.Locate('SubId',Trim(FSubId),[]);
with Panel2 do
begin
j:=0;
for i:=0 to Panel2.ControlCount-1 do
begin
if Controls[i] is TLabel then Continue;
if Controls[i] is TButton then Continue;
if TEdit(Controls[i]).Visible=True then
begin
if j=0 then
FSubId:=Trim(TEdit(Controls[i]).Text)
else
FSubId:=FSubId+','+Trim(TEdit(Controls[i]).Text);
j:=j+1;
end;
end;
end;
with CDS_Main do
begin
Edit;
FieldByName('SmalMF').Value:=Trim(FSubId);
Post;
end;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8B7><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmProductionAnPai.Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
VisbleControl(Panel2,False,Panel2.ControlCount);
VisbleControl(Panel2,True,CDS_Main.fieldbyname('SmalCount').Value+1);
SCSHDataCDS(CDS_Main,Panel2,2);
if Trim(CDS_Main.FieldByName('SmalCount').AsString)='' then Exit;
if CDS_Main.fieldbyname('SmalCount').Value>0 then
begin
if cxTabControl1.TabIndex=0 then
Button6.Visible:=True
else
Button6.Visible:=False;
end;
end;
procedure TfrmProductionAnPai.v1Column24PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
var
mvalue:String;
begin
mvalue:=Trim(CDS_Main.fieldbyname('SmalNote').AsString);
try
frmZDYHelpSel:=TfrmZDYHelpSel.Create(Application);
with frmZDYHelpSel do
begin
flag:='SmalNote';
flagname:='<27><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>';
if ShowModal=1 then
begin
with Self.CDS_Main do
begin
Edit;
FieldByName('SmalNote').Value:=mvalue+Trim(ReturnStr);
//post;
end;
mvalue:=mvalue+ReturnStr;
with Self.ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('UPdate WFBOrder_Sub Set SmalNote='''+Trim(mvalue)+'''');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
end;
finally
end;
end;
procedure TfrmProductionAnPai.v1Column24PropertiesEditValueChanged(
Sender: TObject);
var
mvalue:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
mvalue:='';
with CDS_Main do
begin
Edit;
FieldByName('SmalNote').Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set SmalNote='''+Trim(mvalue)+'''');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmProductionAnPai.v1Column25PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
var
mvalue:String;
begin
mvalue:=Trim(CDS_Main.fieldbyname('DBNote').AsString);
try
frmZDYHelpSel:=TfrmZDYHelpSel.Create(Application);
with frmZDYHelpSel do
begin
flag:='DBNote';
flagname:='<27><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>';
if ShowModal=1 then
begin
with Self.CDS_Main do
begin
Edit;
FieldByName('DBNote').Value:=mvalue+Trim(ReturnStr);
//post;
end;
mvalue:=mvalue+ReturnStr;
with Self.ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('UPdate WFBOrder_Sub Set DBNote='''+Trim(mvalue)+'''');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
end;
finally
end;
end;
procedure TfrmProductionAnPai.v1Column25PropertiesEditValueChanged(
Sender: TObject);
var
mvalue:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
mvalue:='';
with CDS_Main do
begin
Edit;
FieldByName('DBNote').Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate WFBOrder_Sub Set DBNote='''+Trim(mvalue)+'''');
SQL.Add(' where SubId='''+Trim(CDS_Main.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmProductionAnPai.Button7Click(Sender: TObject);
begin
try
frmJiangLiaoSet:=TfrmJiangLiaoSet.Create(Application);
with frmJiangLiaoSet do
begin
if ShowModal=1 then
begin
end;
end;
finally
end;
end;
end.