📄 u_form_datacheck_1.pas
字号:
unit U_Form_DataCheck_1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, EasyGrid, StdCtrls,uAdoSet,uCheckValidate,uString, ButtonExCtl;
type
TForm_DataCheck_1 = class(TForm)
GroupBox1: TGroupBox;
Grid1: TEasyGrid;
BtnFind: TButtonExCtl;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BtnFindClick(Sender: TObject);
private
{ Private declarations }
_AdoNewProduce:TuAdoSet;
_Check:TCheckValidate;
_str:TuString;
public
{ Public declarations }
end;
var
Form_DataCheck_1: TForm_DataCheck_1;
_boxNumSum:double;
_bottleNumSum:double;
_emptyBoxNumSum:double;
implementation
uses U_Form_DataCheck,uGlobal;
{$R *.dfm}
procedure TForm_DataCheck_1.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
var
param:TStringList;
strsql:string;
_boxSum:string;
_EmptyBoxSum:string;
_bottleSum:string;
begin
param:=TStringList.Create;
param.Clear;
if Application.MessageBox('确定是否退出...','信息提示',MB_yesNo+MB_IconWarning)=id_yes then
begin
_boxSum:=trim(grid1.cells[11,grid1.rowcount-1].foretext);
_EmptyboxSum:=trim(grid1.cells[12,grid1.rowcount-1].foretext);
_bottleSum:=trim(grid1.cells[13,grid1.rowcount-1].foretext);
if (_boxSum<>'0') or (_bottleSum<>'0') or (_emptyboxSum<>'0') or (grid1.RowCount<7) then
begin
{/*
临时做,2008-05-03将退出后,信息存盘到newproduce-->sale_handRealStore_flag
*/}
param.Clear;
param.Add('CHK_followTohand');
param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
param.Add(_whichStore);
param.Add(trim(_boxSum));
param.Add(trim(_bottleSum));
param.Add('1');
strsql:='insert into sale_handRealStore_Flag(CHK_Type,CHK_CheckDate,';
strsql:=strsql+'CHK_whichStore,CHK_data1,CHK_data2,CHK_successFlag) Values(';
strsql:=strsql+':s1,:s2,:s3,:s4,:s5,:s6)';
_AdoNewproduce.actionRecord(strsql,param);
//showmessage('对不起,数据核对工作没进行或核对错误,请核对后再退出...');
EnableWindow(Form_DataCheck.Handle,true);
CanClose:=true;
end
else
begin
{/*
将退出后,信息存盘到newproduce-->sale_handRealStore_flag
*/}
param.Clear;
param.Add('CHK_followTohand');
param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
param.Add(_whichStore);
param.Add(trim(_boxSum));
param.Add(trim(_bottleSum));
param.Add('1');
strsql:='insert into sale_handRealStore_Flag(CHK_Type,CHK_CheckDate,';
strsql:=strsql+'CHK_whichStore,CHK_data1,CHK_data2,CHK_successFlag) Values(';
strsql:=strsql+':s1,:s2,:s3,:s4,:s5,:s6)';
_AdoNewproduce.actionRecord(strsql,param);
EnableWindow(Form_DataCheck.Handle,true);
CanClose:=true;
end;
end
else
begin
CanClose:=false;
end;
end;
procedure TForm_DataCheck_1.FormCreate(Sender: TObject);
var
param:TStringList;
strsql:string;
i,j:integer;
begin
_AdoNewProduce:=TuAdoSet.Create('newProduce',1);
_Check:=TCheckValidate.create;
_str:=TuString.Create;
param:=TStringList.Create;
param.Clear;
grid1.SetMerges(rect(1,1,1,2));
grid1.Cells[1,1].ForeText:='序号';
grid1.ColWidths[1]:=50;
grid1.SetMerges(rect(2,1,2,2));
grid1.Cells[2,1].ForeText:='产品名称';
grid1.ColWidths[2]:=120;
grid1.SetMerges(rect(3,1,3,2));
grid1.Cells[3,1].ForeText:='规格';
grid1.ColWidths[3]:=60;
grid1.SetMerges(rect(4,1,4,2));
grid1.Cells[4,1].ForeText:='单位';
grid1.ColWidths[4]:=60;
grid1.SetMerges(rect(5,1,6,1));
grid1.Cells[5,1].ForeText:='接班库存';
grid1.ColWidths[5]:=70;
grid1.cells[5,2].ForeText:='成套数';
grid1.ColWidths[6]:=60;
grid1.cells[6,2].ForeText:='空箱数';
grid1.ColWidths[7]:=60;
grid1.cells[7,2].ForeText:='瓶数';
grid1.SetMerges(rect(8,1,9,1));
grid1.Cells[8,1].ForeText:='前一天交班库存';
grid1.ColWidths[8]:=60;
grid1.cells[8,2].ForeText:='成套数';
grid1.ColWidths[9]:=60;
grid1.cells[9,2].ForeText:='空箱数';
grid1.ColWidths[10]:=60;
grid1.cells[10,2].ForeText:='瓶数';
grid1.SetMerges(rect(11,1,12,1));
grid1.Cells[11,1].ForeText:='库存相差';
grid1.ColWidths[11]:=60;
grid1.cells[11,2].ForeText:='成套数';
grid1.ColWidths[12]:=60;
grid1.cells[12,2].foreText:='空箱数';
grid1.ColWidths[13]:=60;
grid1.cells[13,2].foreText:='瓶数';
for i:=1 to grid1.ColCount-1 do
begin
grid1.Cells[i,1].Color:=rgb(0,143,247);
grid1.Cells[i,2].Color:=rgb(0,143,247);
grid1.Cells[i,1].FontColor:=rgb(255,255,255);
grid1.Cells[i,2].FontColor:=rgb(255,255,255);
end;
_boxNumSum:=0;
_bottleNumSum:=0;
_emptyBoxNumSum:=0;
end;
procedure TForm_DataCheck_1.Button1Click(Sender: TObject);
begin
EnableWindow(Form_DataCheck.Handle,true);
close;
end;
procedure TForm_DataCheck_1.BtnFindClick(Sender: TObject);
var
param:TStringList;
strsql:string;
i:integer;
_boxNum,_bottleNum,_emptyBoxNum:integer;
_boxNum1,_bottleNum1,_emptyBoxNum1:integer;
_boxNum2,_bottleNum2,_emptyBoxNum2:integer;
_CheckDate:string;
_PrevDate:string;
begin
param:=TStringList.Create;
param.Clear;
_CheckDate:=formatDateTime('yyyy-mm-dd',now);
_prevDate:=formatDateTime('yyyy-mm-dd',strToDate(_CheckDate)-1);
//showmessage(_prevDate);
{/*
查询当天的接班数据
*/}
param.Clear;
param.Add(_whichStore);
param.add(_Checkdate);
param.Add(_whichStore);
param.add(_Checkdate);
strsql:='select SF_ProduceName,SF_specification,SF_UnitName,SF_boxNum,';
strsql:=strsql+'SF_EmptyBoxNum,SF_bottleNum from sale_followStore where ';
strsql:=strsql+'SF_whichStore=:s1 and substring(SF_CheckDate,1,10)=:s2 UNiON ';
strsql:=strsql+'select SFO_ProductName,SFO_specification,SFO_UnitName,SFO_boxNum,';
strsql:=strsql+'SFO_EmptyBoxNum,SFO_bottleNum from sale_followStore_other where ';
strsql:=strsql+'SFO_whichStore=:s3 and SFO_followdate=:s4 ';
_AdoNewProduce.BindToGrid_JK(grid1,strsql,param,2,7,2);
for i:=3 to grid1.RowCount-2 do
begin
grid1.Cells[1,i].ForeText:=inttostr(i-2);
end;
{/*
查询前一天的交班数据
*/}
for i:=3 to grid1.RowCount-2 do
begin
param.clear;
param.Add(_whichStore);
param.add(_prevDate);
param.Add(trim(grid1.cells[2,i].foretext));
param.Add(trim(grid1.cells[3,i].foretext));
param.Add(trim(grid1.cells[4,i].foretext));
strsql:='select sum(convert(real,SF_boxNum)) as a,sum(convert(real,SF_EmptyBoxNum)) as c,sum(convert(real,SF_bottleNum)) as b from sale_handRealStore ';
strsql:=strsql+'where SF_whichStore=:s1 and substring(SF_CheckDate,1,10)=:s2 and SF_produceName=:s3 ';
strsql:=strsql+' and SF_specification=:s4 and SF_UnitName=:s5';
grid1.Cells[8,i].ForeText:=_AdoNewProduce.getFieldValue(strsql,param,'a');
grid1.Cells[9,i].ForeText:=_AdoNewProduce.getFieldValue(strsql,param,'c');
grid1.Cells[10,i].ForeText:=_AdoNewProduce.getFieldValue(strsql,param,'b');
end;
{/*
计算库存差额
*/}
for i:=3 to grid1.RowCount-2 do
begin
{/*
计算整箱数差
*/}
if grid1.cells[5,i].foretext<>'' then
begin
_boxNum:=strToInt(grid1.cells[5,i].foretext);
end
else
_boxNum:=0;
if grid1.cells[6,i].foretext<>'' then
begin
_EmptyboxNum:=strToInt(grid1.cells[6,i].foretext);
end
else
_EmptyboxNum:=0;
if grid1.cells[7,i].foretext<>'' then
begin
_bottleNum:=strToInt(grid1.cells[7,i].foretext);
end
else
_bottleNum:=0;
//grid1.cells[11,i].ForeText:=formatFloat('##0',strToInt(grid1.cells[5,i].foretext)-strToInt(grid1.cells[8,i].foretext));
{/*
计算整瓶数差
*/}
if grid1.cells[8,i].foretext<>'' then
begin
_boxNum1:=strToInt(grid1.cells[8,i].foretext);
end
else
_boxNum1:=0;
if grid1.cells[9,i].foretext<>'' then
begin
_EmptyboxNum1:=strToInt(grid1.cells[9,i].foretext);
end
else
_EmptyboxNum1:=0;
if grid1.cells[10,i].foretext<>'' then
begin
_bottleNum1:=strToInt(grid1.cells[10,i].foretext);
end
else
_bottleNum1:=0;
grid1.cells[11,i].ForeText:=formatFloat('##0',_boxNum-_boxNum1);
grid1.cells[12,i].ForeText:=formatFloat('##0',_EmptyBoxNum-_EmptyBoxNum1);
grid1.cells[13,i].ForeText:=formatFloat('##0',_bottleNum-_bottleNum1);
//grid1.cells[13,i].ForeText:=formatFloat('##0',_emptyBoxNum-_emptyBoxNum1);
end;
{/*
设置差额颜色
*/}
for i:=3 to grid1.RowCount-2 do
begin
grid1.cells[11,i].Color:=rgb(241,222,157);
grid1.cells[12,i].Color:=rgb(241,222,157);
grid1.cells[13,i].Color:=rgb(241,222,157);
if grid1.cells[11,i].ForeText<>'0' then
begin
grid1.cells[11,i].FontColor:=rgb(255,0,0);
end;
if grid1.cells[12,i].ForeText<>'0' then
begin
grid1.cells[12,i].FontColor:=rgb(255,0,0);
end;
if grid1.cells[13,i].ForeText<>'0' then
begin
grid1.cells[13,i].FontColor:=rgb(255,0,0);
end;
end;//for
{/*
计算差额合计
*/}
for i:=3 to grid1.RowCount-2 do
begin
if grid1.cells[11,i].foretext<>'' then
begin
_boxNumSum:=_boxNumSum+strToFloat(grid1.cells[11,i].foretext);
end;
if grid1.cells[12,i].foretext<>'' then
begin
_EmptyboxNumSum:=_EmptyboxNumSum+strToFloat(grid1.cells[12,i].foretext);
end;
if grid1.cells[13,i].foretext<>'' then
begin
_bottleNumSum:=_bottleNumSum+strToFloat(grid1.cells[13,i].foretext);
end;
//_emptyBoxNumSum:=_emptyboxNumSum+strToFloat(grid1.cells[13,i].foretext);
end;
grid1.Cells[11,grid1.RowCount-1].ForeText:=formatFloat('##0',_boxNumSum);
grid1.Cells[12,grid1.RowCount-1].ForeText:=formatFloat('##0',_EmptyboxNumSum);
grid1.Cells[13,grid1.RowCount-1].ForeText:=formatFloat('##0',_bottleNumSum);
//grid1.Cells[13,grid1.RowCount-1].ForeText:=formatFloat('##0',_emptyBoxNumSum);
{/*
设置最后一行颜色
*/}
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;
grid1.Refresh;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -