📄 u_form_accidentbill.~pas
字号:
end ////存在则
else
begin
{/*
为了计算编号,首先得到一线酒库的记录数
*/}
param.clear;
param.Add(_whichStore);
strSql:='select * from sale_storage Where whichStore=:s3';
_OrderID:=_AdoNewproduce.getRecordCount(strsql,param)+1;
{/*
添加品种数量
*/}
param.clear;
param.Add(inttostr(_OrderID)); /////1.序号
param.Add(combobox1.text); /////2.产品名称
param.Add(trim(combobox3.text)); /////3.包装//////
param.Add(trim(combobox2.text)); /////4.规格//////////
param.Add(trim(edit2.text)); /////5.整箱数量
param.Add(trim(edit3.text)); /////6.整瓶数量
//param.Add('0'); /////7.整瓶数量
param.Add(_whichStore); /////8.酒库
strsql:='insert into sale_Storage(OrderID,produceName,UnitName,specification,';
strsql:=strsql+'boxNum,bottleNum,WhichStore) Values(:s1,';
strsql:=strsql+':s2,:s3,:s4,:s5,:s6,:s7)';
_AdoNewProduce.actionRecord(strsql,param);
end; ////不存在则,添加品种
end;///_str.save
/////清空数据/////////////////////////////////
combobox1.Text:='';
combobox2.Text:='';
combobox3.Text:='';
edit1.Text:='';
edit2.Text:='0';
edit3.Text:='0';
edit4.Text:='';
{/*
在表格中显示数据//////////////////////
*/}
param.Clear;
param.Add('0');
param.Add(trim(_whichStore));
param.Add(trim(outDate.text));
strSql:='select sampleBillCode,sampleBillDate,TraderName,productName,specification,UnitName,productNum,bottleNum,OutStoreTime,';
strSql:=strSql+'WhichStore,worker from sale_newsample_Accident where isCancel=:s1 and whichStore=:s2 and OutStoreTime=:s3';
_AdoNewproduce.BindToGrid(grid1,strSql,param);
{/*
自动计算编号
param.Clear;
param.Add('SG');
param.Add(_whichStore);
param.add(trim(outDate.text));
strSql:='select * from sale_newSample where substring(sampleBillCode,1,2)=:s1 ';
strsql:=strsql+' and whichStore=:s2 and OutStoreTime=: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:='SG'+trim(FormatdateTime('yyyymmdd',now))+trim(_BillCode);
*/}
end;
procedure TForm_AccidentBill.Grid1DblClick(Sender: TObject);
var
param:TStringList;
_dataInfo:Array of TStringList;
strsql:string;
_Billcode:string;
begin
param:=TStringList.Create;
param.clear;
setLength(_dataInfo,1);
_DataInfo[0]:=TStringList.Create;
_DataInfo[0].Clear;
{/*
首先得到记录信息
*/}
_billcode:=trim(grid1.cells[1,grid1.row].foretext);
param.Clear;
param.Add(trim(_billcode));
strsql:='select * from sale_newSample_Accident where sampleBillcode=:s1';
_AdoNewProduce.getRecordList(strsql,param,_dataInfo);
{/*
给控件付值
*/}
edit1.Text:=trim(_dataInfo[0][0]);
F_Billcode:=trim(_dataInfo[0][0]);
Makedate.Text:=trim(_dataInfo[0][1]);
edit4.Text:=trim(_dataInfo[0][2]);
combobox1.Text:=trim(_dataInfo[0][3]);
combobox2.Text:=trim(_dataInfo[0][4]);
combobox3.Text:=trim(_dataInfo[0][5]);
F_productName:=trim(_dataInfo[0][3]);
F_Specification:=trim(_dataInfo[0][4]);
F_UnitName:=trim(_dataInfo[0][5]);
edit2.Text:=trim(_dataInfo[0][6]);
edit3.Text:=trim(_dataInfo[0][7]);
F_BoxNum:=strToInt(_dataInfo[0][6]);
F_BottleNum:=strToInt(_dataInfo[0][7]);
combobox5.Text:=trim(_dataInfo[0][8]);
outdate.Text:=trim(_dataInfo[0][9]);
combobox6.Text:=trim(_dataInfo[0][11]);
edit6.Text:=trim(_dataInfo[0][12]);
combobox7.Text:=trim(_dataInfo[0][13]);
edit5.Text:=trim(_dataInfo[0][14]);
combobox8.Text:=trim(_dataInfo[0][15]);
end;
procedure TForm_AccidentBill.BtnEditClick(Sender: TObject);
var
param:TStringList;
strsql:string;
_NewProductNum:integer;
_NewBottleNum:integer;
_StoreNum:integer;
_bottleNum:integer;
_BillCode:string;
_rsCount:integer;
begin
param:=TStringList.Create;
param.clear;
{/*
验证需要修改的必要性
*/}
if not _Check.Do_Control(edit1,1,'编号为空,不能修改...') then exit;
if not _Check.Do_Control(combobox1,1,'产品为空,不能修改...') then exit;
if not _Check.Do_Control(edit2,1,'箱数为空,不能修改...') then exit;
if not _Check.Do_Control(edit3,1,'瓶数为空,不能修改...') then exit;
if not _Check.Do_Control(edit4,1,'单位名称为空,不能修改...') then exit;
{/*
得到新的数量
*/}
if edit2.text<>'' then
begin
_NewproductNum:=strToInt(edit2.text)-F_BoxNum;
end;
if edit3.text<>'' then
begin
_NewBottleNum:=strToInt(edit3.text)-F_bottleNum;
end;
{/*
确定是否存盘......
*/}
if _str.updateMessage then
begin
param.clear;
param.Add(trim(Makedate.text)); ///1.
param.Add(trim(edit4.text)); ///2.
param.Add(trim(combobox1.text)); ///3.
param.Add(trim(combobox2.text)); ///4.
param.Add(trim(combobox3.text)); ///5..
param.Add(trim(edit2.text)); ///6.
param.Add(trim(edit3.text)); ///7.
param.Add(trim(combobox5.text)); ///8
param.Add(trim(outDate.text)); ///9.
param.Add(trim(combobox6.text)); ///10.
param.Add(trim(edit6.text)); ////11.
param.Add(trim(combobox7.text)); ////12.
param.Add(trim(edit5.text)); ////13.
param.Add(trim(combobox8.text)); ////14.
param.Add(trim(F_Billcode)); ////15.
strsql:='update sale_NewSample_Accident set sampleBillDate=:s1,TraderName=:s2,productName=:s3,';
strsql:=strsql+'specification=:s4,UnitName=:s5,productNum=:s6,bottleNum=:s7,worker=:s8,outStoreTime=:s9,';
strsql:=strsql+'dutyDept=:s10,AccidentReason=:s11,ZhuGuanRen=:s12,JingBanRen=:s13,TihuoRen=:s14 where sampleBillCode=:s15';
_AdoNewProduce.actionRecord(strsql,param);
end;//fi
{/*
更改库存
*/}
{/*
首先得到原来库存的数量,然后存储到_StoreNum变量中
*/}
param.clear; ////清除查询条件
param.Add(_whichStore); ////1.添加酒库名称/////////
param.Add(trim(F_Productname)); ////2.产品名称
param.Add(trim(F_Specification)); ////3.规格//////
param.Add(trim(F_UnitName)); ////4.包装//////////
strSql:='select * from sale_Storage Where whichStore=:s1 and ';
strsql:=strsql+' produceName=:s2 and Specification=:s3 and UnitName=:s4 ';
_StoreNum:=_AdoNewProduce.getFieldValue(strsql,param,'boxNum');
_bottleNum:=_AdoNewProduce.getFieldValue(strsql,param,'bottleNum');
//showmessage(inttostr(_storeNum));
{/*
修改库存中的数量
*/}
param.clear;
param.Add(inttostr(_StoreNum-_NewProductNum)); ////1.修改整箱数量
param.Add(inttostr(_bottleNum-_NewBottleNum)); ////2.修改整瓶数量
param.Add(_whichStore); ////4.添加酒库名称/////////
param.Add(trim(F_Productname)); ////5.产品名称
param.Add(trim(F_Specification)); ////6.规格//////
param.Add(trim(F_UnitName)); ////7.包装//////////
strSql:='update sale_Storage set boxNum=:s1,bottleNum=:s2 Where WhichStore=:s4 ';
strsql:=strsql+' and produceName=:s5 and Specification=:s6 and UnitName=:s7';
_AdoNewProduce.actionRecord(strSql,param);
{/*
初始化控件内容
*/}
combobox1.Text:='';
combobox2.Text:='';
combobox3.Text:='';
//combobox4.Text:='';
edit2.Text:='0';
edit3.Text:='0';
edit4.Text:='';
combobox6.Text:='';
combobox7.Text:='';
combobox8.Text:='';
edit6.Text:='';
edit5.Text:='';
{/*
在表格中显示数据//////////////////////
*/}
param.Clear;
param.Add('0');
param.Add(trim(_whichStore));
param.Add(trim(outDate.text));
strSql:='select sampleBillCode,sampleBillDate,TraderName,productName,specification,UnitName,productNum,bottleNum,OutStoreTime,';
strSql:=strSql+'WhichStore,worker from sale_newsample_Accident where isCancel=:s1 and whichStore=:s2 and OutStoreTime=:s3';
_AdoNewproduce.BindToGrid(grid1,strSql,param);
grid1.Refresh;
_str.actionOK(at_update);
end;
procedure TForm_AccidentBill.BtnDelClick(Sender: TObject);
var
param:TStringList;
strsql:string;
_StoreNum:integer;
_bottleNum:integer;
_BillCode:string;
_rsCount:integer;
begin
param:=TStringList.Create;
param.clear;
{/*
验证输入数据的
*/}
if not _Check.Do_Control(edit1,1,'编号不能为空...') then exit;
{/*
验证输入此编号的记录是否存在
*/}
param.clear;
param.Add(trim(edit1.Text));
param.Add(trim(_whichStore));
strSql:='select * from sale_Newsample_Accident Where sampleBillCode=:s1 and whichStore=:s2';
if _AdoNewproduce.getRecordCount(strsql,param)<=0 then
begin
showmessage('记录不存在,无法删除...');
exit;
end;
{/*
执行删除操作
*/}
if _str.deleteMessage then
begin
param.Clear;
param.Add(trim(F_Billcode));
param.Add(trim(_whichStore));
strsql:='delete from sale_newSample_Accident where sampleBillcode=:s2 and whichStore=:s2';
_AdoNewProduce.actionRecord(strsql,param);
end;//if
{/*
首先得到原来库存的数量,然后存储到_StoreNum变量中
*/}
param.clear; ////清除查询条件
param.Add(_whichStore); ////1.添加酒库名称/////////
param.Add(trim(F_Productname)); ////2.产品名称
param.Add(trim(F_Specification)); ////3.规格//////
param.Add(trim(F_UnitName)); ////4.包装//////////
strSql:='select * from sale_Storage Where WhichStore=:s1 and ';
strsql:=strsql+' produceName=:s2 and Specification=:s3 and UnitName=:s4 ';
_StoreNum:=_AdoNewProduce.getFieldValue(strsql,param,'boxNum');
_bottleNum:=_AdoNewProduce.getFieldValue(strsql,param,'bottleNum');
//showmessage(inttostr(_storeNum));
{/*
修改库存中的数量
*/}
param.clear;
param.Add(inttostr(_StoreNum-strToInt(edit2.text))); ////1.修改整箱数量
param.Add(inttostr(_bottleNum-strToInt(edit3.text))); ////2.修改整瓶数量
param.Add(_whichStore); ////4.添加酒库名称/////////
param.Add(trim(F_Productname)); ////5.产品名称
param.Add(trim(F_Specification)); ////6.规格//////
param.Add(trim(F_UnitName)); ////7.包装//////////
strSql:='update sale_Storage set boxNum=:s1,bottleNum=:s2 Where WhichStore=:s4 ';
strsql:=strsql+' and produceName=:s5 and Specification=:s6 and UnitName=:s7';
_AdoNewProduce.actionRecord(strSql,param);
{/*
初始化控件内容
*/}
combobox1.Text:='';
combobox2.Text:='';
combobox3.Text:='';
combobox4.Text:='';
edit2.Text:='0';
edit3.Text:='0';
edit4.Text:='';
combobox6.Text:='';
combobox7.Text:='';
combobox8.Text:='';
edit6.Text:='';
edit5.Text:='';
{/*
在表格中显示数据//////////////////////
*/}
param.Clear;
param.Add('0');
param.Add(trim(_whichStore));
strSql:='select sampleBillCode,sampleBillDate,TraderName,productName,specification,UnitName,productNum,bottleNum,OutStoreTime,';
strSql:=strSql+'WhichStore,worker from sale_newsample_Accident where isCancel=:s1 and whichStore=:s2';
_AdoNewproduce.BindToGrid(grid1,strSql,param);
grid1.Refresh;
_str.actionOK(at_delete);
end;
procedure TForm_AccidentBill.ButtonExCtl1Click(Sender: TObject);
begin
if Form_AccidentBillFind=nil then
begin
EnableWindow(Form_AccidentBill.Handle,false);
Form_AccidentBillFind:=TForm_AccidentBillFind.Create(Application);
Form_AccidentBillFind.Show;
end
else
begin
EnableWindow(Form_AccidentBill.Handle,false);
Form_AccidentBillFind.Show;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -