?? u_form_samplebillfind.pas
字號:
unit U_Form_sampleBillFind;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Mask, EasyGrid, ButtonExCtl,uAdoSet,
uCheckValidate,uString;
type
TForm_sampleBillFind = class(TForm)
GroupBox1: TGroupBox;
Label3: TLabel;
ButtonExCtl1: TButtonExCtl;
BtnExit: TButtonExCtl;
Label1: TLabel;
Grid1: TEasyGrid;
beginDate: TMaskEdit;
_beginDate: TDateTimePicker;
endDate: TMaskEdit;
_endDate: TDateTimePicker;
procedure BtnExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure _beginDateCloseUp(Sender: TObject);
procedure _endDateCloseUp(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ButtonExCtl1Click(Sender: TObject);
private
{ Private declarations }
_AdoNewProduce:TuAdoSet;
_Check:TCheckValidate;
_str:TuString;
public
{ Public declarations }
end;
var
Form_sampleBillFind: TForm_sampleBillFind;
implementation
uses U_Form_SampleBill,uGlobal;
{$R *.dfm}
procedure TForm_sampleBillFind.BtnExitClick(Sender: TObject);
begin
EnableWindow(Form_SampleBill.Handle,true);
close;
end;
procedure TForm_sampleBillFind.FormCreate(Sender: TObject);
var
i:integer;
begin
_AdoNewProduce:=TuAdoSet.Create('newProduce',1);
_Check:=TCheckValidate.create;
_str:=TuString.Create;
grid1.Cells[1,1].ForeText:='編號';
grid1.ColWidths[1]:=120;
grid1.Cells[2,1].ForeText:='開票日期';
grid1.ColWidths[2]:=120;
grid1.Cells[3,1].ForeText:='單位名稱';
grid1.ColWidths[3]:=120;
grid1.Cells[4,1].ForeText:='產品名稱';
grid1.ColWidths[4]:=110;
grid1.Cells[5,1].ForeText:='規格';
grid1.ColWidths[5]:=70;
grid1.Cells[6,1].ForeText:='包裝';
grid1.ColWidths[6]:=70;
grid1.Cells[7,1].ForeText:='箱數量';
grid1.ColWidths[7]:=70;
grid1.Cells[8,1].ForeText:='瓶數量';
grid1.ColWidths[8]:=70;
grid1.Cells[9,1].ForeText:='出庫日期';
grid1.ColWidths[9]:=120;
grid1.Cells[10,1].ForeText:='酒庫名稱';
grid1.ColWidths[10]:=80;
grid1.Cells[11,1].ForeText:='保管員';
for i:=1 to grid1.ColCount-1 do
begin
grid1.Cells[i,1].Color:=rgb(0,143,247);
grid1.Cells[i,1].FontColor:=rgb(255,255,255);
end;///
beginDate.Text:=formatDateTime('yyyy-mm-dd',now);
_beginDate.Date:=strTodate(formatDateTime('yyyy-mm-dd',now));
endDate.Text:=formatDateTime('yyyy-mm-dd',now);
_endDate.Date:=strTodate(formatDateTime('yyyy-mm-dd',now));
end;
procedure TForm_sampleBillFind.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
EnableWindow(Form_SampleBill.Handle,true);
CanClose:=true;
end;
procedure TForm_sampleBillFind._beginDateCloseUp(Sender: TObject);
begin
begindate.Text:=formatDateTime('yyyy-mm-dd',_begindate.Date);
end;
procedure TForm_sampleBillFind._endDateCloseUp(Sender: TObject);
begin
enddate.Text:=formatDateTime('yyyy-mm-dd',_enddate.Date);
end;
procedure TForm_sampleBillFind.FormShow(Sender: TObject);
var
i,j:integer;
begin
for i:=2 to grid1.RowCount-1 do
begin
for j:=1 to grid1.ColCount-1 do
begin
grid1.Cells[j,i].ForeText:='';
end;
end;
grid1.RowCount:=3;
grid1.Refresh;
end;
procedure TForm_sampleBillFind.ButtonExCtl1Click(Sender: TObject);
var
param:TStringList;
strsql:string;
i,j:integer;
_Total1,_Total2,_Total3:double;
begin
param:=TStringList.Create;
param.clear;
for i:=2 to grid1.RowCount-1 do
begin
for j:=1 to grid1.ColCount-1 do
begin
grid1.Cells[j,i].ForeText:='';
end;
end;
grid1.RowCount:=3;
grid1.Refresh;
param.Clear;
param.Add(trim(begindate.text));
param.Add(trim(endDate.text));
param.Add(trim(_whichStore));
strSql:='select sampleBillCode,sampleBillDate,TRaderName,productName,specification,UnitName,productNum,bottleNum,OutStoreTime,';
strSql:=strSql+'WhichStore,worker from sale_newsample_Office where sampleBilldate>=:s1 and sampleBilldate<=:s2 and whichStore=:s3';
if _AdoNewproduce.getRecordCount(strsql,param)<=0 then
begin
showmessage('樣品票記錄不存在');
exit;
end;
param.Clear;
param.Add(trim(begindate.text));
param.Add(trim(endDate.text));
param.Add(trim(_whichStore));
strSql:='select sampleBillCode,sampleBillDate,TRaderName,productName,specification,UnitName,productNum,bottleNum,OutStoreTime,';
strSql:=strSql+'WhichStore,worker from sale_newsample_Office where sampleBilldate>=:s1 and sampleBilldate<=:s2 and whichStore=:s3';
_AdoNewproduce.BindToGrid(grid1,strSql,param);
{/*
計算合計:
*/}
_Total1:=0;
_Total2:=0;
for i:=2 to grid1.RowCount-2 do
begin
if grid1.cells[7,i].foretext<>'' then
begin
_Total1:=_Total1+strToFloat(grid1.cells[7,i].foretext);
end;
if grid1.cells[8,i].foretext<>'' then
begin
_Total2:=_Total2+strToFloat(grid1.cells[8,i].foretext);
end;
end;
grid1.cells[1,grid1.RowCount-1].ForeText:='合計:';
grid1.cells[7,grid1.RowCount-1].ForeText:=formatFloat('##0',_Total1);
grid1.cells[8,grid1.RowCount-1].ForeText:=formatFloat('##0',_Total2);
{/*
設置最后一行顏色
*/}
for i:=1 to grid1.ColCount-1 do
begin
grid1.Cells[i,grid1.RowCount-1].Color:=rgb(0,143,247);
grid1.Cells[i,grid1.RowCount-1].FontColor:=rgb(255,255,255);
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -