📄 cp.pas
字号:
unit cp;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, Grids, DBGrids, Db, DBTables, Menus, ADODB;
type
Tfrm_cp = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Panel3: TPanel;
Label1: TLabel;
Button5: TButton;
StringGrid1: TStringGrid;
Edit1: TEdit;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
SaveDialog1: TSaveDialog;
ListBox1: TListBox;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
Query_gzdx: TADOQuery;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure PopupMenu1Popup(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
SelRowCount: Integer;
procedure OutDisk;
procedure outdisk2;
function ReturnNextMonth(Curr: Integer): String;
procedure Save_Disk(Str: String);
function BankBit(Str: String): String;
function BankShortBit(Str: String;Flag: Integer): String;
function BankLongBit(Str: String;Flag: Integer): String;
{ Private declarations }
public
{ Public declarations }
end;
var
frm_cp: Tfrm_cp;
implementation
uses dl, yggzjgtz, pub,dm;
{$R *.DFM}
procedure Tfrm_cp.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
end;
procedure Tfrm_cp.FormShow(Sender: TObject);
var NowDate: String;
begin
NowDate := FormatDatetime('YYYYMMDDHHMMSS',Date);
Edit1.Text := Copy(NowDate,1,6);
Frm_cp.Width := 751;
Frm_cp.Height := 432;
StringGrid1.ColWidths[0] := 0;
SelRowCount := -1;
end;
procedure Tfrm_cp.Button5Click(Sender: TObject);
var Sql: String;
I,J: Integer;
begin
J := 2;
for I := 0 to StringGrid1.RowCount - 1 do
StringGrid1.Rows[I].Clear;
Sql := 'select mc from jbcsb'
+' where lx=1';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.Open;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
StringGrid1.Cells[J,0] := ADOQuery1.FieldByName('mc').AsString;
J := J + 1;
ADOQuery1.Next;
end;
StringGrid1.Cells[1,0] := '姓名';
StringGrid1.Cells[0,0] := '工号';
Sql := 'select distinct a.ygh,a.xm xm from ygzlb a,ygxjjgb b where b.yf='''
+Edit1.Text+''''+' and a.ygh=b.ygh';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.Open;
StringGrid1.RowCount := ADOQuery1.RecordCount + 2;
if StringGrid1.RowCount > 1 then StringGrid1.FixedRows := 1;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
StringGrid1.Cols[0].Add(ADOQuery1.FieldByname('ygh').AsString);
StringGrid1.Cols[1].Add(ADOQuery1.FieldByname('xm').AsString);
ADOQuery1.Next;
end;
Sql := 'select a.mc,b.ygh,c.sm,c.ygh,c.xszmid from'
+' jbcsb a,ygzlb b,ygxjjgb c where c.yf='
+''''+Edit1.Text+''''+' and a.id=c.xszmid and a.lx=1'
+' and b.ygh=c.ygh';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.Open;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
for I := 1 to StringGrid1.RowCount - 1 do
begin
if ADOQuery1.FieldByName('ygh').AsString = StringGrid1.Cols[0].Strings[I] then
begin
for J := 2 to StringGrid1.ColCount - 1 do
begin
if ADOQuery1.FieldByName('mc').AsString = StringGrid1.Rows[0].Strings[J] then
begin
StringGrid1.Cells[J,I] := FormatFloat('0.00',ADOQuery1.FieldByName('sm').AsFloat);
Break;
end;
end;
end;
end;
ADOQuery1.Next;
end;
for I := 1 to StringGrid1.ColCount - 1 do
begin
if I = 1 then StringGrid1.Cells[I,StringGrid1.RowCount-1] := '合计'
else
begin
if Trim(StringGrid1.Cells[I,StringGrid1.RowCount-1])='' then
StringGrid1.Cells[I,StringGrid1.RowCount-1]:= '0.00';
for J := 1 to StringGrid1.RowCount - 1 do
begin
if (J <> StringGrid1.RowCount-1) then
begin
if Trim(StringGrid1.Cells[I,J]) = '' then StringGrid1.Cells[I,J] := '0.00';
StringGrid1.Cells[I,StringGrid1.RowCount-1] :=
FloatToStr(StrToFloat(StringGrid1.Cells[I,J])+StrToFloat(StringGrid1.Cells[I,StringGrid1.RowCount-1]));
StringGrid1.Cells[I,StringGrid1.RowCount-1] := FormatFloat('0.00',StrToFloat(StringGrid1.Cells[I,StringGrid1.RowCount-1]));
end;
end;
end;
end;
end;
procedure Tfrm_cp.Button1Click(Sender: TObject);
begin
Close;
end;
procedure Tfrm_cp.Button2Click(Sender: TObject);
var FileDir: String;
Sql: String;
begin
if Application.MessageBox('确认出盘吗?','系统提示',mb_IconInformation+mb_OK+mb_OKCancel)=IDCancel then Exit;
if Trim(StringGrid1.Cols[0].Strings[1]) = '' then
begin
Application.MessageBox('没有可出盘的数据!','系统提示',mb_IconInformation+mb_OK);
Exit;
end;
if SaveDialog1.Execute then
begin
Sql := 'select csdm from kjcsb where yf='
+''''+Trim(Edit1.Text)+''' and csmc=''出盘标志''';
ADOQuery2.Close;
ADOQuery2.Sql.Clear;
ADOQuery2.Sql.Add(Sql);
ADOQuery2.Open;
if ADOQuery2.IsEmpty then
outdisk2
else if ADOQuery2.FieldByName('csdm').AsString = '0' then
OutDisk;
FileDir := SaveDialog1.FileName;
Save_Disk(FileDir);
Application.MessageBox('出盘成功!','系统提示',mb_IconInformation+mb_OK);
end
else
begin
Application.MessageBox('您未选择存放路径,系统将不出盘!','系统提示',mb_IconInformation+mb_OK);
Exit;
end;
end;
procedure Tfrm_cp.OutDisk;
var Sql,DateStr,NextMonth: String;
begin
DateStr := FormatDateTime('YYYY-MM-DD HH:MM:SS',Now);
Sql := 'select yf,ygh,xszmid,sm from ygxjjgb where yf='''+Edit1.Text+'''';
ADOQuery2.Close;
ADOQuery2.Sql.Clear;
ADOQuery2.Sql.Add(Sql);
ADOQuery2.Open;
ADOQuery2.First;
while not ADOQuery2.Eof do
begin
Sql := 'insert into ygxjjgb(yf,ygh,xszmid,sm,czy,czsj) values('
+''''+ReturnNextMonth(StrToInt(Trim(Edit1.Text)))+''''+','+''''+ADOQuery2.FieldByName('ygh').AsString+''''
+','+ADOQuery2.FieldByName('xszmid').AsString+','+ADOQuery2.FieldByName('sm').AsString
+','+''''+dluser+''''+','+''''+DateStr+''''+')';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.ExecSQL;
ADOQuery2.Next;
end;
Sql := 'update kjcsb set csdm=''1'' where yf='''+Trim(Edit1.Text)+''''
+' and csmc=''出盘标志''';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.ExecSQL;
if Copy(Trim(Edit1.Text),5,2) = '12' then
NextMonth := IntToStr(StrToInt(Copy(Trim(Edit1.Text),5,2))+1)+'01'
else
NextMonth := IntToStr(StrToInt(Trim(Edit1.Text))+1);
Sql := 'insert into kjcsb(csdm,yf,csmc) values('
+'''0'','''+NextMonth+''','
+'''出盘标志'')';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.ExecSQL;
end;
procedure Tfrm_cp.OutDisk2;
var Sql,DateStr,NextMonth: String;
begin
DateStr := FormatDateTime('YYYY-MM-DD HH:MM:SS',Now);
Sql := 'select yf,ygh,xszmid,sm from ygxjjgb where yf='''+Edit1.Text+'''';
ADOQuery2.Close;
ADOQuery2.Sql.Clear;
ADOQuery2.Sql.Add(Sql);
ADOQuery2.Open;
ADOQuery2.First;
while not ADOQuery2.Eof do
begin
Sql := 'insert into ygxjjgb(yf,ygh,xszmid,sm,czy,czsj) values('
+''''+ReturnNextMonth(StrToInt(Trim(Edit1.Text)))+''''+','+''''+ADOQuery2.FieldByName('ygh').AsString+''''
+','+ADOQuery2.FieldByName('xszmid').AsString+','+ADOQuery2.FieldByName('sm').AsString
+','+''''+dluser+''''+','+''''+DateStr+''''+')';
ADOQuery1.Close;
ADOQuery1.Sql.Clear;
ADOQuery1.Sql.Add(Sql);
ADOQuery1.ExecSQL;
ADOQuery2.Next;
end;
sql:='insert into kjcsb(csdm,yf,csmc) values('
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -