📄 u_form_wastebill.~pas
字号:
unit U_Form_WasteBill;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, EasyGrid, ComCtrls, StdCtrls, Mask, ButtonExCtl,uAdoSet,
uCheckValidate,uString;
type
TForm_WasteBill = class(TForm)
GroupBox1: TGroupBox;
BtnSave: TButtonExCtl;
BtnExit: TButtonExCtl;
BtnFind: TButtonExCtl;
Label3: TLabel;
beginDate: TMaskEdit;
GroupBox2: TGroupBox;
Grid1: TEasyGrid;
ButtonExCtl1: TButtonExCtl;
procedure BtnExitClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure BtnFindClick(Sender: TObject);
procedure BtnSaveClick(Sender: TObject);
procedure ButtonExCtl1Click(Sender: TObject);
procedure _beginDateCloseUp(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
_AdoNewProduce:TuAdoSet;
_Check:TCheckValidate;
_str:TuString;
public
{ Public declarations }
end;
var
Form_WasteBill: TForm_WasteBill;
implementation
uses U_Form_MainMenu,uGlobal,U_Form_wasteBillFind;
{$R *.dfm}
procedure TForm_WasteBill.BtnExitClick(Sender: TObject);
begin
EnableWindow(Form_MainMenu.Handle,true);
Close;
end;
procedure TForm_WasteBill.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
EnableWindow(Form_MainMenu.Handle,true);
CanClose:=true;
end;
procedure TForm_WasteBill.FormCreate(Sender: TObject);
begin
_AdoNewProduce:=TuAdoSet.Create('newProduce',1);
_Check:=TCheckValidate.create;
_str:=TuString.Create;
with _AdoNewProduce do
begin
setGridTitle(grid1,1,'序号',60);
setGridTitle(grid1,2,'产品名称',140);
setGridTitle(grid1,3,'规格',80);
setGridTitle(grid1,4,'单位',80);
setGridTitle(grid1,5,'装卸损',90);
setGridTitle(grid1,6,'空瓶/半瓶/自爆',130);
setGridTitle(grid1,7,'其他',100);
setGridTitle(grid1,8,'酒库名称',80);
end;
beginDate.Text:=formatDateTime('yyyy-mm-dd',now);
//_beginDate.Date:=strTodate(formatDateTime('yyyy-mm-dd',now));
end;
procedure TForm_WasteBill.BtnFindClick(Sender: TObject);
var
param:TStringList;
strsql:string;
i:integer;
begin
param:=TStringList.Create;
param.clear;
{/*
开始检索数据
*/}
param.Add(_whichStore);
strSql:='select OrderID,ProduceName,specification,UnitName from sale_Storage Where whichStore=:s1 order by OrderID';
_AdoNewproduce.BindToGrid_JK(grid1,strsql,param,1,4,1);
grid1.Refresh;
end;
procedure TForm_WasteBill.BtnSaveClick(Sender: TObject);
var
param:TStringList;
strsql:string;
i,j:integer;
begin
param:=TStringList.Create;
param.clear;
{/*
2008.04.09
入库之前先检查是否进行接班任务
*/}
param.clear;
param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
param.add('1');
param.Add(trim(_whichStore));
strsql:='select * from sale_followStore_Flag where SF_CheckDate=:s1 and SF_Flag=:s2 and SF_whichStore=:s3';
if _AdoNewProduce.getRecordCount(strsql,param)<=0 then
begin
showmessage('请首先进行接班库存盘点工作,然后在进行其他操作...');
exit;
end;
{/*
查询当天的损耗记录是否存在
*/}
param.Clear;
param.Add(trim(beginDate.text));
param.Add(trim(_whichStore));
strSql:='select * from sale_wasteBill where SW_CheckDate=:s1 and SW_whichStore=:s2';
if _AdoNewProduce.getRecordCount(strSql,param)>0 then
begin
if Application.MessageBox(Pchar('当天的损耗记录已经存在,是否覆盖存盘?'),'系统提示!',MB_YESNO+MB_IconWarning)=id_yes then
begin
{/*
覆盖存盘操作
*/}
param.clear;
param.Add(trim(beginDate.text));
param.Add(trim(_whichStore));
strsql:='delete from sale_wasteBill where SW_CheckDate=:s1 and SW_whichStore=:s2';
_AdoNewproduce.actionRecord(strsql,param);
{/*
存盘操作
*/}
for i:=2 to grid1.RowCount-3 do
begin
param.clear;
param.Add(trim(grid1.cells[1,i].foretext));
param.Add(trim(grid1.cells[2,i].foretext));
param.Add(trim(grid1.cells[3,i].foretext));
param.Add(trim(grid1.cells[4,i].foretext));
for j:=5 to grid1.ColCount-1 do
begin
if grid1.cells[j,i].ForeText<>'' then
begin
param.Add(trim(grid1.cells[j,i].foretext));
end
else
begin
param.Add('0');
end;
end;
param.Add(trim(_whichStore));
param.Add(trim(beginDate.text));
param.Add(trim(_StoreMan));
strsql:='insert into sale_wasteBill(SW_OrderID,SW_produceName,SW_specification,SW_UnitName,';
strsql:=strsql+'SW_bottleNum1,SW_bottleNum2,SW_bottleNum3,SW_bottleNum4,SW_bottleNum5,SW_bottleNum6,';
strsql:=strsql+'SW_bottleNum7,SW_bottleNum8,SW_bottleNum9,SW_bottleNum10,SW_bottleNum11,SW_bottleNum12,';
strsql:=strsql+'SW_WhichStore,SW_CheckDate,SW_StoreMan) Values(:s1,';
strsql:=strsql+':s2,:s3,:s4,:s5,:s6,:s7,:s8,:s9,:s10,:s11,:s12,:s13,:s14,:s15,:s16,:s17,:s18,:s19)';
_AdoNewProduce.actionRecord(strsql,param);
end;//for i
_str.actionOK(aT_save);
end;//Application
end//if -Ado
else
begin
{/*
存盘操作
*/}
for i:=2 to grid1.RowCount-3 do
begin
param.clear;
param.Add(trim(grid1.cells[1,i].foretext));
param.Add(trim(grid1.cells[2,i].foretext));
param.Add(trim(grid1.cells[3,i].foretext));
param.Add(trim(grid1.cells[4,i].foretext));
for j:=5 to grid1.ColCount-1 do
begin
if grid1.cells[j,i].ForeText<>'' then
begin
param.Add(trim(grid1.cells[j,i].foretext));
end
else
begin
param.Add('0');
end;
end;
param.Add(trim(_whichStore));
param.Add(trim(beginDate.text));
param.Add(trim(_StoreMan));
strsql:='insert into sale_wasteBill(SW_OrderID,SW_produceName,SW_specification,SW_UnitName,';
strsql:=strsql+'SW_bottleNum1,SW_bottleNum2,SW_bottleNum3,SW_bottleNum4,SW_bottleNum5,SW_bottleNum6,';
strsql:=strsql+'SW_bottleNum7,SW_bottleNum8,SW_bottleNum9,SW_bottleNum10,SW_bottleNum11,SW_bottleNum12,';
strsql:=strsql+'SW_WhichStore,SW_CheckDate,SW_StoreMan) Values(:s1,';
strsql:=strsql+':s2,:s3,:s4,:s5,:s6,:s7,:s8,:s9,:s10,:s11,:s12,:s13,:s14,:s15,:s16,:s17,:s18,:s19)';
_AdoNewProduce.actionRecord(strsql,param);
end;//for i
_str.actionOK(aT_save);
end;
end;
procedure TForm_WasteBill.ButtonExCtl1Click(Sender: TObject);
var
param:TStringList;
strsql:string;
i,j:integer;
begin
{if Form_wasteBillFind=nil then
begin
EnableWindow(Form_WasteBill.Handle,false);
Form_wasteBillFind:=TForm_wasteBillFind.Create(Application);
Form_wasteBillFind.Show;
end
else
begin
EnableWindow(Form_WasteBill.Handle,false);
Form_wasteBillFind.Show;
end;
}
{/*
查询当天的损耗,如果不存在提示不存在
否则,如果存在调出损耗记录
*/}
param:=TStringList.Create;
param.clear;
param.Add(trim(beginDate.text));
param.Add(trim(_whichStore));
strSql:='select SW_orderID,SW_ProduceName,SW_specification,SW_unitName,SW_bottleNum1,';
strsql:=strsql+'SW_bottleNum2,SW_bottleNum3,SW_bottleNum4,SW_bottleNum5,SW_bottleNum6,';
strsql:=strsql+'SW_bottleNum7,SW_bottleNum8,SW_bottleNum9,SW_bottleNum10,SW_bottleNum11,';
strsql:=strsql+'SW_bottleNum12 from sale_wasteBill where SW_checkdate=:s1 and SW_whichStore=:s2';
if _AdoNewproduce.getRecordCount(strSql,param)<=0 then
begin
for i:=2 to grid1.RowCount-1 do
begin
for j:=5 to grid1.ColCount-1 do
begin
grid1.cells[j,i].ForeText:='';
end;
end;
grid1.Refresh;
showmessage('当天的损耗的记录不存在...');
exit;
end
else
begin
for i:=2 to grid1.RowCount-1 do
begin
for j:=5 to grid1.ColCount-1 do
begin
grid1.cells[j,i].ForeText:='';
end;
end;
grid1.Refresh;
param.clear;
param.Add(trim(beginDate.text));
param.Add(trim(_whichStore));
strSql:='select SW_orderID,SW_ProduceName,SW_specification,SW_unitName,SW_bottleNum1,';
strsql:=strsql+'SW_bottleNum2,SW_bottleNum3,SW_bottleNum4,SW_bottleNum5,SW_bottleNum6,';
strsql:=strsql+'SW_bottleNum7,SW_bottleNum8,SW_bottleNum9,SW_bottleNum10,SW_bottleNum11,';
strsql:=strsql+'SW_bottleNum12 from sale_wasteBill where SW_checkdate=:s1 and SW_whichStore=:s2';
_AdoNewProduce.BindToGrid_JK(grid1,strsql,param,1,grid1.ColCount-1,1);
grid1.Refresh;
end;
end;
procedure TForm_WasteBill._beginDateCloseUp(Sender: TObject);
begin
//beginDate.Text:=formatDateTime('yyyy-mm-dd',_beginDate.Date);
end;
procedure TForm_WasteBill.FormShow(Sender: TObject);
var
param:TStringList;
strSql:string;
i:integer;
_RSCount:integer;
WBI_ItemName:TStringList;
begin
param:=TStringList.Create;
WbI_ItemName:=TStringList.Create;
{/*
计算损耗PG_WasteBillItem表中损耗项目的个数
*/}
param.clear;
strSql:='select * from PG_WasteBillItem ';
_RSCount:=_AdoNewproduce.getRecordCount(strsql,param);
grid1.ColCount:=_RSCount+5;
grid1.Refresh;
{/*
显示损耗的标题
*/}
param.clear;
strSql:='select WBI_ItemName from PG_WasteBillItem order By WBI_OrderID';
WBI_ItemName:=_AdoNewproduce.getFieldList(strSql,param,'WBI_ItemName');
for i:=5 to grid1.colcount-1 do
begin
grid1.cells[i,1].foretext:=WBI_ItemName[i-5];
grid1.ColWidths[i]:=60;
grid1.Cells[i,1].Color:=rgb(0,146,247);
grid1.Cells[i,1].FontColor:=rgb(255,255,255);
end;
param.clear;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -