275 lines
7.3 KiB
ObjectPascal
275 lines
7.3 KiB
ObjectPascal
|
|
unit U_SalaryInPut;
|
|||
|
|
|
|||
|
|
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,
|
|||
|
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
|
|||
|
|
cxGridTableView, cxGridDBTableView, cxGrid, DBClient, cxTextEdit, DateUtils,
|
|||
|
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinWXI,
|
|||
|
|
dxDateRanges, dxScrollbarAnnotations;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmSalaryInPut = class(TForm)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBSave: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
DayCombo: TComboBox;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
YMCaption: TLabel;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
HJCaption: TLabel;
|
|||
|
|
cxGrid1: TcxGrid;
|
|||
|
|
Tv1: TcxGridDBTableView;
|
|||
|
|
v1EEName: TcxGridDBColumn;
|
|||
|
|
v1DVal: TcxGridDBColumn;
|
|||
|
|
v1Editer: TcxGridDBColumn;
|
|||
|
|
v1Edittime: TcxGridDBColumn;
|
|||
|
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
Order_Main: TClientDataSet;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure DayComboChange(Sender: TObject);
|
|||
|
|
procedure Order_MainAfterPost(DataSet: TDataSet);
|
|||
|
|
private
|
|||
|
|
FDay: Integer; //<2F><>ǰ¼<C7B0><C2BC><EFBFBD><EFBFBD>(1-31)
|
|||
|
|
FDays: Integer; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
FSRDate: TDateTime; //<2F><>ǰ¼<C7B0><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
FInitFlag: Boolean;
|
|||
|
|
procedure InitDayCombo();
|
|||
|
|
procedure InitData();
|
|||
|
|
procedure CalcHJ();
|
|||
|
|
function SaveData(): Boolean;
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
PState: Integer; //0:<3A><><EFBFBD><EFBFBD>; 1:<3A><EFBFBD>
|
|||
|
|
FYMonth: string; //<2F><><EFBFBD><EFBFBD>(yyyymm)
|
|||
|
|
FInitDay: Integer;
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmSalaryInPut: TfrmSalaryInPut;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
U_DataLink, U_RTFun;
|
|||
|
|
|
|||
|
|
const
|
|||
|
|
CNDayOfWeek: array[1..7] of string = ('<27><>', 'һ', '<27><>', '<27><>', '<27><>', '<27><>', '<27><>');
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
FInitFlag := True;
|
|||
|
|
YMCaption.Caption := Copy(FYMonth, 1, 4) + '<27><>' + Copy(FYMonth, 5, 2) + '<27><>';
|
|||
|
|
if PState = 1 then
|
|||
|
|
Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
|
else
|
|||
|
|
Caption := '<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>';
|
|||
|
|
InitDayCombo();
|
|||
|
|
InitData();
|
|||
|
|
CalcHJ();
|
|||
|
|
FInitFlag := False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.InitDayCombo();
|
|||
|
|
var
|
|||
|
|
i, FY, FM, FDay: Integer;
|
|||
|
|
begin
|
|||
|
|
FY := StrToInt(Copy(FYMonth, 1, 4));
|
|||
|
|
FM := StrToInt(Copy(FYMonth, 5, 2));
|
|||
|
|
FDays := DaysInMonth(EncodeDate(FY, FM, 1));
|
|||
|
|
DayCombo.Items.Clear;
|
|||
|
|
for i := 1 to FDays do
|
|||
|
|
DayCombo.Items.Add(Format('%d<><64>(%s)', [i, CNDayOfWeek[DayOfWeek(EncodeDate(FY, FM, i))]]));
|
|||
|
|
//Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD>
|
|||
|
|
if (FInitDay >= 1) and (FInitDay <= FDays) then
|
|||
|
|
FDay := FInitDay
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
FDay := DayOf(SGetServerDate(ADOQueryTemp));
|
|||
|
|
if FDay > FDays then
|
|||
|
|
FDay := 1;
|
|||
|
|
end;
|
|||
|
|
DayCombo.ItemIndex := FDay - 1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.InitData();
|
|||
|
|
begin
|
|||
|
|
if DayCombo.ItemIndex < 0 then
|
|||
|
|
Exit;
|
|||
|
|
FDay := DayCombo.ItemIndex + 1;
|
|||
|
|
FSRDate := EncodeDate(StrToInt(Copy(FYMonth, 1, 4)), StrToInt(Copy(FYMonth, 5, 2)), FDay);
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select E.EEID,E.EECode,E.EEName ');
|
|||
|
|
sql.Add(' ,S.GZS as DVal,S.SALID as SALID,S.Editer as Editer,S.Edittime as Edittime ');
|
|||
|
|
sql.Add(' from SY_Employee E ');
|
|||
|
|
sql.Add(' left join SY_Salary S on S.EEID=E.EEID and S.GZRQ=' + quotedstr(FormatDateTime('yyyy-mm-dd', FSRDate)));
|
|||
|
|
sql.Add(' where isnull(E.EEType,''<27><>ʽ'')<>''<27><>ְ'' or S.EEID is not null ');
|
|||
|
|
sql.Add(' order by E.EECode ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS(ADOQueryTemp, Order_Main);
|
|||
|
|
SInitCDSData(ADOQueryTemp, Order_Main);
|
|||
|
|
TDateTimeField(Order_Main.FieldByName('Edittime')).DisplayFormat := 'mm-dd hh:nn';
|
|||
|
|
Order_Main.MergeChangeLog;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.DayComboChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if FInitFlag then
|
|||
|
|
Exit;
|
|||
|
|
if DayCombo.ItemIndex < 0 then
|
|||
|
|
Exit;
|
|||
|
|
if Order_Main.ChangeCount > 0 then
|
|||
|
|
if Application.MessageBox('<27>л<EFBFBD><D0BB><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
begin
|
|||
|
|
FInitFlag := True;
|
|||
|
|
DayCombo.ItemIndex := FDay - 1;
|
|||
|
|
FInitFlag := False;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
InitData();
|
|||
|
|
CalcHJ();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.Order_MainAfterPost(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
CalcHJ();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.CalcHJ();
|
|||
|
|
var
|
|||
|
|
FVal, FHJ: Double;
|
|||
|
|
FBm: TBookmark;
|
|||
|
|
begin
|
|||
|
|
FHJ := 0;
|
|||
|
|
with Order_Main do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
FBm := GetBookmark;
|
|||
|
|
First;
|
|||
|
|
while not Eof do
|
|||
|
|
begin
|
|||
|
|
if TryStrToFloat(Trim(fieldbyname('DVal').AsString), FVal) then
|
|||
|
|
FHJ := FHJ + FVal;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
if FBm <> nil then
|
|||
|
|
begin
|
|||
|
|
GotoBookmark(FBm);
|
|||
|
|
FreeBookmark(FBm);
|
|||
|
|
end;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
HJCaption.Caption := FormatFloat('0.##', FHJ);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmSalaryInPut.SaveData(): Boolean;
|
|||
|
|
var
|
|||
|
|
mval: string;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
if Order_Main.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
if Order_Main.State in [dsEdit, dsInsert] then
|
|||
|
|
Order_Main.Post;
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
with Order_Main do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
First;
|
|||
|
|
while not Eof do
|
|||
|
|
begin
|
|||
|
|
mval := Trim(fieldbyname('DVal').AsString);
|
|||
|
|
if Trim(fieldbyname('SALID').AsString) = '' then
|
|||
|
|
begin
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>¼<EFBFBD><C2BC>ֵ -> <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
if mval <> '' then
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('insert into SY_Salary(GZRQ,EEID,GZS,Filler,Filltime) values(');
|
|||
|
|
sql.Add(quotedstr(FormatDateTime('yyyy-mm-dd', FSRDate)) + ',' + quotedstr(Trim(Order_Main.fieldbyname('EEID').AsString)));
|
|||
|
|
sql.Add(',' + quotedstr(mval) + ',' + quotedstr(Trim(DName)) + ',getdate())');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
// if mval = '' then
|
|||
|
|
// begin
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD> -> ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|||
|
|
// with ADOQueryCmd do
|
|||
|
|
// begin
|
|||
|
|
// Close;
|
|||
|
|
// sql.Clear;
|
|||
|
|
// sql.Add('delete SY_Salary where SALID=' + Trim(Order_Main.fieldbyname('SALID').AsString));
|
|||
|
|
// ExecSQL;
|
|||
|
|
// end;
|
|||
|
|
// end
|
|||
|
|
// else
|
|||
|
|
// begin
|
|||
|
|
//<2F>Ĺ<DEB8>ʱ -> <20><><EFBFBD>²<EFBFBD><C2B2><EFBFBD>¼<EFBFBD><EFBFBD><DEB8><EFBFBD>
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('update SY_Salary set GZS=' + quotedstr(mval));
|
|||
|
|
sql.Add(',Editer=' + quotedstr(Trim(DName)) + ',Edittime=getdate()');
|
|||
|
|
sql.Add(' where SALID=' + Trim(Order_Main.fieldbyname('SALID').AsString));
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
// end;
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
First;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
Order_Main.MergeChangeLog;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Order_Main.EnableControls;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.TBSaveClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
if SaveData() then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
ModalResult := 1;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmSalaryInPut.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Order_Main.ChangeCount > 0 then
|
|||
|
|
if Application.MessageBox('<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8>ȷ<EFBFBD><C8B7><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
Exit;
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|