952 lines
29 KiB
ObjectPascal
952 lines
29 KiB
ObjectPascal
|
|
unit U_WorkerPayListB; //
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
|||
|
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
|||
|
|
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
|
|||
|
|
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
|||
|
|
cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter, RM_Common, RM_Class,
|
|||
|
|
RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxTextEdit, cxPC, cxCheckBox,
|
|||
|
|
Menus, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmWorkerPayListB = class(TForm)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBRafresh: TToolButton;
|
|||
|
|
TBEdit: TToolButton;
|
|||
|
|
TBDel: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
ADOQueryMain: TADOQuery;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
TBExport: TToolButton;
|
|||
|
|
Order_Main: TClientDataSet;
|
|||
|
|
RM1: TRMGridReport;
|
|||
|
|
RMDBMain: TRMDBDataSet;
|
|||
|
|
RMXLSExport1: TRMXLSExport;
|
|||
|
|
CDS_PRT: TClientDataSet;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
BegDate: TDateTimePicker;
|
|||
|
|
EndDate: TDateTimePicker;
|
|||
|
|
Panel2: TPanel;
|
|||
|
|
CSDate: TDateTimePicker;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
CDS_Worker: TClientDataSet;
|
|||
|
|
ToolButton4: TToolButton;
|
|||
|
|
Worker: TEdit;
|
|||
|
|
PopupMenu1: TPopupMenu;
|
|||
|
|
N1: TMenuItem;
|
|||
|
|
N2: TMenuItem;
|
|||
|
|
Label8: TLabel;
|
|||
|
|
WPDateMonth: TEdit;
|
|||
|
|
TBAdd: TToolButton;
|
|||
|
|
TBUpdate: TToolButton;
|
|||
|
|
cxGrid1: TcxGrid;
|
|||
|
|
Tv1: TcxGridDBTableView;
|
|||
|
|
v1Column22: TcxGridDBColumn;
|
|||
|
|
v1Column5: TcxGridDBColumn;
|
|||
|
|
v1Column19: TcxGridDBColumn;
|
|||
|
|
v1Column8: TcxGridDBColumn;
|
|||
|
|
v1Column1: TcxGridDBColumn;
|
|||
|
|
v1Column27: TcxGridDBColumn;
|
|||
|
|
v1Column10: TcxGridDBColumn;
|
|||
|
|
v1PRTSpec: TcxGridDBColumn;
|
|||
|
|
v1Column3: TcxGridDBColumn;
|
|||
|
|
v1Column4: TcxGridDBColumn;
|
|||
|
|
v1Column6: TcxGridDBColumn;
|
|||
|
|
v1Column12: TcxGridDBColumn;
|
|||
|
|
v1Column29: TcxGridDBColumn;
|
|||
|
|
v1Column2: TcxGridDBColumn;
|
|||
|
|
v1Column13: TcxGridDBColumn;
|
|||
|
|
v1Column17: TcxGridDBColumn;
|
|||
|
|
v1Column7: TcxGridDBColumn;
|
|||
|
|
v1Column25: TcxGridDBColumn;
|
|||
|
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
|
Panel3: TPanel;
|
|||
|
|
v1SSel: TcxGridDBColumn;
|
|||
|
|
v1Column9: TcxGridDBColumn;
|
|||
|
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
|
ToolButton1: TToolButton;
|
|||
|
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
|
Tv1Column9: TcxGridDBColumn;
|
|||
|
|
Tv1Column10: TcxGridDBColumn;
|
|||
|
|
Tv1Column11: TcxGridDBColumn;
|
|||
|
|
Tv1Column12: TcxGridDBColumn;
|
|||
|
|
ToolButton2: TToolButton;
|
|||
|
|
ADOQuery1: TADOQuery;
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure TBEditClick(Sender: TObject);
|
|||
|
|
procedure TBDelClick(Sender: TObject);
|
|||
|
|
procedure TBExportClick(Sender: TObject);
|
|||
|
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure cxPageControl1Change(Sender: TObject);
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
|
procedure TBAddClick(Sender: TObject);
|
|||
|
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
|
procedure WorkerChange(Sender: TObject);
|
|||
|
|
procedure N1Click(Sender: TObject);
|
|||
|
|
procedure N2Click(Sender: TObject);
|
|||
|
|
procedure TBUpdateClick(Sender: TObject);
|
|||
|
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FInt, PFInt: Integer;
|
|||
|
|
canshu1, canshu2: string;
|
|||
|
|
procedure InitGrid();
|
|||
|
|
procedure InitForm();
|
|||
|
|
function SaveGZData(): Boolean;
|
|||
|
|
function DelData(): Boolean;
|
|||
|
|
procedure InitGridWsql(fsj: string);
|
|||
|
|
function SaveData(): Boolean;
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
//var
|
|||
|
|
// frmWorkerPayListB: TfrmWorkerPayListB;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
U_DataLink, U_RTFun, U_WorkPayInPutB, U_ZDYHelp;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
function TfrmWorkerPayListB.SaveGZData(): Boolean;
|
|||
|
|
var
|
|||
|
|
maxId, CRID, FMainId, X: string;
|
|||
|
|
FDate: TDateTime;
|
|||
|
|
begin
|
|||
|
|
FMainId := '';
|
|||
|
|
X := trim(Order_Main.fieldbyname('WPDateMonth').AsString) + '-01';
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
// sql.Add('SELECT DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,:FDate)+1, 0)) as dt');
|
|||
|
|
sql.Add('SELECT DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,''' + X + ''')+1, 0)) as dt');
|
|||
|
|
// Parameters.ParamByName('FDate').Value := trim(Order_Main.fieldbyname('WPDateMonth').AsString) + '-01';
|
|||
|
|
// ShowMessage(SQL.text);
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
FDate := ADOQueryTemp.fieldbyname('dt').AsDateTime;
|
|||
|
|
// FDate := Trim(ADOQueryTemp.fieldbyname('dt').AsString);
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_CR where YFID=''' + Trim(FMainId) + '''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
FMainId := Trim(ADOQueryCmd.fieldbyname('YFID').AsString);
|
|||
|
|
if Trim(FMainId) = '' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd, maxId, 'SK', 'YS_Money_CR', 4, 1) = False then
|
|||
|
|
begin
|
|||
|
|
// Result := False;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
maxId := FMainId;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_KC where FactoryName=''' + Trim(Order_Main.fieldbyname('Worker').AsString) + '''');
|
|||
|
|
sql.Add(' and KCType=''GYS'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryCmd.IsEmpty = False then
|
|||
|
|
begin
|
|||
|
|
CRID := ADOQueryCmd.fieldbyname('CRID').AsString;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('Update YS_Money_CRID set CRID=CRID+1');
|
|||
|
|
sql.Add('select * from YS_Money_CRID ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
CRID := ADOQueryCmd.fieldbyname('CRID').AsString;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_KC where 1<>1');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('CRID').Value := StrToInt(CRID);
|
|||
|
|
FieldByName('FactoryNo').Value := Trim(Order_Main.fieldbyname('Worker').AsString);
|
|||
|
|
FieldByName('FactoryName').Value := Trim(Order_Main.fieldbyname('Worker').AsString);
|
|||
|
|
FieldByName('ZdyStr1').Value := 'Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_CR where YFID=''' + Trim(FMainId) + '''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
if Trim(FMainId) = '' then
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('ChkStatusP').Value := 'δ<><CEB4><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('Filler').Value := Trim(DName);
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('Editer').Value := Trim(DName);
|
|||
|
|
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
|
|||
|
|
end;
|
|||
|
|
FieldByName('YFID').Value := Trim(maxId);
|
|||
|
|
FieldByName('CRID').Value := StrToInt(CRID);
|
|||
|
|
|
|||
|
|
FieldByName('CRType').Value := 'Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
|
|||
|
|
FieldByName('CRFlag').Value := 'Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('QtyFlag').Value := 1;
|
|||
|
|
FieldByName('FactoryNo').Value := Trim(Order_Main.fieldbyname('Worker').AsString);
|
|||
|
|
FieldByName('FactoryName').Value := Trim(Order_Main.fieldbyname('Worker').AsString);
|
|||
|
|
// RTSetsavedata(ADOQueryCmd, 'YS_Money_CR', Panel1, 2);
|
|||
|
|
// if Trim(FormatDateTime('yyyy-MM', CRTime.Date)) = Trim(FormatDateTime('yyyy-MM', SKDate.Date)) then
|
|||
|
|
// begin
|
|||
|
|
// FieldByName('CRTime').Value := SKDate.Date;
|
|||
|
|
// end
|
|||
|
|
// else
|
|||
|
|
// begin
|
|||
|
|
// FieldByName('CRTime').Value := formatdateTIme('yyyy-MM-dd', StrToDate(FDate));
|
|||
|
|
FieldByName('CRTime').Value := formatdateTIme('yyyy-MM-dd', FDate);
|
|||
|
|
// end;
|
|||
|
|
FieldByName('P_CodeName').Value := '<27><><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('ChkstatusP').Value := 'δ<><CEB4><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('JSMoney').Value := Trim(Order_Main.fieldbyname('YFHZMoney').AsString);
|
|||
|
|
FieldByName('Money').Value := Trim(Order_Main.fieldbyname('YFHZMoney').AsString);
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
FMainId := Trim(maxId);
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
|
// Result := True;
|
|||
|
|
except
|
|||
|
|
// Result := True;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
//frmWorkerPayListB:=nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action := caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
WriteCxGrid(Copy(Self.Caption, 1, Length(Self.Caption) - 1), Tv1, '<27><><EFBFBD><EFBFBD>');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.InitGrid();
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
ADOQueryMain.DisableControls;
|
|||
|
|
with ADOQueryMain do
|
|||
|
|
begin
|
|||
|
|
Filtered := False;
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select A.* ');
|
|||
|
|
sql.Add(',WPDateMonth=Convert(varchar(7),WPDate,120)');
|
|||
|
|
SQL.Add(' from Worker_Pay A where ');
|
|||
|
|
SQL.Add(' Convert(varchar(7),A.WPDate,120)>=''' + Trim(FormatDateTime('yyyy-MM', BegDate.Date)) + '''');
|
|||
|
|
SQL.Add(' and Convert(varchar(7),A.WPDate,120)<=''' + Trim(FormatDateTime('yyyy-MM', EndDate.Date)) + '''');
|
|||
|
|
sql.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
sql.Add(' order by WPDateMonth,XHInt');
|
|||
|
|
// ShowMessage(SQL.text);
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryMain, Order_Main);
|
|||
|
|
SInitCDSData20(ADOQueryMain, Order_Main);
|
|||
|
|
finally
|
|||
|
|
ADOQueryMain.EnableControls;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.InitForm();
|
|||
|
|
begin
|
|||
|
|
CSDate.Date := StrToDate(FormatDateTime('yyyy-MM', SGetServerDateMBeg(ADOQueryTemp) - 1) + '-01');
|
|||
|
|
EndDate.Date := CSDate.Date;
|
|||
|
|
BegDate.Date := CSDate.Date;
|
|||
|
|
ReadCxGrid(Copy(Self.Caption, 1, Length(Self.Caption) - 1), Tv1, '<27><><EFBFBD><EFBFBD>');
|
|||
|
|
//InitGrid();
|
|||
|
|
if Self.Caption = '<27>̶<EFBFBD><CCB6><EFBFBD><EFBFBD>ʲ<EFBFBD>ѯ*' then
|
|||
|
|
begin
|
|||
|
|
TBAdd.Visible := False;
|
|||
|
|
TBEdit.Visible := False;
|
|||
|
|
TBDel.Visible := False;
|
|||
|
|
TBExport.Visible := False;
|
|||
|
|
TBUpdate.Visible := False;
|
|||
|
|
v1SSel.Visible := False;
|
|||
|
|
v1SSel.Hidden := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBEditClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
CSDateStr, maxno, FWPID: string;
|
|||
|
|
begin
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
CSDateStr := Trim(FormatDateTime('yyyy-MM', CSDate.Date));
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from Worker_Pay where Convert(varchar(7),WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '''');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox(PChar(CSDateStr + '<27>·ݵĹ<DDB5><C4B9>ʲ<EFBFBD><CAB2><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!'), '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from Worker_Pay where WPDate=''' + Trim(Order_Main.fieldbyname('WPDate').AsString) + '''');
|
|||
|
|
sql.Add(' and isnull(ChkStatus,'''')<>'''' ');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty = False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ܱ༭!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with ADOQuery1 do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_CR where FactoryNo=''' + Trim(Order_Main.fieldbyname('Worker').AsString) + '''');
|
|||
|
|
sql.Add(' and convert(varchar(7),CRTime,120)=''' + Trim(Order_Main.fieldbyname('WPDateMonth').AsString) + ''' ');
|
|||
|
|
// SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQuery1.IsEmpty = False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Application.MessageBox(PChar('ȷ<><C8B7>Ҫ<EFBFBD><EFBFBD>' + CSDateStr + '<27>·ݵĹ<DDB5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'), '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
frmWorkPayInPutB := TfrmWorkPayInPutB.Create(Application);
|
|||
|
|
with frmWorkPayInPutB do
|
|||
|
|
begin
|
|||
|
|
FDate := Trim(FormatDateTime('yyyy-MM', CSDate.DateTime));
|
|||
|
|
// FPayType:=Trim(Self.PayType10.Text);
|
|||
|
|
if ShowModal = 1 then
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmWorkPayInPutB.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from Worker_Pay where WPDate=''' + Trim(Order_Main.fieldbyname('WPDate').AsString) + '''');
|
|||
|
|
sql.Add(' and isnull(ChkStatus,'''')<>'''' ');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty = False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Order_Main.Locate('SSel', True, []) = False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
Exit;
|
|||
|
|
if DelData() then
|
|||
|
|
begin
|
|||
|
|
//Order_Main.Delete;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmWorkerPayListB.DelData(): Boolean;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
Result := false;
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
Order_Main.DisableControls;
|
|||
|
|
with Order_Main do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while Locate('SSel', True, []) do
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('delete Worker_Pay where WPId=''' + Trim(Order_Main.fieldbyname('WPId').AsString) + '''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
Order_Main.delete;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
Order_Main.EnableControls;
|
|||
|
|
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Result := False;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBExportClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
TcxGridToExcel('<27>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid1);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBRafreshClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
SelOKNo(Order_Main, False);
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitForm();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.cxPageControl1Change(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
canshu1 := Trim(DParameters1);
|
|||
|
|
canshu2 := Trim(DParameters2);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.InitGridWsql(fsj: string);
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmWorkerPayListB.SaveData(): Boolean;
|
|||
|
|
var
|
|||
|
|
maxno, FWPID, XS, FFFInt: string;
|
|||
|
|
SYDate: TDateTime;
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select SYDate=dateadd(month,-1,:FFDate) ');
|
|||
|
|
Parameters.ParamByName('FFDate').Value := CSDate.DateTime;
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SYDate := ADOQueryTemp.fieldbyname('SYDate').AsDateTime;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select * ');
|
|||
|
|
sql.Add(' from Worker_Pay A ');
|
|||
|
|
sql.Add(' where Convert(varchar(7),A.WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', CSDate.DateTime)) + ''' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty = False then
|
|||
|
|
begin
|
|||
|
|
FFFInt := '<27><>';
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
FFFInt := '<27><>';
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
Result := False;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select A.DPID,A.Dept,A.BankNo,A.ShenFenNo,A.BasePay,A.YGName,B.XHInt,B.SheBaoFee,B.BaoMiMoney,B.GeShuiFee,A.LiZhiFlag,A.LiZhiDate ');
|
|||
|
|
sql.Add(' left join Worker_Pay B on A.ShenFenNo=B.IDNO and ');
|
|||
|
|
if Trim(FFFInt) = '<27><>' then
|
|||
|
|
SQL.Add(' Convert(varchar(7),B.WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', CSDate.DateTime)) + '''')
|
|||
|
|
else
|
|||
|
|
SQL.Add(' Convert(varchar(7),B.WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', SYDate)) + '''');
|
|||
|
|
//SQL.Add(' where isnull(A.PayType,'''')='''+Trim(PayType10.Text)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryTemp, CDS_Worker);
|
|||
|
|
SInitCDSData20(ADOQueryTemp, CDS_Worker);
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CDS_Worker.DisableControls;
|
|||
|
|
with CDS_Worker do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while not Eof do
|
|||
|
|
begin
|
|||
|
|
if CDS_Worker.FieldByName('LiZhiFlag').AsBoolean = True then
|
|||
|
|
begin
|
|||
|
|
if Trim(FormatDateTime('yyyy-MM', CSDate.DateTime)) > Trim(FormatDateTime('yyyy-MM', CDS_Worker.FieldByName('LiZhiDate').AsDateTime)) then
|
|||
|
|
begin
|
|||
|
|
Next;
|
|||
|
|
Continue;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from Worker_Pay where ');
|
|||
|
|
SQL.Add(' Convert(varchar(7),WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', CSDate.DateTime)) + '''');
|
|||
|
|
SQL.Add(' and IDNO=''' + Trim(CDS_Worker.fieldbyname('ShenFenNo').AsString) + '''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
FWPID := Trim(ADOQueryTemp.fieldbyname('WPID').AsString);
|
|||
|
|
if Trim(FWPID) = '' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd, maxno, 'WP', 'Worker_Pay', 4, 1) = False then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
maxno := Trim(FWPID);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
SQL.Add('select * from Worker_Pay where WPId=''' + Trim(maxno) + '''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
if Trim(FWPID) = '' then
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('Filler').Value := Trim(DName);
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('Editer').Value := Trim(DName);
|
|||
|
|
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
|
|||
|
|
end;
|
|||
|
|
FieldByName('WPId').Value := Trim(maxno);
|
|||
|
|
FieldByName('WPDate').Value := Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '-01';
|
|||
|
|
FieldByName('Worker').Value := Trim(CDS_Worker.fieldbyname('YGName').AsString);
|
|||
|
|
FieldByName('BankNo').Value := Trim(CDS_Worker.fieldbyname('BankNo').AsString);
|
|||
|
|
FieldByName('IDNO').Value := Trim(CDS_Worker.fieldbyname('ShenFenNo').AsString);
|
|||
|
|
FieldByName('BasePay').Value := CDS_Worker.fieldbyname('BasePay').Value;
|
|||
|
|
FieldByName('BaoMiMoney').Value := CDS_Worker.fieldbyname('BaoMiMoney').Value;
|
|||
|
|
FieldByName('XHInt').Value := CDS_Worker.fieldbyname('XHInt').Value;
|
|||
|
|
FieldByName('SheBaoFee').Value := CDS_Worker.fieldbyname('SheBaoFee').Value;
|
|||
|
|
FieldByName('GeShuiFee').Value := CDS_Worker.fieldbyname('GeShuiFee').Value;
|
|||
|
|
FieldByName('DPID').Value := Trim(CDS_Worker.fieldbyname('DPID').AsString);
|
|||
|
|
FieldByName('Dept').Value := Trim(CDS_Worker.fieldbyname('Dept').AsString);
|
|||
|
|
//FieldByName('PayType').Value:=Trim(PayType10.Text);
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
CDS_Worker.EnableControls;
|
|||
|
|
//<2F><><EFBFBD>²<EFBFBD><C2B2>ǹ̶<C7B9><CCB6><EFBFBD><EFBFBD>ʵ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD> <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ϼơ<CFBC>
|
|||
|
|
{ with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('Update Worker_Pay Set YFHZMoney=(select YFMoney from Worker_Pay_YF A ') ;
|
|||
|
|
sql.Add(' where A.WYDate=Worker_Pay.WPDate and A.Worker=Worker_Pay.Worker)');
|
|||
|
|
sql.Add(' where exists(select * from Worker_Pay_YF B where B.WYDate=Worker_Pay.WPDate and B.Worker=Worker_Pay.Worker)');
|
|||
|
|
sql.Add(' and WPDate='''+Trim(Trim(FormatDateTime('yyyy-MM',CSDate.Date))+'-01')+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end; }
|
|||
|
|
//<2F><><EFBFBD><EFBFBD> Ӧ<><D3A6><EFBFBD>ϼƽ<CFBC><C6BD><EFBFBD>
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('UPdate Worker_Pay Set YFHZMoney=');
|
|||
|
|
sql.Add('isnull(BasePay,0)+isnull(BaoMiMoney,0)+isnull(JiaBanMoney,0)+isnull(YFOtherMoney,0)');
|
|||
|
|
sql.Add(' where WPDate=''' + Trim(Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '-01') + '''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD> Ӧ<>ۻ<EFBFBD><DBBB>ܽ<EFBFBD><DCBD><EFBFBD>
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('UPdate Worker_Pay Set YKHZFee=');
|
|||
|
|
sql.Add('isnull(SheBaoFee,0)+isnull(QueQinFee,0)+isnull(GeShuiFee,0)+isnull(YKOtherFee,0)');
|
|||
|
|
sql.Add(' where WPDate=''' + Trim(Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '-01') + '''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('UPdate Worker_Pay Set SFMoney=');
|
|||
|
|
sql.Add('isnull(YFHZMoney,0)+isnull(YKHZFee,0)');
|
|||
|
|
sql.Add(' where WPDate=''' + Trim(Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '-01') + '''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
Result := False;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.cxTabControl1Change(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBAddClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
CSDateStr, FWPID, maxno, CSDateStrQ: string;
|
|||
|
|
begin
|
|||
|
|
CSDateStr := Trim(FormatDateTime('yyyy-MM', CSDate.Date));
|
|||
|
|
CSDateStrQ := FormatDateTime('yyyy-MM', StrToDate(CSDateStr + '-01') - 1) + '-01';
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from Worker_Pay where Convert(varchar(7),WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '''');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty = False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox(PChar(CSDateStr + '<27>·ݵĹ<DDB5><C4B9><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!'), '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if Application.MessageBox(PChar('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>' + CSDateStr + '<27>·ݵĹ<DDB5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'), '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
Exit;
|
|||
|
|
Panel3.Visible := True;
|
|||
|
|
Panel3.Refresh;
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD><CCB6>˵Ĺ<CBB5><C4B9><EFBFBD>
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * ');
|
|||
|
|
sql.Add(' into #Temp1');
|
|||
|
|
sql.Add(' from Worker_Pay A where A.WPDate=''' + Trim(CSDateStrQ) + '''');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
sql.Add(' and not exists');
|
|||
|
|
sql.Add(' (select * from Worker_Pay B where B.WPDate=''' + Trim(CSDateStr + '-01') + '''');
|
|||
|
|
sql.Add(' and B.Worker=A.Worker and B.DataType=A.DataType)');
|
|||
|
|
sql.Add(' Update #Temp1 Set ');
|
|||
|
|
sql.Add(' WPId=substring(WPId,1,12)+''' + Trim(CSDateStr) + '''');
|
|||
|
|
sql.Add(' ,WPDate=''' + Trim(CSDateStr + '-01') + '''');
|
|||
|
|
sql.Add(' Update #Temp1 Set FillTime=getdate(),Filler=''' + Trim(DName) + '''');
|
|||
|
|
sql.Add(' insert into Worker_Pay ');
|
|||
|
|
sql.Add(' select * from #Temp1');
|
|||
|
|
sql.Add(' Drop Table #Temp1 ');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
Panel3.Visible := False;
|
|||
|
|
try
|
|||
|
|
frmWorkPayInPutB := TfrmWorkPayInPutB.Create(Application);
|
|||
|
|
with frmWorkPayInPutB do
|
|||
|
|
begin
|
|||
|
|
FDate := Trim(FormatDateTime('yyyy-MM', CSDate.DateTime));
|
|||
|
|
// FPayType:=Trim(Self.PayType10.Text);
|
|||
|
|
if ShowModal = 1 then
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmWorkPayInPutB.Free;
|
|||
|
|
end;
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.ToolButton4Click(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
fPrintFile: string;
|
|||
|
|
begin
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>.rmf';
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Filtered := False;
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select A.*,WPDateMonth=Convert(varchar(7),WPDate,120) from Worker_Pay A');
|
|||
|
|
sql.Add(' where Convert(varchar(7),WPDate,120)=''' + Trim(Order_Main.fieldbyname('WPDateMonth').AsString) + '''');
|
|||
|
|
sql.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
sql.Add(' order by XHInt');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryTemp, CDS_PRT);
|
|||
|
|
SInitCDSData20(ADOQueryTemp, CDS_PRT);
|
|||
|
|
RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1);
|
|||
|
|
if FileExists(fPrintFile) then
|
|||
|
|
begin
|
|||
|
|
RMVariables['DName'] := Trim(DName);
|
|||
|
|
RM1.ShowPrintDialog := True;
|
|||
|
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
|
RM1.ShowReport;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>'), '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.WorkerChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryMain.Active = False then
|
|||
|
|
Exit;
|
|||
|
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
|
SCreateCDS20(ADOQueryMain, Order_Main);
|
|||
|
|
SInitCDSData20(ADOQueryMain, Order_Main);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.N1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
SelOKNo(Order_Main, True);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.N2Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
SelOKNo(Order_Main, False);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.TBUpdateClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
CSDateStr, FWPID, maxno, CSDateStrQ: string;
|
|||
|
|
begin
|
|||
|
|
CSDateStr := Trim(FormatDateTime('yyyy-MM', CSDate.Date));
|
|||
|
|
CSDateStrQ := FormatDateTime('yyyy-MM', StrToDate(CSDateStr + '-01') - 1) + '-01';
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from Worker_Pay where Convert(varchar(7),WPDate,120)=''' + Trim(FormatDateTime('yyyy-MM', CSDate.Date)) + '''');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox(PChar(CSDateStr + '<27>·ݵĹ<DDB5><C4B9>ʲ<EFBFBD><CAB2><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD>!'), '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if Application.MessageBox(PChar('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>' + CSDateStr + '<27>·ݵĹ<DDB5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'), '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
Exit;
|
|||
|
|
Panel3.Caption := '<27><><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ժ<D4BA><F3A1A3A1><EFBFBD>';
|
|||
|
|
Panel3.Visible := True;
|
|||
|
|
Panel3.Refresh;
|
|||
|
|
try
|
|||
|
|
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD><CCB6>˵Ĺ<CBB5><C4B9><EFBFBD>
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * ');
|
|||
|
|
sql.Add(' into #Temp1');
|
|||
|
|
sql.Add(' from Worker_Pay A where A.WPDate=''' + Trim(CSDateStrQ) + '''');
|
|||
|
|
SQL.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
sql.Add(' and not exists');
|
|||
|
|
sql.Add(' (select * from Worker_Pay B where B.WPDate=''' + Trim(CSDateStr + '-01') + '''');
|
|||
|
|
sql.Add(' and B.Worker=A.Worker and B.DataType=A.DataType)');
|
|||
|
|
sql.Add(' Update #Temp1 Set ');
|
|||
|
|
sql.Add(' WPId=substring(WPId,1,12)+''' + Trim(CSDateStr) + '''');
|
|||
|
|
sql.Add(' ,WPDate=''' + Trim(CSDateStr + '-01') + '''');
|
|||
|
|
sql.Add(' Update #Temp1 Set FillTime=getdate(),Filler=''' + Trim(DName) + '''');
|
|||
|
|
sql.Add(' insert into Worker_Pay ');
|
|||
|
|
sql.Add(' select * from #Temp1');
|
|||
|
|
sql.Add(' Drop Table #Temp1 ');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD>
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
Panel3.Visible := False;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>³ɹ<C2B3><C9B9><EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.ToolButton1Click(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
fPrintFile: string;
|
|||
|
|
begin
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD>·ݹ<C2B7><DDB9><EFBFBD>.rmf';
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Filtered := False;
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select A.*,WPDateMonth=Convert(varchar(7),WPDate,120) from Worker_Pay A');
|
|||
|
|
sql.Add(' where Worker=''' + Trim(Order_Main.fieldbyname('Worker').AsString) + '''');
|
|||
|
|
sql.Add(' and Convert(varchar(4),WPDate,120)=''' + Trim(FormatDateTime('yyyy', Order_Main.fieldbyname('WPDate').AsDateTime)) + '''');
|
|||
|
|
sql.Add(' and isnull(DataType,'''')=''B'' ');
|
|||
|
|
sql.Add(' order by Convert(varchar(7),WPDate,120)');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryTemp, CDS_PRT);
|
|||
|
|
SInitCDSData20(ADOQueryTemp, CDS_PRT);
|
|||
|
|
RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1);
|
|||
|
|
if FileExists(fPrintFile) then
|
|||
|
|
begin
|
|||
|
|
RMVariables['DName'] := Trim(DName);
|
|||
|
|
RM1.ShowPrintDialog := True;
|
|||
|
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
|
RM1.ShowReport;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + '<27><><EFBFBD><EFBFBD><EFBFBD>·ݹ<C2B7><DDB9><EFBFBD>'), '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmWorkerPayListB.ToolButton2Click(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
maxId, CRID, FMainId, X: string;
|
|||
|
|
FDate: TDateTime;
|
|||
|
|
begin
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
if Order_Main.Locate('SSel', True, []) = False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
Order_Main.DisableControls;
|
|||
|
|
// ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
with Order_Main do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while not Eof do
|
|||
|
|
begin
|
|||
|
|
if Order_Main.FieldByName('SSel').AsBoolean = True then
|
|||
|
|
begin
|
|||
|
|
if SaveGZData() then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
|
ModalResult := 1;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
// ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
Order_Main.EnableControls;
|
|||
|
|
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
|
// Panel9.Visible := false;
|
|||
|
|
// TBRafresh.Click;
|
|||
|
|
except
|
|||
|
|
// ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Order_Main.EnableControls;
|
|||
|
|
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|
|||
|
|
|