📄 inv_enter_homemadeckinvin.pas
字号:
+' '''+GetCode(CmBx_Warehouse.Text)+''''
+','''+AdoQry_Tmp1.fieldbyname('ItemCode').AsString+''''
+')'
+' Update AveragePrice Set'
+' ApQty=ApQty+'+AdoQry_Tmp1.fieldbyname('InvBillQty').AsString+''
+',ApAmount=ApAmount+'+AdoQry_Tmp1.fieldbyname('InvBillNoTaxPrice').AsString
+'*'+AdoQry_Tmp1.fieldbyname('InvBillQty').AsString+'*'+fExchRate
+' Where WHCode='''+GetCode(CmBx_Warehouse.Text)+''''
+' And ItemCode='''+AdoQry_Tmp1.fieldbyname('ItemCode').AsString+''''
+' Update AveragePrice Set'
+' AveragePrice=Case When ApQty=0 Then AveragePrice Else ApAmount/ApQty end'
+' Where WHCode='''+GetCode(CmBx_Warehouse.Text)+''''
+' And ItemCode='''+AdoQry_Tmp1.fieldbyname('ItemCode').AsString+'''';
AdoQry_Tmp.ExecSQL;
end;
//更新InvInBillline中的价格
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:='Update InvInBillline Set'
+' Valuation='+AdoQry_Tmp1.fieldbyname('PoreferencedPrice').AsString+''
+',InvBillNoTaxPriceC='+AdoQry_Tmp1.fieldbyname('InvBillNoTaxPrice').AsString+''
+',InvBillNoTaxAmountC='+AdoQry_Tmp1.fieldbyname('InvBillNoTaxPrice').AsString
+'*'+AdoQry_Tmp1.fieldbyname('InvBillQty').AsString+''
+',InvBillPriceC='+AdoQry_Tmp1.fieldbyname('InvBillPrice').AsString+''
+',InvBillAmountC='+AdoQry_Tmp1.fieldbyname('InvBillPrice').AsString
+'*'+AdoQry_Tmp1.fieldbyname('InvBillQty').AsString+''
+',InvBillNoTaxPrice='+AdoQry_Tmp1.fieldbyname('InvBillNoTaxPrice').AsString
+'*'+fExchRate+''
+',InvBillNoTaxAmount=Round('+AdoQry_Tmp1.fieldbyname('InvBillNoTaxPrice').AsString
+'*'+AdoQry_Tmp1.fieldbyname('InvBillQty').AsString+'*'+fExchRate+',2)'
+',InvBillPrice='+AdoQry_Tmp1.fieldbyname('InvBillPrice').AsString
+'*'+fExchRate+''
+',InvBillAmount=Round('+AdoQry_Tmp1.fieldbyname('InvBillPrice').AsString
+'*'+AdoQry_Tmp1.fieldbyname('InvBillQty').AsString+'*'+fExchRate+',2)'
+' Where InvBillId='+Bill_Id
+' And InvBillLineNo='+AdoQry_Tmp1.fieldbyname('InvBillLineNo').AsString
+' And ItemCode='''+AdoQry_Tmp1.fieldbyname('ItemCode').AsString+'''';
AdoQry_Tmp.ExecSQL ;
AdoQry_Tmp1.Next;
end;
AdoQry_Tmp1.Free;
CmBx_WhPosition.Enabled:=False;
Edt_RemArk.Enabled:=False;
Act_Save.Enabled:=False;
DBConnect.CommitTrans;
AdoQry_Body.EnableControls ;
DBGridEh.Columns[5].ReadOnly :=True;
Frm_Inv_Enter_HomemadeCkInvInH.FSelectedLine.clear;
except
on e:Exception do
begin
DBConnect.RollBackTrans;
Act_Save.Enabled:=False;
RecOrderror(Self,AdoQry_tmp,E.message);
AdoQry_Body.EnableControls ;
DispInfo(DispStr,3);
Abort;
end;
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.SaveHeadData;
begin//把表头控件写入缓存,没Post
inherited;
if not FFromCheckIn then
with AdoQry_Head do
begin//把根据表头当前数据初始化,表头控件
fieldbyname('WHCode').AsString:=GetCode(CmBx_Warehouse.Text);
fieldbyname('WHName').AsString:=GetName(CmBx_Warehouse.Text);
fieldbyname('PONO').AsString:=Edt_PoNO.Text;
fieldbyname('VendorCode').AsString:=ExtEdt_VendorCode.Text;
fieldbyname('VendorName').AsString:=Lbl_VendorName.Caption;
fieldbyname('VendorBillNo').AsString:=Edt_VendorBillNo.Text;
fieldbyname('WhPositionCode').AsString:=GetCode(CmBx_WhPosition.Text);
fieldbyname('WhPositionName').AsString:=GetName(CmBx_WhPosition.Text);
fieldbyname('InvBillNo').AsString:=Edt_BillNo.Text;
fieldbyname('InvBillDate').AsString:=MEdt_BillDate.Text;
fieldbyname('InvBillRemArk').AsString:=Edt_ReMArk.Text;
end
Else
begin
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.SetStatus(CurrentStatus: String;
var AnswerStatus, EnableControls: String);
begin//窗体状态设置
inherited;
If FFromCheckIn then
begin
if CurrentStatus='Edit' then
begin
AnswerStatus:='Edit';
EnableControls:='Edt_RemArk,CmBx_WhPosition,MEdt_BillDate,';
end
else
begin
AnswerStatus:='ReadOnly';
EnableControls:='';
end;
end
else
if(CurrentStatus='Edit')then
begin
AnswerStatus:='ReadOnly';
EnableControls:='';
end
else if (CurrentStatus='Add') then
begin
AnswerStatus:='Add';
EnableControls:='Edt_RemArk,Edt_VendorBillNo,';
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.FormCreate(Sender: TObject);
begin
inherited;
FFromCheckIn :=False;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.CmBx_WarehouseChange(Sender: TObject);
var
tmp_WhCode,tmp_WhPositionCode:string;
begin
inherited;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select WhPositionCode+'' ''+WhPositionName As WhPositionCodeName'
+' From WhPosition'
+' Where WHCode='''+GetCode(CmBx_Warehouse.Text)+''''
+' And WhPositionType<>1 '
+' And BackFlushWHP<>1'
+' Order By WhPositionCode';
AdoQry_Tmp.Open;
AdoQry_Tmp.First;
CmBx_WhPosition.clear;
while not AdoQry_Tmp.Eof do
begin
CmBx_WhPosition.Items.Add(AdoQry_Tmp.fieldbyname('WhPositionCodeName').AsString);
AdoQry_Tmp.Next;
end;
if Status='ReadOnly' then
InitCmBxText(CmBx_WhPosition,AdoQry_Head.fieldbyname('WhPositionCode').AsString)
else
CmBx_WhPosition.Itemindex:=0;
If IsSpecial then
begin
tmp_WhCode:=GetCode(CmBx_Warehouse.Text);
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select WhPosition.WhPositionCode,WhPosition.WhPositionName '+
' From WhPosition '+
' Where WhPosition.WHCode='''+tmp_WhCode+''''+
' And WhPositionType=2 ');
open;
tmp_WhPositionCode:=fieldbyname('WhPositionCode').AsString;
end;
InitCmBxText(CmBx_WhPosition,tmp_WhPositionCode);
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.PoCodeCheck(Sender: TObject);
begin
if (ActiveControl=ExtEdt_VendorCode ) or (ActiveControl.Name ='ToolButton4') then
Exit;
//inherited;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select mo.DeptCode'
+' From mo Where mo.moNo='''+Trim(Edt_PoNO.text)+'''';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('DeptCode').AsString<>ExtEdt_VendorCode.Text then
begin
DispInfo('订单号不存在或不属于该生产部门!',3);
TWinControl(Sender).SetFocus;
Abort;
end;
{AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Select PoSpecial From Po Where PoNo='''+TEdit(Sender).Text+'''');
AdoQry_Tmp.Open;
If AdoQry_Tmp.fieldbyname('PoSpecial').AsFloat=1 then
begin
If OLDPoNo<>Edt_PoNo.Text then
//DispInfo('该PO属于独立PO,入库只能发生在"冻结"类型的货位上!',3);
OldPoNo:=Edt_PoNo.Text;
IsSpecial:=True;
if not Changed then exit;
CmBx_WarehouseChange(cmbx_Warehouse);
end
Else
begin
IsSpecial:=False;
OldPoNo:=Edt_PoNo.Text;
// CmBx_WarehouseChange(cmbx_Warehouse);
end;}
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.SetFormParam(FrmParam1,FrmParam2,FrmParam3,
FrmParam4,FrmParam5,FrmParam6:String);
begin
if FrmParam1='CheckIn' then
FFromCheckIn:=True;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.FormActivate(Sender: TObject);
begin
IsSpecial:=False;
inherited;
// Frm_Entry_Detail.Caption:=FormCaption;
if (FFromCheckIn)then
begin
Act_Save.Enabled:=True;
AdoQry_Head.Edit;
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.DateCheck(Sender: TObject);
begin
inherited;
if not WHClsPeriodCheck(AdoQry_Tmp,GetCode(Cmbx_Warehouse.Text),
Copy((TEdit(Sender).Text),1,7)) then
begin
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.Act_PreviewExecute(Sender: TObject);
begin
// inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(CmBx_Warehouse.Text),Edt_BillNo.Text,Param1,ModuleCode,True,False,True,'');
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.Act_PrintExecute(Sender: TObject);
begin
// inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(CmBx_Warehouse.Text),Edt_BillNo.Text,Param1,ModuleCode,False,False,True,'');
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.Edt_PoNOKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if(Key=120)then
CommonHint(Sender,AdoQry_Tmp,'mono','生产订单号','MoLineno',
'生产订单行号','MoLine','MoLineStatus=6');
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.Act_InsertLineExecute(Sender: TObject);
begin
act_Save.enabled:=True;
//Frm_Entry_Detail.SetFormParam(GetCode(CmBx_Warehouse.Text),MEdt_BillDate.Text,
// FFDays,FBDays,FOQty,GetCode(CmBx_WhPosition.Text));
inherited;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.Act_ModifyExecute(Sender: TObject);
begin
//Frm_Entry_Detail.SetFormParam(GetCode(CmBx_Warehouse.Text),MEdt_BillDate.Text,
// FFDays,FBDays,FOQty,GetCode(CmBx_WhPosition.Text));
inherited;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.DBGridEhColExit(Sender: TObject);
begin
inherited;
if not dbgrideh.ReadOnly then
if (LowerCase(dbgrideh.SelectedField .fieldName)='InvBillqty' )
then
begin
AdoQry_Body.refresh;
if AdoQry_Body.fieldbyname('InvBillQTY').asfloat >oldInvBillQTY then
begin
DispInfo('入库数量不能大于质检判定数量!',1);
abort;
end;
end;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.DBGridEhColEnter(Sender: TObject);
begin
inherited;
oldInvBillQTY:=AdoQry_Body.fieldbyname('InvBillQTY').asfloat;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.AdoQry_BodyBeforeEdit(DataSet: TDataSet);
begin
inherited;
//oldInvBillQTY:=0.0;
oldInvBillQTY:=AdoQry_Body.fieldbyname('InvBillQTY').asfloat;
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.DBGridEhKeyPress(Sender: TObject;
var Key: ChAr);
begin
inherited;
//if key=VK_TAB then
end;
procedure TFrm_Inv_Enter_HomemadeCkInvIn.DBGridEhExit(Sender: TObject);
begin
inherited;
//DBGridEhColExit(DBGridEh);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -