📄 ucount.pas
字号:
unit ucount;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, DBGridEhImpExp, ExtCtrls, dialogs, Grids, DBGridEh, Menus, ComCtrls,
DB, ADODB;
type
Tcount = class(TForm)
DBGridEh1: TDBGridEh;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
SaveDialog1: TSaveDialog;
procedure CancelBtnClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure FormActivate(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
FF_exp: string;
FF_xm: string;
FF_values: string;
FF_backcolor: TColor;
FF_font: TFont;
procedure SetF_exp(const Value: string);
procedure SetF_xm(const Value: string);
procedure SetF_values(const Value: string);
procedure SetF_backcolor(const Value: TColor);
procedure SetF_font(const Value: TFont);
{ Private declarations }
public
{ Public declarations }
published
property F_xm: string read FF_xm write SetF_xm;
property F_exp: string read FF_exp write SetF_exp;
property F_values: string read FF_values write SetF_values;
property F_font: TFont read FF_font write SetF_font;
property F_backcolor: TColor read FF_backcolor write SetF_backcolor;
end;
var
count: Tcount;
implementation
uses u_dm, u_main, FRM_SELECTFIELDS, frm_dbgrideh_print_set, ucount_bold;
{$R *.dfm}
procedure Tcount.CancelBtnClick(Sender: TObject);
begin
close;
end;
procedure Tcount.BitBtn1Click(Sender: TObject);
var
s: string;
begin
s := 'update rc set s1=0 where s1 is null and acount_id=' +
main.Acount_id;
dm1.EXE_SQL(s);
s := 'update rc set s2=0 where s2 is null and acount_id=' +
main.Acount_id;
dm1.EXE_SQL(s);
with dm1.A_jd_she do
begin
Close;
Parameters.ParamByName('@acount_id').Value := StrToInt(main.Acount_id);
Parameters.ParamByName('@min_date').Value := DateTimePicker1.DateTime;
Parameters.ParamByName('@max_date').Value := DateTimePicker2.DateTime;
Open;
DBGridEh1.DataSource := dm1.D_jd_she;
end;
end;
procedure Tcount.FormCreate(Sender: TObject);
var
s: string;
begin
// main.Scale_form(0, Self);
s := main.ACOUNT_YEAR;
DateTimePicker1.Date := Date;
DateTimePicker1.Time := EncodeTime(0, 0, 0, 0);
DateTimePicker2.Date := date;
DateTimePicker2.Time := EncodeTime(12, 59, 59, 0);
if main.Load_grid_enable then
if FileExists(main.dat_path + 'count.dat') then
DBGridEh1.Columns.LoadFromFile(main.dat_path + 'count.dat');
end;
procedure Tcount.BitBtn2Click(Sender: TObject);
begin
with TSELECTFIELDS.Create(self) do
begin
Dbgrideh := DBGridEh1;
ShowModal;
end;
end;
procedure Tcount.BitBtn3Click(Sender: TObject);
var
s: string;
begin
s := main.dw + main.ACOUNT_YEAR + '入库进度表';
with Tdbgrideh_print.Create(self) do
begin
PrintDBGridEh1.DBGridEh := DBGridEh1;
L_TITLE_CENTER.Caption := s;
s := '报表时间:' + DateToStr(Date);
L_GRIDE_BEFOR.Caption := s;
ShowModal;
end;
end;
procedure Tcount.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure Tcount.SetF_exp(const Value: string);
begin
FF_exp := Value;
end;
procedure Tcount.SetF_xm(const Value: string);
begin
FF_xm := Value;
end;
procedure Tcount.SetF_values(const Value: string);
begin
FF_values := Value;
end;
procedure Tcount.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
with dm1.A_jd_she do
begin
if F_exp = '=' then
begin
if FieldByName(F_xm).AsCurrency = StrToCurr(F_values) then
begin
AFont.Assign(F_font);
Background := F_backcolor;
exit;
end;
end;
if F_exp = '>' then
begin
if FieldByName(F_xm).AsCurrency > StrToCurr(F_values) then
begin
AFont.Assign(F_font);
Background := F_backcolor;
exit;
end;
end;
if F_exp = '<' then
begin
if FieldByName(F_xm).AsCurrency < StrToCurr(F_values) then
begin
AFont.Assign(F_font);
Background := F_backcolor;
exit;
end;
end;
if F_exp = '>=' then
begin
if FieldByName(F_xm).AsCurrency >= StrToCurr(F_values) then
begin
AFont.Assign(F_font);
Background := F_backcolor;
exit;
end;
end;
if F_exp = '<=' then
begin
if FieldByName(F_xm).AsCurrency <= StrToCurr(F_values) then
begin
AFont.Assign(F_font);
Background := F_backcolor;
exit;
end;
end;
if F_exp = '<>' then
begin
if FieldByName(F_xm).AsCurrency <> StrToCurr(F_values) then
begin
AFont.Assign(F_font);
Background := F_backcolor;
exit;
end;
end;
end;
end;
procedure Tcount.SetF_backcolor(const Value: TColor);
begin
FF_backcolor := Value;
end;
procedure Tcount.SetF_font(const Value: TFont);
begin
FF_font := Value;
end;
procedure Tcount.FormActivate(Sender: TObject);
begin
F_font := TFont.Create;
F_font.Assign(Self.Font);
F_backcolor := clWhite;
end;
procedure Tcount.BitBtn4Click(Sender: TObject);
var
xm: string;
begin
with Tcount_bold.Create(self) do
begin
if F_xm <> '' then
begin
ListBox1.ItemIndex := ListBox1.Items.IndexOf(F_xm);
ListBox2.ItemIndex := ListBox2.Items.IndexOf(F_exp);
Edit1.Text := F_values;
l_example.Font.Assign(F_font);
Panel1.Color := F_backcolor;
end;
if ShowModal = mrok then
begin
case ListBox1.ItemIndex of
0: xm := 'r_s1';
1: xm := 's1';
2: xm := 'x_s1';
3: xm := 'b_s1';
4: xm := 'r_s2';
5: xm := 's2';
6: xm := 'x_s2';
7: xm := 'b_s2';
8: xm := 'r_sum';
9: xm := 'y_sum';
10: xm := 'x_sum';
11: xm := 'b_sum';
end;
if trim(edit1.Text) <> '' then
begin
F_xm := xm;
F_exp := ListBox2.Items[ListBox2.itemindex];
F_values := Edit1.Text;
F_font.Assign(l_example.Font);
F_backcolor := Panel1.Color;
DBGridEh1.Invalidate;
end;
end;
end;
end;
procedure Tcount.Button1Click(Sender: TObject);
begin
F_xm := 'b_s1';
F_exp := '=';
F_values := '0';
end;
procedure Tcount.BitBtn5Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
if SaveDialog1.FileName <> '' then
begin
if UpperCase(Copy(SaveDialog1.FileName, Length(SaveDialog1.FileName) -
2, 3)) <> 'XLS' then
SaveDialog1.FileName := SaveDialog1.FileName + '.XLS';
SaveDBGridEhToExportFile(TDBGridEhExportAsXLS, DBGridEh1,
SaveDialog1.FileName, true);
MessageDlg('网格数据已成功导出到文件!', mtWarning, [mbok], 0);
end;
end;
end;
procedure Tcount.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if main.Load_grid_enable then
DBGridEh1.Columns.SaveToFile(main.dat_path + 'count.dat');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -