📄 datamodule1.pas
字号:
adoCmd.parameters[6].value:=myUsrName;
adoCmd.parameters[7].value:=nEmployId;
adoCmd.parameters[8].value:=sMemo;
adoCmd.execute;
end;
procedure TDataE2.InsertIInstore(nTblId,nBillid,nVendorId,nEmployId,nStoreId:integer;dBillDate:tdatetime;sInvono,sMemo:string);
begin
if nTblId=1 then
adoCmd.commandtext:='insert into I_INSTORE values ( :BillId, :invono , :Venderid, :storeid,0, :billdate, :operator, :EmployId, null,null,0, :IsSent,:inType,0,0, :memo)'
else //outstore
adoCmd.commandtext:='insert into O_OUTSTORE values ( :BillId, :invono , :Venderid, :storeid,0, :billdate, :operator, :EmployId, 0,null,null,0,:IsSent,:saletype,0,0, :memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=nVendorId;
adoCmd.parameters[3].value:=nStoreId;
adoCmd.parameters[4].value:=dBillDate;
adoCmd.parameters[5].value:=myUsrName;
adoCmd.parameters[6].value:=nEmployid;
//将现款销售与开单分开
if ((nTblId = 11) or (nTblId = 1)) and bBatchSale then
adoCmd.parameters[7].value:=1
else
adoCmd.parameters[7].value:=0;
if ((nTblId = 11) or (nTblId = 1)) and bBatchSale then
adoCmd.parameters[8].value:=1
else
adoCmd.parameters[8].value:=0;
adoCmd.parameters[9].value:=sMemo;
adoCmd.execute;
end;
procedure TDataE2.InsertIOGas(nTblId,nBillid,nVendorId,nEmployId,nStoreId:integer;dBillDate:tdatetime;sInvono,sMemo:string);
begin
adoCmd.commandtext:='insert into IO_Gas values ( :BillId, :invono , :Clientid, :storeid,0, :billdate, :operator, :EmployId, :clientOpr,-1,-1,-1,0,0,0, :memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=nVendorId;
adoCmd.parameters[3].value:=nStoreId;
adoCmd.parameters[4].value:=dBillDate;
adoCmd.parameters[5].value:=myUsrName;
adoCmd.parameters[6].value:=nEmployid;
adoCmd.parameters[7].value:='';
adoCmd.parameters[8].value:=sMemo;
adoCmd.execute;
end;
procedure TDataE2.InsertDRepair(nTblId,nBillid,nCusid,nCusfileid,nEmployId,nStoreId:integer;dBillDate:tdatetime;sInvono,sMemo:string);
begin
adoCmd.commandtext:='insert into D_Repair values ( :BillId, :invono , :Clientid, :Cusfileid, :storeid,0, :billdate, 0, :operator, :EmployId, 0, :problem, :Detection, :Rptype, :receiver, :memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=nCusId;
adoCmd.parameters[3].value:=nCusfileId;
adoCmd.parameters[4].value:=nStoreId;
adoCmd.parameters[5].value:=dBillDate;
adoCmd.parameters[6].value:=myUsrName;
adoCmd.parameters[7].value:=nEmployid;
adoCmd.parameters[8].value:='';
adoCmd.parameters[9].value:='';
adoCmd.parameters[10].value:='';
adoCmd.parameters[11].value:='';
adoCmd.parameters[12].value:=sMemo;
adoCmd.execute;
end;
procedure TDataE2.InsertIReturn(nBillid,nVendorId,nEmployId,nStoreId,IsRCash,nPayTypeId,nBankId:integer;
dBillDate:tdatetime;sInvono,sMemo,sChekcNo,sTable:string);
begin
adoCmd.commandtext:='insert into '+sTable+' values ( :BillId, :invono , :VendorId, :storId,0, :billdate, :operator, :EmployId,:PayTypeId,:BankId, :checkNo, :IsRCash,1, :Memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=nVendorId;
adoCmd.parameters[3].value:=nStoreId;
adoCmd.parameters[4].value:=dBillDate;
adoCmd.parameters[5].value:=myUsrName;
adoCmd.parameters[6].value:=nEmployid;
adoCmd.parameters[7].value:=nPayTypeId;
adoCmd.parameters[8].value:=nBankId;
adoCmd.parameters[9].value:='';
adoCmd.parameters[10].value:=IsRCash;
adoCmd.parameters[11].value:=sMemo;
adoCmd.execute;
end;
procedure TDataE2.InsertIPay(nBillid,nCusId,nEmployid,nBankId,nPayTypeId:integer;dBillDate:Tdatetime;sInvoNo,sMemo,sCheckNo,sPayStyle,sTable,sAmt:string);
var
nBillAmt:real;
code:integer;
begin
adoCmd.commandtext:='insert into '+sTable+' values ( :BillId, :invono ,:Cusid, :BillAmt, :billdate, :operator, :EmployId, :paytypeid, :bankId, :paystyle, :checkNo,null,null,0,0, :Memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=nCusId;
if (sPayStyle='预付款') or (sPayStyle='预收款') then
begin
Val(sAmt, nBillamt, Code);
if Code <> 0 then
nBillamt:=0;
adoCmd.parameters[3].value:=nBillamt;
end else
adoCmd.parameters[3].value:=0;
adoCmd.parameters[4].value:=dBillDate;
adoCmd.parameters[5].value:=myUsrName;
adoCmd.parameters[6].value:=nEmployid;
adoCmd.parameters[7].value:=nPayTypeid;
adoCmd.parameters[8].value:=nBankid;
adoCmd.parameters[9].value:=sPayStyle;
adoCmd.parameters[10].value:=sCheckNo;
adoCmd.parameters[11].value:=sMemo;
adoCmd.execute;
end;
//其它收入
procedure TDataE2.InsertDIncome(nBillid,nEmployid,nBankId,nPayTypeId:integer;dBillDate:Tdatetime;sInvoNo,sMemo,sCheckNo,sTable:string);
begin
adoCmd.commandtext:='insert into '+sTable+' values ( :BillId, :invono , 0, :billdate, :operator, :EmployId, :paytypeid, :bankId, :checkNo, :Memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=dBillDate;
adoCmd.parameters[3].value:=myUsrName;
adoCmd.parameters[4].value:=nEmployid;
adoCmd.parameters[5].value:=nPayTypeid;
adoCmd.parameters[6].value:=nBankid;
adoCmd.parameters[7].value:=sCheckNo;
adoCmd.parameters[8].value:=sMemo;
adoCmd.execute;
end;
//盘点,
procedure TDataE2.InsertDCheck(nBillid,nStoreid:integer;dBillDate:tdatetime;sInvono,sMemo:string);
begin
adoCmd.commandtext:='insert into d_check values ( :BillId, :invono , :billdate, :operator, :StoreId, 0, :memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvono;
adoCmd.parameters[2].value:=dBillDate;
adoCmd.parameters[3].value:=myUsrName;
adoCmd.parameters[4].value:=nStoreId;
adoCmd.parameters[5].value:=sMemo;
adoCmd.execute;
end;
//盘点,
procedure TDataE2.InsertDMove(nBillid,nStoreid,nOutStoreId:integer;dBillDate:tdatetime;sInvono,sMemo:string);
begin
adoCmd.commandtext:='insert into d_Move values ( :BillId, :invono , :billdate, :operator, :OutStoreId, :StoreId, 0, :memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvono;
adoCmd.parameters[2].value:=dBillDate;
adoCmd.parameters[3].value:=myUsrName;
adoCmd.parameters[4].value:=nOutStoreId;
adoCmd.parameters[5].value:=nStoreId;
adoCmd.parameters[6].value:=sMemo;
adoCmd.execute;
end;
//其它出入库
procedure TDataE2.InsertDInOut(nBillid,nStoreid,nEmployid,nIoTypeId,nRSunit:integer;dBillDate:TDatetime;sInvono,sMemo:string);
begin
adoCmd.commandtext:='insert into d_InOut values ( :BillId, :invono , :billdate, :StoreId, :TypeId, :operator , :employId,0,0, :rsunit, :memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvono;
adoCmd.parameters[2].value:=dBillDate;
adoCmd.parameters[3].value:=nStoreId;
adoCmd.parameters[4].value:=nIoTypeId;
adoCmd.parameters[5].value:=myUsrName;
adoCmd.parameters[6].value:=nEmployId;
adoCmd.parameters[7].value:=nRSunit;
adoCmd.parameters[8].value:=sMemo;
adoCmd.execute;
end;
procedure TDataE2.InsertIBuildTear(bNew:boolean;nBillid,nStoreId,nOutStoreId,nEmployId,GoodsId:integer;dBillDate:tdatetime;sInvono,sMemo,sTable:string;nQty,nPrice:real);
begin
if bNew then
begin
adoCmd.commandtext:='insert into '+sTable+' values ( :BillId, :invono , :InStoreId, :outstoreid, :billdate, :operator, :EmployId, :Goodsid, :qty, :price, :BillAmt, :Memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=nStoreId;
adoCmd.parameters[3].value:=nOutStoreId;
adoCmd.parameters[4].value:=dBillDate;
adoCmd.parameters[5].value:=myUsrName;
adoCmd.parameters[6].value:=nEmployid;
adoCmd.parameters[7].value:=GoodsId;
adoCmd.parameters[8].value:=nQty;
adoCmd.parameters[9].value:=nPrice;
adoCmd.parameters[10].value:=nQty*nPrice;
adoCmd.parameters[11].value:=sMemo;
adoCmd.execute; end
else begin
adoCmd.commandtext:='update '+sTable+' set StoreId= :storId,EmployId= :EmployId,GoodsId= :Goodsid,Qty= :qty,Price= :price,BillAmt :BillAmt,Memo= :Memo where billid= :billid';
adoCmd.parameters[0].value:=nStoreId;
adoCmd.parameters[1].value:=nEmployid;
adoCmd.parameters[2].value:=GoodsId;
adoCmd.parameters[3].value:=nQty;
adoCmd.parameters[4].value:=nPrice;
adoCmd.parameters[5].value:=nQty*nPrice;
adoCmd.parameters[6].value:=sMemo;
adoCmd.parameters[7].value:=nBillId;
adoCmd.execute;
end;
end;
procedure TDataE2.InsertDMaterial(nBillid,nEmployId,GoodsId:integer;dBillDate:tdatetime;sInvono,sMemo,sSelfCode:string;nQty:real);
begin
adoCmd.commandtext:='insert into D_Material values ( :BillId, :invono , :billdate, :EmployId, :selfCode, :Goodsid, :qty, :operator, :Memo)';
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=sInvoNo;
adoCmd.parameters[2].value:=dBillDate;
adoCmd.parameters[3].value:=nEmployid;
adoCmd.parameters[4].value:=sSelfcode;
adoCmd.parameters[5].value:=GoodsId;
adoCmd.parameters[6].value:=nQty;
adoCmd.parameters[7].value:=myUsrName;
adoCmd.parameters[8].value:=sMemo;
adoCmd.execute;
end;
Procedure TDataE2.InsertOnHand(nStoreId,nGoodsId:integer);
begin
AdoStp1.Close;
AdoStp1.ProcedureName :='dbo.pcdInsOnHand;1';
try
AdoStp1.Parameters.Refresh;
AdoStp1.Parameters[1].value:=nStoreid;
AdoStp1.Parameters[2].value:=nGoodsId;
except
end;
Adostp1.execproc;
end;
Function TDataE2.GetPriorNext(bPrior:boolean;tablename:string;nBillId:integer):boolean;
begin
sSql:='select top 1 * from ';
if bPrior then
sSql:=sSql+ tableName+ ' where billid < :billId order by billid desc'
else
sSql:=sSql+ tableName+ ' where billid > :billId ';
if adoquery1.active then adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add(sSql);
adoquery1.parameters[0].value:=nBillid;
adoQuery1.open;
result:=not adoquery1.eof;
end;
{Function TDataE2.GetNext(tablename:string;nBillId:integer):boolean;
begin
sSql:='select top 1 * from ';
sSql:=sSql+ tableName+ ' where billid > :billId ';
if adoquery1.active then adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add(sSql);
adoquery1.parameters[0].value:=nBillid;
adoQuery1.open;
result:=not adoquery1.eof;
end;
}
Function TDataE2.GetReftblName(nTblId:integer):string;
begin
result:='NULL';
case nTblId of
1: result:=aTblName[0];
2: result:=aTblName[1];
3: result:=aTblName[1];
11: result:=aTblName[10];
12: result:=aTblName[11];
13: result:=aTblName[11];
end;
end;
Function TDataE2.UPdateMasterAmt(nTblId,nBillId:integer):boolean;
begin
AdoStp1.Close;
AdoStp1.ProcedureName :='dbo.pcdUpdateMasterAmt;1';
try
AdoStp1.Parameters.Refresh;
AdoStp1.Parameters[1].value:=aTblName[nTblId];
AdoStp1.Parameters[2].value:=GetRefTblName(nTblId);
AdoStp1.Parameters[3].value:=nBillid;
AdoStp1.Parameters[4].value:=nTblid;
if ( (nTblId =11) or (nTblId =1) ) and bBatchSale then
AdoStp1.Parameters[5].value:=1
else
AdoStp1.Parameters[5].value:=0;
except
end;
Adostp1.execproc;
result:=Adostp1.Parameters[0].value;
end;
Function TDataE2.UPdateRefTableAmt(nTblId,nBillId:integer):boolean;
begin
AdoStp1.Close;
AdoStp1.ProcedureName :='dbo.pcdUpdateRefTable;1';
try
AdoStp1.Parameters.Refresh;
AdoStp1.Parameters[1].value:=aTblName[nTblId];
AdoStp1.Parameters[2].value:=GetRefTblName(nTblId);
AdoStp1.Parameters[3].value:=nBillid;
AdoStp1.Parameters[4].value:=nTblid;
except
end;
Adostp1.execproc;
result:=Adostp1.Parameters[0].value;
end;
procedure TDataE2.queryDetailNewRecord(DataSet: TDataSet);
begin
with queryDetail do
begin
fieldbyname('BillId').asinteger:=nBillId;
fieldbyname('itemno').asinteger:=nId;
fieldbyname('memo1').asstring:='';
if (gTableid mod 10 <>3) and ( gTableid <= 30 ) then
begin
fieldbyname('qty').asinteger:=0;
fieldbyname('code').asstring:='';
if gTableId <> 30 then
fieldbyname('price').asinteger:=0;
end;
end;
inc(nid);
end;
procedure TDataE2.queryDetailCalcFields(DataSet: TDataSet);
begin
with queryDetail do
case gTableId of
3,13:
fieldbyname('Total').AsCurrency :=fieldbyname('BillAmt').AsCurrency-fieldbyname('TakeAmt').ascurrency-fieldbyname('RtnAmt').ascurrency;
23: //pos查询
fieldbyname('Total').AsCurrency :=fieldbyname('qty').Asfloat*fieldbyname('Price').ascurrency;//*fieldbyname('disc').asinteger/100;
else
begin
if nIOTotalbit=2 then
begin
if fieldbyname('qty').AsFloat*fieldbyname('price').ascurrency>=0 then
fieldbyname('Total').AsCurrency :=Int(fieldbyname('qty').AsFloat*fieldbyname('price').ascurrency*100+0.5)/100
else fieldbyname('Total').AsCurrency :=Int(fieldbyname('qty').AsFloat*fieldbyname('price').ascurrency*100-0.5)/100;
end
else
fieldbyname('Total').AsCurrency :=fieldbyname('qty').AsFloat*fieldbyname('price').ascurrency;
end;
end;
end;
procedure TDataE2.tblTypeNewRecord(DataSet: TDataSet);
begin
with tblType do
begin
//edit;
fieldbyname('type').asstring:='*';
fieldbyname('name').asstring:='';
fieldbyname('desk').asstring:='';
end;
end;
procedure TDataE2.tblType1NewRecord(DataSet: TDataSet);
begin
with tblType1 do
begin
fieldbyname('type').asstring:=tblType.fieldbyname('type').asstring;
fieldbyname('code1').asstring:='*';
fieldbyname('name').asstring:='';
end;
end;
procedure TDataE2.tblType2NewRecord(DataSet: TDataSet);
begin
with tblType2 do
begin
fieldbyname('type').asstring:=tblType1.fieldbyname('type').asstring;
fieldbyname('code1').asstring:=tblType1.fieldbyname('code1').asstring;;
fieldbyname('code2').asstring:='*';
fieldbyname('name').asstring:='';
end;
end;
procedure TDataE2.QueryGoodsCalcFields(DataSet: TDataSet);
begin
with QueryGoods do
FieldByName('codename').value:=trim(FieldByName('code').value)+' '+trim(FieldByName('name').value);
end;
procedure TDataE2.DecodeSelection;
begin
if sSelection[1]='1' then bNostore:=true else bNoStore:=false;
if sSelection[2]='1' then bExtraPage:=true else bExtraPage:=false;
nSysPaper:=strtoint(sSelection[3]);
nSysLevel1:=strtoint(sSelection[4]); //各级编码的总长(含上级) - 1
nSysLevel2:=nSysLevel1+strtoint(sSelection[5]);
nSysLevel3:=nSysLevel2+strtoint(sSelection[6]);
if sSelection[7]='1' then bInputTip:=true else bInputTip:=false;
if sSelection[8]='1' then bFIFO:=true else bFIFO:=false;
nSample:=strtoint(sSelection[9]);
if sSelection[10]='1' then bZone:=true else bZone:=false;
if sSelection[11]='1' then bPenStyle:=true else bPenStyle:=false;
nInpriceType:=strtoint(sSelection[12]);
nSumbit:=strtoint(sSelection[13]);
if sSelection[14]='1' then bPrintBarcode:=true else bPrintBarcode:=false;
nPageBottomMargin:=strtoint(sSelection[15])*10+strtoint(sSelection[16]);
if sSelection[17]='1' then bTwoUnit:=true else bTwoUnit:=false;
nBillStyle:=strtoint(sSelection[18]);
if sSelection[19]='1' then bOutUnit2:=true else bOutUnit2:=false;
nIOTotalbit:=strtoint(sSelection[20]);
if nSaveDataDay=0 then nSaveDataDay:=999; //不册除数据
if nSysLine=0 then nSysLine:=999; //为0 不打印分隔线
end;
Function TDataE2.ToMyValue(oldValue:real):real;
var
nNum,nAbs:integer;
nTmp:real;
begin
nNum:=100;
case nSumbit of
0: nNum:=1;
1: nNum:=10;
2: nNum:=100;
3: nNum:=1000;
4: nNum:=10000;
end;
nAbs:=1;
if OldValue <0 then nAbs:=-1;
nTmp:=OldValue*nNum;
nTmp:=nTmp+0.5*nAbs; //四舍五入
nTmp:=int(nTmp)/nNum;
result:=nTmp;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -