📄 u_form_changebill.~pas
字号:
grid1.Refresh;
end;
procedure TForm_ChangeBill.RBBtn_1Click(Sender: TObject);
var
i,j:integer;
begin
if RBBtn_1.Checked then
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;///for i
beginDate.Enabled:=false;
//beginDate.Text:=_str.formatDate(2);
_beginDate.Enabled:=false;
//_beginDate.Date:=strToDate(_str.formatDate(2));
endDate.Enabled:=false;
//endDate.Text:=_str.formatDate(2);
_endDate.Enabled:=false;
//_endDate.Date:=strToDate(_str.formatDate(2));
end;
end;
procedure TForm_ChangeBill.RBBtn_2Click(Sender: TObject);
var
i,j:integer;
begin
if RBBtn_2.Checked then
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;///for i
beginDate.Enabled:=true;
//beginDate.Text:=_str.formatDate(2);
_beginDate.Enabled:=true;
//_beginDate.Date:=strToDate(_str.formatDate(2));
endDate.Enabled:=true;
//endDate.Text:=_str.formatDate(2);
_endDate.Enabled:=true;
//_endDate.Date:=strToDate(_str.formatDate(2));
end;
end;
procedure TForm_ChangeBill.Grid1DblClick(Sender: TObject);
var
param:TStringList;
param1:TStringList;
strSql:string;
i:integer;
DataInfo:Array of TStringList; ////存储销售整条记录数据信息
DataInfo_PG:Array of TStringList; ////存储包装传票整条记录数据信息
DataInfo_YJ:Array of TStringList; ////存储包装押金票整条记录数据信息
_StoreNum:integer; ////存储库存中原来整箱数量
_bottleNum:integer; ////存储库存中原来整瓶数量
_emptyBoxNum:integer;
_StoreRecordCount:integer; ////存储库存中当前品种的记录数,用来判断记录是否存在
_OrderID:integer; /////存储序号
begin
{/*
建立列表对象的实例
*/}
param:=TStringList.Create;
param1:=TStringList.Create;
{/*
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;
{/*
进行调票操作
tmp_tanlename=1 则对销售票据进行调票
tmp_tablename=2 则对包装票据进行调票
*/}
if tmp_tablename=1 then
begin
{/*
到销售开票表中(newsale)查询票据是否存在
*/}
param.clear;
param.Add(trim(grid1.cells[1,grid1.row].foretext));
strSql:='select * from saleBill Where ';
strSql:=strSql+'saleBillCode=:_saleCode and iscancel=0 and isChange=0';
if _Adosale.getRecordCount(strsql,param)<=0 then
begin
showmessage('此编号票据不是在销售开的票据,可能存在问题?');
exit;
end;
{/*
到调酒票表(newprocedure--->sale_ChangeBill)中检查是否已经调过
*/}
param.clear;
param.Add(trim(grid1.cells[1,grid1.row].foretext));
strSql:='Select * from sale_ChangeBill Where saleBillCode=:_saleCode';
if _AdoNewproduce.getRecordCount(strsql,param)>0 then
begin
showmessage('此编号票据已经调过,不能再调?');
exit;
end;
{/*
得到在(newsale-->salebill)中记录信息,然后存储在datainfo[0]中
*/}
//datainfo_PG[0]:=TStringList.Create;
param.Clear;
setLength(datainfo,1);
dataInfo[0]:=TStringList.Create;
DataInfo[0].clear;
param.Add(trim(grid1.cells[1,grid1.row].foretext));
strSql:='Select saleBillCode,saleBillDate,saleAreaName,TraderName,ProductName,Specification,UnitName,MakeName,saleNum,saleSum,DriverNumber From saleBill Where ';
strSql:=strSql+'saleBillCode=:_saleCode and iscancel=0 and isChange=0';
_Adosale.getRecordList(strsql,param,datainfo);
{/*
确定是否进行调票
*/}
if Application.MessageBox(pchar('确定是否调酒票?'),pchar('系统提示'),MB_YesNo+MB_IconWarning)=id_yes then
begin
{/*
将需要调票的记录存储到newproduce-->sale_ChangeBill中
*/}
param.Clear;
strSql:='insert into sale_ChangeBill(saleBillCode,saleBillDate,saleAreaName,TraderName,ProductName,Specification,UnitName,MakeName,';
strSql:=strsql+'saleNum,OutStoreDate,StoreMan,BillType,WhichStore,DriverNumber) Values(:s1,:s2,:s3,:s4,';
strsql:=strsql+':s5,:s6,:s7,:s8,:s9,:s10,:s11,:s12,:s13,:s14)';
////将数据加入到列表中作为Sql语句的参数///////////
//showmessage(datainfo[0][0]);
//showmessage(DataInfo[0][DataInfo[0].Count-1]);
for i:=0 to DataInfo[0].Count-3 do
begin
param.Add(DataInfo[0][i]);
//showmessage(param[i]);
end;////for
param.Add(trim(formatDateTime('yyyy-mm-dd hh:mm:ss',now))); ///1.日期
param.Add(_StoreMan); ///2.保管员/////////
param.Add('销售传票'); ///3.票据标志
param.Add(_whichStore);
param.Add(DataInfo[0][DataInfo[0].Count-1]);
///4.填写酒库名称B:一线酒库 C:二线酒库 D:三线酒库 A:高档酒库
_AdoNewproduce.actionRecord(strsql,param);
{/*
总体目标:更改库存表中(newproduce-->sale_storage)的品种的库存数量
2.首先得到原来的库存数量
1.到库存表中查找当前品种是否存在,如果存在则修改使库存数量减少
如果不存在,则添加品种和数量
*/}
{/*
1.首先判断当前品种酒是否存在,存在才能得到库存数量然后存储到_storeNum变量中
*/}
param.clear;
strSql:='select * from sale_Storage Where WhichStore=:s1 and ';
strsql:=strsql+' produceName=:s2 and UnitName=:s3 and Specification=:s4';
param.Add(_whichStore); ///1.酒库名称
param.Add(trim(copy(trim(DataInfo[0][4]),1,pos('∕',trim(DataInfo[0][4]))-1))); ///2.产品名称
param.Add(trim(datainfo[0][6])); ///3.单位
param.Add(trim(copy(trim(datainfo[0][5]),4,length(trim(datainfo[0][5]))-3))); ///4.规格
_StoreRecordCount:=_AdoNewproduce.getRecordCount(strsql,param); ///得到符合条件的记录数
///showmessage(inttostr(_storeRecordCount));
if _StoreRecordCount>0 then
begin
{/*
存在,则得到原来库存数量
*/}
param.clear;
param.Add(_whichStore); ///1.添加酒库名称B:一线酒库
param.Add(trim(copy(trim(DataInfo[0][4]),1,pos('∕',trim(DataInfo[0][4]))-1))); ///2.产品名称
param.Add(trim(datainfo[0][6])); ///3.单位
param.Add(trim(copy(trim(datainfo[0][5]),4,length(trim(datainfo[0][5]))-3))); ///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));
{/*
更改库存表中的数量字段名:boxNum 和 bottleNum
*/}
param.clear;
param.Add(inttostr(_StoreNum-strtoint(DataInfo[0][8]))); ///1.用原来的库存数-调票的数量
//param.Add(inttostr(_bottleNum-strtoint(DataInfo[0][8]))); ///**用原来的库存数-调票的数量
param.Add(_whichStore); ///2.添加酒库名称/////////
param.Add(trim(copy(trim(DataInfo[0][4]),1,pos('∕',trim(DataInfo[0][4]))-1))); ///3.产品名称
param.Add(trim(datainfo[0][6])); ///4.单位
param.Add(trim(copy(trim(datainfo[0][5]),4,length(trim(datainfo[0][5]))-3))); ///5。规格
strSql:='update sale_storage set boxNum=:s1 Where WhichStore=:s2 ';
strsql:=strsql+' and produceName=:s3 and UnitName=:s4 and Specification=:s5';
_AdoNewProduce.actionRecord(strSql,param);
end ////_store=0
else
begin
{/*
为了计算编号,首先得到一线酒库品种的记录数
*/}
param.clear;
param.Add(_whichStore);
strSql:='select * from sale_Storage Where whichStore=:s3';
_OrderID:=_AdoNewproduce.getRecordCount(strsql,param)+1;
{/*
进行存盘操作newproduce-->sale_Storage
*/}
param.Clear;
param.Add(inttostr(_OrderID)); ///1.序号
param.Add(trim(copy(trim(DataInfo[0][4]),1,pos('∕',trim(DataInfo[0][4]))-1))); ///2.产品
param.Add(trim(datainfo[0][6])); ///3.单位
param.Add(trim(copy(trim(datainfo[0][5]),4,length(trim(datainfo[0][5]))-3))); ///4.规格
param.Add('-'+trim(DataInfo[0][8])); ///5.整箱数量
param.Add('0'); ///6.整瓶数量
///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; ////_store=0
{/*
修改newsale-->salebill表中的调票标志isChange--为1 ---0:代表未调 1:代表已经调票
*/}
param.Clear;
param.Add(DataInfo[0][0]);
strSql:='UpDate saleBill Set isChange=1 Where saleBillCode=:s1 and isCancel=0 and isChange=0';
_Adosale.actionRecord(strsql,param);
{/*
最后删除表格表面的一行数据/////////////////
*/}
grid1.DeleteRow(rect(1,grid1.Row,grid1.ColCount-1,grid1.row));
{/*
存盘成功提示
*/}
_str.actionOK(at_save);
end;///application
end;//if tmp_tablename=1
////tmp_tablename=2包装车间调票//////////////////////////////////////////////////
setLength(datainfo_PG,1);
DataInfo_PG[0]:=TStringList.Create;
DataInfo_PG[0].Clear;
if tmp_tablename=2 then
begin
{/*
首先得到包装车间单据号的记录信息,然后存储在datainfo_PG[0]中
*/}
param.Clear;
param.Add(trim(grid1.cells[1,grid1.row].foretext));
param.Add('否');
strSql:='Select 单据号,单位名称,包装物名称,验收车间,地区,开票日期,酒桶数,成套数,空箱数,空瓶数,';
strSql:=strSql+'验收人,制表人,单据标志,箱色,瓶色,票据来源 ';
strSql:=strSql+' From PGYSD Where 单据号=:s1 and 是否作废=:s2';
_AdoRongPin.getRecordList(strsql,param,datainfo_PG);
{/*
开始调票
*/}
if Application.MessageBox(pchar('确定是否调包装票?'),pchar('系统提示!'),MB_YesNo+MB_IconWarning)=id_yes then
begin
{/*
将记录存储到newproduce-->PG_ChangeBill中
*/}
param.clear;
for i:=0 to DataInfo_PG[0].Count-1 do
begin
///showmessage(DataInfo_PG[i]);
if trim(DataInfo_PG[0][i])<>'' then
begin
//showmessage('不空');
param.Add(DataInfo_PG[0][i]);
end
else
begin
//showmessage('kong');
param.add(' ');
end;
end;////for i
param.Add('0');
param.Add(_whichStore);
param.Add(trim(formatDateTime('yyyy-mm-dd hh:mm:ss',now)));
strSql:='insert into PG_ChangeBill(PG_BillCode,PG_TraderName,PG_WrapName,PG_WSName,PG_AreaName,PG_BillDate,PG_JTNum,';
strSql:=strSql+'PG_CTNum,PG_KXNum,PG_KPNum,PG_Checker,PG_Reporter,PG_BillFlag,PG_BoxColor,PG_BottleColor,PG_BillSource,isCanCel,';
strsql:=strsql+'whichStore,PG_OutStoreDate) 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);
{/*
更改品供验收票据的标志--->是否打印:1 为已经调过 空:为未调
*/}
param.Clear;
param.Add(trim(grid1.cells[1,grid1.row].foretext));
param.Add('否');
strSql:='Update PGYsd Set 是否打印=1 Where 单据号=:s1 and 是否作废=:s2';
_AdoRongPin.actionRecord(strsql,param);
showmessage('调票成功...');
///////////最后删除表格表面的一行数据/////////////////
grid1.DeleteRow(rect(1,grid1.Row,grid1.ColCount-1,grid1.row));
end;///Application.message
end;//tmp_tablename=2
////tmp_tablename=3是调押金票//////////////////////////////////////////////////
setLength(datainfo_YJ,1);
DataInfo_YJ[0]:=TStringList.Create;
DataInfo_YJ[0].Clear;
if tmp_tableName=3 then
begin
{/*
首先得押金单据号的记录信息,然后存储在datainfo_YJ[0]中
*/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -