📄 u_form_producestock.~pas
字号:
unit U_Form_ProduceStock;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, EasyGrid, StdCtrls, Mask, ButtonExCtl,uAdoSet,uCheckValidate,uString;
type
TForm_ProduceStock = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label9: TLabel;
Label1: TLabel;
Label2: TLabel;
MakeDate: TMaskEdit;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Edit2: TEdit;
ComboBox4: TComboBox;
Grid1: TEasyGrid;
OpenDate: TDateTimePicker;
OpenDate1: TDateTimePicker;
Edit1: TEdit;
BtnSave: TButtonExCtl;
BtnExit: TButtonExCtl;
BtnEdit: TButtonExCtl;
BtnDel: TButtonExCtl;
Label8: TLabel;
Edit3: TEdit;
Label10: TLabel;
ComboBox5: TComboBox;
Label11: TLabel;
Edit4: TEdit;
ButtonExCtl1: TButtonExCtl;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure BtnExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OpenDateCloseUp(Sender: TObject);
procedure BtnSaveClick(Sender: TObject);
procedure Grid1DblClick(Sender: TObject);
procedure BtnEditClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BtnDelClick(Sender: TObject);
procedure ButtonExCtl1Click(Sender: TObject);
private
{ Private declarations }
_Adosale:TuAdoSet;
_AdoNewproduce:TuAdoSet;
_Check:TCheckValidate;
_str:TuString;
public
{ Public declarations }
end;
var
Form_ProduceStock: TForm_ProduceStock;
F_BillCode:string;
F_BoxNum:integer;
F_EmptyBoxNum:integer;
F_BottleNum:integer;
F_ProductName:string;
F_Specification:string;
F_UnitName:string;
implementation
uses U_Form_MainMenu,uGlobal,U_Form_ProductStockFind,U_Form_ProduceStock_DX;
{$R *.dfm}
procedure TForm_ProduceStock.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
EnableWindow(Form_MainMenu.Handle,true);
CanClose:=true;
end;
procedure TForm_ProduceStock.BtnExitClick(Sender: TObject);
begin
EnableWindow(Form_MainMenu.Handle,true);
Close;
end;
procedure TForm_ProduceStock.FormCreate(Sender: TObject);
var
param:TStringList;
strsql:string;
_RsCount:integer;
i:integer;
_BillCode:string;
begin
_Adosale:=TuAdoSet.Create('newsale',1);
_AdoNewproduce:=TuAdoSet.Create('newproduce',1);
_Check:=TCheckValidate.create;
_str:=TuString.Create;
///////添加规格/////////////////////////////
combobox2.Items.Add('24');
combobox2.Items.Add('15');
combobox2.Items.Add('12');
combobox2.Items.Add('10');
combobox2.Items.Add('8');
combobox2.Items.Add('6');
combobox2.Items.Add('9');
///////添加包装//////////////
combobox3.Items.Add('塑箱');
combobox3.Items.Add('塑包');
combobox3.Items.Add('纸箱');
combobox3.Items.Add('千升');
combobox3.Items.Add('桶');
combobox4.Items.Clear;
combobox4.Items.Add('一线酒库');
MakeDate.Text:=formatDateTime('yyyy-mm-dd-',now);
OpenDate.Date:=strTodate(formatDateTime('yyyy-mm-dd',now));
param:=TStringList.Create;
param.clear;
strsql:='select wareTypeName from saleArea_tmp order By orderCode';
_Adosale.FillControl(combobox1,strsql,param,'wareTypeName');
{/*
设置表格标题
*/}
grid1.Cells[1,1].ForeText:='编号';
grid1.ColWidths[1]:=130;
grid1.Cells[2,1].ForeText:='入库日期';
grid1.ColWidths[2]:=130;
grid1.Cells[3,1].ForeText:='入库时间';
grid1.ColWidths[3]:=130;
grid1.Cells[4,1].ForeText:='产品名称';
grid1.ColWidths[4]:=90;
grid1.Cells[5,1].ForeText:='规格';
grid1.ColWidths[5]:=70;
grid1.Cells[6,1].ForeText:='包装';
grid1.ColWidths[6]:=60;
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]:=70;
grid1.Cells[10,1].ForeText:='酒库名称';
grid1.ColWidths[10]:=90;
grid1.Cells[11,1].ForeText:='保管员';
grid1.ColWidths[11]:=70;
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;///
{/*
在表格中显示数据//////////////////////
*/}
param.Clear;
param.Add(trim(makeDate.text));
param.Add(_whichStore);
strSql:='select SI_IntoBillCode,SI_IntoDate,SI_intoTime,SI_productName,SI_specification,SI_UnitName,SI_productNum,SI_EmptyBoxNum,';
strSql:=strSql+'SI_bottleNum,SI_WhichStore,SI_StoreMan from sale_IntoStore where SI_intoDate=:s1 and SI_whichStore=:s2 order by SI_IntoBillCode';
_AdoNewproduce.BindToGrid(grid1,strSql,param);
{/*
自动计算编号
*/}
param.Clear;
param.Add('RK');
param.Add(trim(_whichStore));
param.Add(trim(makeDate.text));
strSql:='select * from sale_IntoStore where substring(SI_intoBillCode,1,2)=:s1 ';
strsql:=strsql+' and SI_whichStore=:s2 and SI_intodate=:s3';
_RsCount:=_AdoNewProduce.getRecordCount(strSql,param);
if (_RsCount>=0) and (_RsCount<9) then
begin
_BillCode:='00'+intToStr(_RsCount+1)
end;
if (_RsCount>=9) and (_RsCount<99) then
begin
_BillCode:='0'+intToStr(_RsCount+1)
end;
if (_RsCount>=99) and (_RsCount<999) then
begin
_BillCode:=intToStr(_RsCount+1)
end;
edit1.Text:='RK'+trim(FormatdateTime('yyyymmdd',now))+'_'+trim(_whichStore)+trim(_BillCode);
if trim(_whichStore)='B' then
begin
combobox4.Text:='一线酒库';
end;
if trim(_whichStore)='C' then
begin
combobox4.Text:='二线酒库';
end;
if trim(_whichStore)='D' then
begin
combobox4.Text:='三线酒库';
end;
if trim(_whichStore)='A' then
begin
combobox4.Text:='高档酒库';
end;
edit2.text:='0';
edit3.Text:='0';
edit4.Text:='0';
{/*
添加保管员
*/}
param.clear;
param.Add(_whichstore);
strsql:='select realName from userTable where whichStore=:s1';
_AdoNewproduce.FillControl(combobox5,strsql,param,'realName');
combobox5.Text:=trim(_StoreMan);
end;
procedure TForm_ProduceStock.OpenDateCloseUp(Sender: TObject);
begin
makedate.Text:=formatDateTime('yyyy-mm-dd',OpenDate.Date);
end;
procedure TForm_ProduceStock.BtnSaveClick(Sender: TObject);
var
param:TStringList;
strsql:string;
_StoreNum:integer;
_bottleNum:integer;
_EmptyBoxNum:integer;
_OrderID:integer;
_OrderID1:integer;
_BillCode:string;
_rsCount:integer;
_CheckDate:string;
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;
{/*
输入数据的有效性验证
*/}
if not _Check.Do_Control(edit1,1,'编号不能为空...') then exit;
if not _Check.Do_Control(combobox1,1,'请选择入库啤酒品种...') then exit;
if not _Check.Do_Control(combobox2,1,'请选择入库啤酒规格...') then exit;
if not _Check.Do_Control(combobox3,1,'请选择入库啤酒包装...') then exit;
if not _Check.Do_Control(edit2,1,'请输整箱数量,如果没有输入0...') then exit;
if not _Check.Do_Control(edit3,1,'请输整瓶数量,如果没有输入0...') then exit;
{/*
验证输入此编号的记录是否存在
*/}
param.clear;
param.Add(trim(edit1.Text));
param.Add(_whichStore);
strSql:='select * from sale_IntoStore Where SI_intoBillCode=:s1 and SI_whichStore=:s2';
if _AdoNewproduce.getRecordCount(strsql,param)>0 then
begin
showmessage('记录已经存在...');
exit;
end;
{/*
将输入的数据存储到入库表中(newproduce-->sale_intoStore)
*/}
if _str.saveMessage then
begin
param.Clear;
param.Add(trim(edit1.Text)); /////1.编号
param.Add(trim(MakeDate.Text)); /////2.入库日期
param.Add(formatDateTime('hh:mm:ss',opendate1.Date)); /////3.入库时间
param.Add(trim(combobox1.Text)); /////4.产品名称
param.Add(trim(combobox2.Text)); /////5.规格
param.Add(trim(combobox3.Text)); /////6.包装
param.Add(trim(edit2.Text)); /////7.成套数量
param.Add(trim(edit3.Text)); /////8.空箱数量
param.Add(trim(edit4.Text)); /////9.瓶数量
param.Add(_whichStore); /////10.酒库名称 B:代表一线 C:二线 D:三线
param.Add(_storeMan); /////11.保管员
strSql:='insert into sale_IntoStore(SI_IntoBillCode,SI_IntoDate,SI_IntoTime,SI_productName,SI_specification,SI_unitName,';
strSql:=strSql+'SI_productNum,SI_EmptyBoxNum,SI_bottleNum,SI_whichStore,SI_StoreMan) Values(:s1,:s2,:s3,:s4,:s5,:s6,:s7,:s8,:s9,:s10,:s11)';
_AdoNewproduce.actionRecord(strsql,param);
{/*
更改库存表(newproduce-->sale_Storage)中的库存的数量productNum,boxNum,emptyBoxNum,bottleNum
1.首先到库存表中查找当前符合条件的记录是否存在,如果存在则修改,否则添加
*/}
param.Clear;
param.Add(_whichStore); /////1.添加酒库名称/////////
param.Add(combobox1.text); /////2.产品名称
param.Add(trim(combobox3.text)); /////3.包装//////
param.Add(trim(combobox2.text));
strSql:='select * from sale_Storage Where WhichStore=:s1 and ';
strsql:=strsql+' produceName=:s2 and UnitName=:s3 and Specification=:s4';
if _AdoNewproduce.getRecordCount(strsql,param)>0 then
begin
{/*
品种存在,首先得到原来库存的数量,然后存储到_StoreNum变量中
*/}
param.clear; ////清除查询条件
param.Add(_whichStore); ////1.添加酒库名称/////////
param.Add(combobox1.text); ////2.产品名称
param.Add(trim(combobox3.text)); ////3.规格//////
param.Add(trim(combobox2.text)); ////4.包装//////////
strSql:='select * from sale_Storage Where WhichStore=:s1 and ';
strsql:=strsql+' produceName=:s2 and UnitName=:s3 and Specification=:s4';
_StoreNum:=_AdoNewProduce.getFieldValue(strsql,param,'boxNum'); /////得到成套数量
_bottleNum:=_AdoNewProduce.getFieldValue(strsql,param,'bottleNum'); /////得到瓶数量
_EmptyBoxNum:=_AdoNewProduce.getFieldValue(strsql,param,'EmptyBoxNum'); /////得到空箱数量
//showmessage(inttostr(_storeNum));
{/*
修改sale_storage库存中的数量
*/}
param.clear;
param.Add(inttostr(_StoreNum+strtoint(edit2.text))); ////1.修改整箱数量
param.Add(inttostr(_bottleNum+strtoint(edit4.text))); ////2.修改整瓶数量
param.Add(inttostr(_EmptyBoxNum+strtoint(edit3.text))); ////3.修改整瓶数量
param.Add(_whichStore); ////4.添加酒库名称/////////
param.Add(combobox1.text); ////5.产品名称
param.Add(trim(combobox3.text)); ////6.规格//////
param.Add(trim(combobox2.text)); ////7.包装//////////
strSql:='update sale_Storage set boxNum=:s1,bottleNum=:s2,EmptyBoxNum=:s3 Where WhichStore=:s4 ';
strsql:=strsql+' and produceName=:s5 and UnitName=:s6 and Specification=:s7';
_AdoNewProduce.actionRecord(strSql,param);
end ////以上品种存在则,以下是品种不存在则添加
else
begin
{/*
为了计算编号,首先得到一线酒库的记录数
*/}
param.clear;
param.Add(_whichStore);
strSql:='select * from sale_storage Where whichStore=:s1';
_OrderID1:=_AdoNewproduce.getRecordCount(strsql,param)+1;
{/*
添加品种数量
*/}
param.clear;
param.Add(inttostr(_OrderID1)); /////1.
param.Add(combobox1.text); /////2.产品名称
param.Add(trim(combobox2.text)); /////3.规格//////
param.Add(trim(combobox3.text)); /////4.包装//////////
param.Add(trim(edit2.text)); /////5.成套数量
param.Add(trim(edit3.text)); /////6.空箱数量
param.Add(trim(edit4.text)); /////7.瓶数量
param.Add(_whichStore); /////8.酒库名称
//param.Add(trim(makeDate.text)); /////9.日期
strsql:='insert into sale_storage(OrderID,produceName,specification,UnitName,';
strsql:=strsql+'boxNum,EmptyBoxNum,bottleNum,WhichStore) Values(:s1,';
strsql:=strsql+':s2,:s3,:s4,:s5,:s6,:s7,:s8)';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -