inv_priceaudit_b.pas
来自「一个MRPII系统源代码版本」· PAS 代码 · 共 1,055 行 · 第 1/3 页
PAS
1,055 行
quotedstr(Sourceno)+','+
''''+tmp_memo+''')');
AdoQry_tmp.execsql;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
AdoQry_tmp.open;
Billid:=AdoQry_tmp.fieldbyname('Billid').asstring;
//把旧单据增加到InvBillline 红色单据
with tmp_AdoQry do
begin
First;
for M:=0 to recordCount-1 do
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
'insert InvInBillline(InvBillid,'+
'InvBilllineno,'+
'ItemCode,'+
'pono,'+
'polineno,'+
'BilllineremArk,'+
'InvBillqty,'+
'InvBillPrice,'+
'InvBillAmount,'+
'InvBillnotaxPrice,'+
'InvBillnotaxAmount,'+
'InvBillPricec,'+
'InvBillAmountc,'+
'InvBillnotaxPricec,'+
'InvBillnotaxAmountc,'+
'Valuation) '+
' Values('+Billid+','+
''''+fieldbyname('InvBilllineno').asstring+''','+
''''+fieldbyname('ItemCode').asstring+''','+
''''+lbl_Pono.Caption+''','+
''''+fieldbyname('polineno').asstring+''','+
''''+fieldbyname('BilllineremArk').asstring+''','+
'-('+fieldbyname('InvBillqty').asstring+'),'+
fieldbyname('InvBillPrice').asstring+'*'+fExchRate+','+
'-('+fieldbyname('InvBillAmount').asstring+')*'+fExchRate+','+
fieldbyname('InvBillnotaxPrice').asstring+'*'+fExchRate+','+
'-('+fieldbyname('InvBillnotaxAmount').asstring+')*'+fExchRate+','+
fieldbyname('InvBillPrice').asstring+','+
'-('+fieldbyname('InvBillAmount').asstring+'),'+
fieldbyname('InvBillnotaxPrice').asstring+','+
'-('+fieldbyname('InvBillnotaxAmount').asstring+'),'+
'0)');
AdoQry_tmp.execsql;
next;
end;
end;
//原单改备注
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add(' update InvInBill '+
' set InvBillremArk=InvBillremArk+''/''+'+
quotedstr(Extedt_memo.text+'已核价,蓝单:'+blueBillno+',红单:'+redBillno)+
' where InvBillid='+AdoQry_Head.fieldbyname('InvBillid').asstring);
execsql;
end;
AdoQry_Head.edit;
AdoQry_Head.fieldbyname('InvBillremArk').Value:=
AdoQry_Head.fieldbyname('InvBillremArk').Value+
'/'+Extedt_memo.text+'已核价,蓝单:'+blueBillno+',红单:'+redBillno;
AdoQry_Head.post;
end;
//存盘成功
AdoQry_Body.Connection.CommitTrans;
//状态控制--------------------
tmp_AdoQry.Free;
act_Save.enabled:=False;
act_Modify.enabled:=False;
dbgrideh.SetFocus;
except
begin
AdoQry_Body.Connection.RollBackTrans;
DispInfo(' 存盘不成功,请稍后再试! ',1);
end;
end;
Frm_Inv_PriceAudit_H.lct_InvBillno:=AdoQry_Head.fieldbyname('InvBillno').asstring;
Frm_Inv_PriceAudit_H.lct_WhCodeName:=AdoQry_Head.fieldbyname('whCodeName').asstring;
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('InvBillStkchck').Value:=1;
AdoQry_Head.fieldbyname('PriceAuditTimes').Value:=
AdoQry_Head.fieldbyname('PriceAuditTimes').Value+1;
AdoQry_Head.fieldbyname('RealBillFlag').Value:=mArk;
AdoQry_Head.post;
// AdoQry_Head.next;
end;
procedure TFrm_Inv_PriceAudit_B.Act_SaveExecute(Sender: TObject);
begin
if AdoQry_Head.fieldbyname('RealBillFlag').Value=0 then
begin
if MessageDlg('已经核过价,且产生了蓝单,不能再核价,是否关闭?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
Act_Save.Enabled:=False;
Close;
end;
end
else
inherited;
ActiveControl:=DBGridEh;
Extedt_InvBilltaxrate.enabled :=False;
Extedt_memo.Enabled:=False;
end;
procedure TFrm_Inv_PriceAudit_B.FormActivate(Sender: TObject);
begin
inherited;
//窗体TITLE的显示
if modal='暂估价' then
begin
Caption:='采购入库暂估价单据处理';
pnl_title.Caption:='采购入库暂估价单据处理';
chck_realPrice.Visible :=True;
if AdoQry_Head.fieldbyname('InvBillValuation').Value=0 then
chck_realPrice.checked:=True
else
chck_realPrice.checked:=False;
end
else
begin
Caption:='采购入库单据核价';
pnl_title.Caption:='采购入库单据核价';
chck_realPrice.Visible :=False;
chck_realPrice.Checked :=False;
end;
ToolButton4.Left:=TlBtn_Print.Left+ToolButton4.Width;
if status='ReadOnly' then
begin
act_Save.enabled:=False;
Caption:='单据明细';
pnl_title.Caption:='单据明细';
end
else
act_Save.Enabled:=True;
end;
procedure TFrm_Inv_PriceAudit_B.Act_PreviewExecute(Sender: TObject);
begin
//inherited;
if ((BillTypeCode='0102') and (GetCode(lbl_Currency.Caption)<>'00')) then
begin
try
with TFrm_Inv_PurchaseIn_P_CC.Create(self) do
begin
showmodal;
if modalResult=mrok then
begin
if RadioGroupprint.ItemIndex=0 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'');
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'C');
end;
if RadioGroupprint.ItemIndex=1 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'');
end;
if RadioGroupprint.ItemIndex=2 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'C');
end;
end;
end;
finally
Frm_Inv_PurchaseIn_P_CC.Free;
end;
end
else
if (BillTypeCode='0103') then
try
with TFrm_Inv_PurchaseIn_P_OO.Create(self) do
begin
showmodal;
if modalResult=mrok then
begin
if RadioGroupprint.ItemIndex=0 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'');
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'B');
end;
if RadioGroupprint.ItemIndex=1 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'');
end;
if RadioGroupprint.ItemIndex=2 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'B');
end;
end;
end;
finally
Frm_Inv_PurchaseIn_P_CC.Free;
end
else
begin
BillPrint(AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption) ,Extedt_Billno.text,BillTypeCode,ModuleCode,True,False,True,'');
end;
end;
procedure TFrm_Inv_PriceAudit_B.Act_PrintExecute(Sender: TObject);
begin
//inherited;
if ((BillTypeCode='0102') and (GetCode(lbl_Currency.Caption)<>'00')) then
begin
try
with TFrm_Inv_PurchaseIn_P_CC.Create(self) do
begin
showmodal;
if modalResult=mrok then
begin
if RadioGroupprint.ItemIndex=0 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'');
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'C');
end;
if RadioGroupprint.ItemIndex=1 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'');
end;
if RadioGroupprint.ItemIndex=2 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'C');
end;
end;
end;
finally
Frm_Inv_PurchaseIn_P_CC.Free;
end;
end
else
if (BillTypeCode='0103') then
try
with TFrm_Inv_PurchaseIn_P_OO.Create(self) do
begin
showmodal;
if modalResult=mrok then
begin
if RadioGroupprint.ItemIndex=0 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'');
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'B');
end;
if RadioGroupprint.ItemIndex=1 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'');
end;
if RadioGroupprint.ItemIndex=2 then
begin
BillPrint(self.AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption),Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'B');
end;
end;
end;
finally
Frm_Inv_PurchaseIn_P_CC.Free;
end
else
begin
// tmp_lastBillno:=(100000+strtoint(copy(Trim(Extedt_Billno.text),6,5))+1);
// BillPrint(AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption) ,Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'');
BillPrint(AdoQry_Tmp.Connection,GetCode(lbl_WhCode.Caption) ,Extedt_Billno.text,BillTypeCode,ModuleCode,False,False,True,'');
end;
end;
procedure TFrm_Inv_PriceAudit_B.edt_DateExit(Sender: TObject);
begin
inherited;
if length(Trim(edt_Date.text))=1 then
edt_Date.text:='0'+Trim(edt_Date.text);
tmp_Date:=lbl_Month.Caption+edt_Date.text;
try
DateSeparator:='.';
Shortdateformat:='yyyy.mm.dd';
StrToDateTime(tmp_Date);
except
DispInfo(' 日期非法! ',1);
TWinControl(Sender).SetFocus;
Abort;
end;
//如果是进口采购,取当前日期的汇率
if BillTypeCode='0102' then
begin
if AdoQry_Head.fieldbyname('currencyCode').asstring<>'00' then
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select ExchRate '+
' from ExchRate '+
'where exchMonth='''+copy(tmp_Date,1,7)+''' and '+
' currencyCode='''+AdoQry_Head.fieldbyname('currencyCode').asstring+'''');
open;
if eof then
begin
DispInfo('币种:'+AdoQry_Head.fieldbyname('currencyCode').asstring+' '+AdoQry_Head.fieldbyname('currencyName').asstring+' '+copy(tmp_Date,1,7)+'月的汇率没有定义!',1);
edt_Date.setfocus;
end
else
begin
fExchRate:=fieldbyname('ExchRate').asstring;
end;
end;
end
else fExchRate:='1';
end;
end;
procedure TFrm_Inv_PriceAudit_B.Act_ModifyExecute(Sender: TObject);
begin
if AdoQry_Head.fieldbyname('RealBillFlag').Value=0 then
begin
showmessage('已经核过价,且产生了蓝单,不能再核价');
exit;
end
else
inherited;
end;
procedure TFrm_Inv_PriceAudit_B.DBGridEhDblClick(Sender: TObject);
begin
if AdoQry_Head.fieldbyname('RealBillFlag').Value=0 then
begin
showmessage('已经核过价,且产生了蓝单,不能再核价');
exit;
end
else
inherited;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?