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

556 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_WorkerDeptFeeInPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer,
cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB,
ExtCtrls, BtnEdit, cxDropDownEdit, cxCalendar, cxGridCustomPopupMenu,
cxGridPopupMenu;
type
TfrmWorkerDeptFeeInPut = class(TForm)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
ScrollBox1: TScrollBox;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
ADOTemp: TADOQuery;
ADOCmd: TADOQuery;
DataSource1: TDataSource;
Order_Sub: TClientDataSet;
ADOZDY: TADOQuery;
ADOQuery1: TADOQuery;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1MSMoney: TcxGridDBColumn;
cxGridPopupMenu1: TcxGridPopupMenu;
v1Column5: TcxGridDBColumn;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label5: TLabel;
Label9: TLabel;
Label4: TLabel;
WFDate: TDateTimePicker;
Worker: TBtnEditA;
WFType: TBtnEditA;
Note: TEdit;
Dept: TBtnEditA;
v1Column1: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
Label3: TLabel;
WFTypeSub: TBtnEditA;
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure WorkerBtnClick(Sender: TObject);
procedure v1Column3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure WFTypeBtnClick(Sender: TObject);
procedure v1Column2PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column7PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v1Column5PropertiesEditValueChanged(Sender: TObject);
procedure DeptBtnClick(Sender: TObject);
procedure WFTypeSubBtnClick(Sender: TObject);
private
FXS:Integer;
procedure InitData();
procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
function SaveData():Boolean;
procedure GetMaxConNO();
{ Private declarations }
public
PState,PCopyInt:Integer;
FMainId,FConNo,FConType:String;
{ Public declarations }
end;
var
frmWorkerDeptFeeInPut: TfrmWorkerDeptFeeInPut;
implementation
uses
U_DataLink,U_ZDYHelp,U_RTFun,U_GYSList,
U_SYDeptUserView;
{$R *.dfm}
procedure TfrmWorkerDeptFeeInPut.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid('<27><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>');
end;
procedure TfrmWorkerDeptFeeInPut.InitData();
begin
with ADOQuery1 do
begin
Close;
SQL.Clear;
sql.Add('select A.*,B.* from Worker_Fee_Main A left join Worker_Fee_Sub B on A.WFID=B.WFID');
sql.Add(' where A.WFID='''+Trim(FMainId)+'''');
Open;
end;
SCSHDataNew(ADOQuery1,Panel1,0);
with ADOQuery1 do
begin
Close;
SQL.Clear;
sql.Add('select * from Worker_Fee_Sub ');
sql.Add(' where WFID='''+Trim(FMainId)+'''');
Open;
end;
SCreateCDS20(ADOQuery1,Order_Sub);
SInitCDSData20(ADOQuery1,Order_Sub);
if PState=0 then
begin
WFDate.DateTime:=SGetServerDate(ADOTemp);
WFDate.Checked:=False;
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
Worker.Text:=Trim(DName);
end;
end;
end;
procedure TfrmWorkerDeptFeeInPut.ZDYHelp(FButn:TcxButtonEdit;LType:string);
begin
end;
procedure TfrmWorkerDeptFeeInPut.FormShow(Sender: TObject);
begin
ReadCxGrid('<27><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>');
InitData();
end;
procedure TfrmWorkerDeptFeeInPut.GetMaxConNO();
begin
end;
function TfrmWorkerDeptFeeInPut.SaveData():Boolean;
var
maxno,maxSubNo:String;
begin
try
Result:=False;
ADOCmd.Connection.BeginTrans;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if Trim(FMainId)='' then
begin
if GetLSNo(ADOCmd,maxno,'WF','Worker_Fee_Main',3,1)=False then
begin
ADOCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
end else
begin
maxno:=Trim(FMainId);
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from Worker_Fee_Main where WFId='''+Trim(FMainId)+'''');
Open;
end;
with ADOCmd do
begin
if Trim(FMainId)='' then
begin
Append;
end
else begin
Edit;
end;
FieldByName('WFId').Value:=Trim(maxno);
RTSetsavedata(ADOCmd,'Worker_Fee_Main',Panel1,0);
FieldByName('BXNO').Value:='BX'+Trim(maxno);
if Trim(FMainId)='' then
begin
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillerCode').Value:=Trim(DCode);
end else
begin
FieldByName('Editer').Value:=Trim(DName);
FieldByName('EditerCode').Value:=Trim(DCode);
FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
end;
Post;
end;
///<2F><><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>
with Order_Sub do
begin
First;
while not Eof do
begin
if Trim(Order_Sub.fieldbyname('WSId').AsString)='' then
begin
if GetLSNo(ADOCmd,maxSubNo,'WS','Worker_Fee_Sub',4,1)=False then
begin
ADOCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD>ɷ<EFBFBD><C9B7>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
exit;
end;
end else
begin
maxSubNo:=Trim(Order_Sub.fieldbyname('WSId').AsString);
end;
with ADOCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from Worker_Fee_Sub where ');
sql.Add(' WSId='''+Trim(maxSubNo)+'''');
Open;
end;
with ADOCmd do
begin
if Trim(Order_Sub.fieldbyname('WSId').AsString)='' then
Append
else
Edit;
FieldByName('WFID').Value:=Trim(maxno);
FieldByName('WSId').Value:=Trim(maxSubNo);
RTSetSaveDataCDS(ADOCmd,Tv1,Order_Sub,'Worker_Fee_Sub',0);
Post;
end;
Order_Sub.Edit;
Order_Sub.FieldByName('WSId').Value:=Trim(maxSubNo);
Next;
end;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('Update Worker_Fee_Main Set HZMoney=');
sql.Add(' (select isnull(Sum(isnull(Money,0)),0) from Worker_Fee_Sub A where A.WFID=Worker_Fee_Main.WFID)');
sql.Add(' where WFID='''+Trim(maxno)+'''');
ExecSQL;
end;
ADOCmd.Connection.CommitTrans;
FMainId:=Trim(maxno);
Result:=True;
except
Result:=False;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
end;
end;
procedure TfrmWorkerDeptFeeInPut.TBSaveClick(Sender: TObject);
var
FReal:Double;
FPPrice,PRTPrice,BCMoney,FPQty,ChaMoney:string;
begin
ToolBar1.SetFocus;
if Trim(Worker.Text)='' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Trim(WFType.Text)='' then
begin
Application.MessageBox('<27><><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
{if Trim(Dept.Text)='' then
begin
Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end; }
if WFDate.Checked=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ѡ<EFBFBD><D1A1>!','<27><>ʾ',0);
Exit;
end;
if Order_Sub.IsEmpty then
begin
Application.MessageBox('<27><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
exit;
end;
if Order_Sub.Locate('Money',Null,[])=True then
begin
Application.MessageBox('<27><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
Order_Sub.DisableControls;
with Order_Sub do
begin
First;
while not Eof do
begin
if Trim(Order_Sub.fieldbyname('MoneyKP').AsString)<>'' then
begin
if Order_Sub.fieldbyname('MoneyKP').Value<>0 then
begin
if Trim(Order_Sub.fieldbyname('FactoryName').AsString)='' then
begin
Application.MessageBox('<27><>Դ<EFBFBD>ز<EFBFBD><D8B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
end;
end;
next;
end;
end;
Order_Sub.EnableControls;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
//ModalResult:=1;
end;
end;
procedure TfrmWorkerDeptFeeInPut.ToolButton1Click(Sender: TObject);
begin
with Order_Sub do
begin
Append;
Post;
end;
end;
procedure TfrmWorkerDeptFeeInPut.ToolButton2Click(Sender: TObject);
begin
if Order_Sub.IsEmpty then Exit;
if Trim(Order_Sub.fieldbyname('WSId').AsString)<>'' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
end;
Order_Sub.Delete;
end;
procedure TfrmWorkerDeptFeeInPut.WorkerBtnClick(Sender: TObject);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='BXWorker';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
Worker.Text:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmWorkerDeptFeeInPut.v1Column3PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='KeMu';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
with Self.Order_Sub do
begin
Edit;
FieldByName('KeMu').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
// Post;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmWorkerDeptFeeInPut.WFTypeBtnClick(Sender: TObject);
var
fsj:string;
FWZ:Integer;
begin
fsj:=Trim(TBtnEditA(Sender).Hint);
FWZ:=Pos('/',fsj);
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:=Copy(fsj,1,FWZ-1);
flagname:=Copy(fsj,FWZ+1,Length(fsj)-fwz);
MainType:=Trim(Self.Dept.Text);
if Trim(flag)='WFType' then
begin
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
TBAdd.Visible:=False;
TBDel.Visible:=False;
TBEdit.Visible:=False;
end;
end;
if ShowModal=1 then
begin
TBtnEditA(Sender).Text:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmWorkerDeptFeeInPut.v1Column2PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
{ try
frmGYSList:=TfrmGYSList.Create(Application);
with frmGYSList do
begin
if ShowModal=1 then
begin
with Self.Order_Sub do
begin
Edit;
FieldByName('FactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString);
end;
end;
end;
finally
frmGYSList.Free;
end; }
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='BXGYS';
flagname:='<27><>Ӧ<EFBFBD><D3A6>';
if ShowModal=1 then
begin
with Self.Order_Sub do
begin
Edit;
FieldByName('FactoryName').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmWorkerDeptFeeInPut.v1Column7PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='BXQtyUnit';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ';
if ShowModal=1 then
begin
with Self.Order_Sub do
begin
Edit;
FieldByName('QtyUnit').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
// Post;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmWorkerDeptFeeInPut.v1Column5PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FName,FQty,FPrice:String;
begin
FName:=Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
mvalue:=TcxTextEdit(Sender).EditingText;
with Order_Sub do
begin
Edit;
FieldByName(FName).Value:=mvalue;
Post;
end;
FQty:=Trim(Order_Sub.fieldbyname('Qty').AsString);
FPrice:=Trim(Order_Sub.fieldbyname('Price').AsString);
if Trim(FQty)='' then FQty:='0';
if Trim(FPrice)='' then FPrice:='0';
with Order_Sub do
begin
edit;
FieldByName('Money').Value:=StrToFloat(FQty)*StrToFloat(FPrice);
end;
end;
procedure TfrmWorkerDeptFeeInPut.DeptBtnClick(Sender: TObject);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='BXDept';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
TBAdd.Visible:=False;
TBDel.Visible:=False;
TBEdit.Visible:=False;
end;
if ShowModal=1 then
begin
Dept.Text:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmWorkerDeptFeeInPut.WFTypeSubBtnClick(Sender: TObject);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='WFTypeSub';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
MainType:=Trim(Dept.Text)+Trim(WFType.Text);
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
TBAdd.Visible:=False;
TBDel.Visible:=False;
TBEdit.Visible:=False;
end;
if ShowModal=1 then
begin
WFTypeSub.Text:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
end.