📄 inv_enter_whtowh.pas
字号:
'Values('
+''''+IBill_No+''''
{+','''+AdoQry_Head.fieldbyname('WHCode').AsString+''''
+','''+AdoQry_Head.fieldbyname('InvBillDate').AsString+''''
+','''+FormatDateTime('yyyy.mm',AdoQry_Head.fieldbyname('InvBillDate').
AsDateTime)+''''}
+','''+getCode(CmBx_OWarehouse.text)+''''
//+','''+AdoQry_Head.fieldbyname('InvBillDate').AsString+''''
//+','''+FormatDateTime('yyyy.mm',AdoQry_Head.fieldbyname('BillDate').
// AsDateTime)+''''
+','''+LEdt_ToDeptCode.text+''''
+','''+MEdt_BillDate.text+''''
+','''+copy(MEdt_BillDate.text,1,7)+''''
+','+'''0199'''+','+'''098'''+',1'
+','''+UserCode+''''
+','''+UserCode+''''
//+','''+AdoQry_Head.fieldbyname('WhPositionCode').AsString+''''
//+','''+AdoQry_Head.fieldbyname('OWhPositionCode').AsString+''''
//','''+AdoQry_Head.fieldbyname('InvBillRemArk').AsString+''''
+','''+getCode(CmBx_WhPosition.text)+''''
+','''+getCode(CmBx_OWhPosition.text)+''''
+','''+Edt_RemArk.text+''''
+')';
AdoQry_tmp.ExecSQL;
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.SQL.Text:='Select @@identity as Bill_Id';
AdoQry_tmp.Open;
Bill_Id:=AdoQry_tmp.fieldbyname('Bill_Id').AsString;
end;
AdoQry_Body.First;
Bill_LineNo:=1;
while(not AdoQry_Body.Eof)do
begin
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.SQL.Text:='Insert InvInBillLine'+
'(InvBillId,InvBillLineNo,ItemCode,InvBillQty,BillLineRemArk,BatchNo)'+
'Values('
+''''+Bill_Id+''''
+','+IntToStr(Bill_LineNo)+''
+','''+AdoQry_Body.fieldbyname('ItemCode').AsString+''''
+','+AdoQry_Body.fieldbyname('InvBillQty').AsString+''
+','''+AdoQry_Body.fieldbyname('BillLineRemArk').AsString+''''
+','''+AdoQry_Body.fieldbyname('BatchNo').AsString+''''
+')';
AdoQry_tmp.ExecSQL;
Tempstr:=UpdateInv(AdoQry_tmp,
//AdoQry_Head.fieldbyname('WHCode').AsString,
//AdoQry_Head.fieldbyname('OWhPositionCode').AsString,
getCode(CmBx_OWarehouse.text),
getCode(CmBx_OWhPosition.text),
AdoQry_Body.fieldbyname('ItemCode').AsString,
'('+AdoQry_Body.fieldbyname('InvBillQty').AsString+')',
NeedChangePrice,True);
if Tempstr<>'' then
begin
DispStr:=Tempstr;
Abort;
end;
if AdoQry_Body.fieldbyname('BatchNo').AsString<>'' then
begin
if not BatchInvCheck(AdoQry_tmp,AdoQry_Body.fieldbyname('BatchNo').AsString,
'R',
//AdoQry_Head.fieldbyname('WHCode').AsString,
//AdoQry_Head.fieldbyname('OWhPositionCode').AsString,
getCode(CmBx_OWarehouse.text),
getCode(CmBx_OWhPosition.text),
AdoQry_Body.fieldbyname('InvBillQty').AsFloat)then
Abort;
ChangeBatchInv(AdoQry_tmp,AdoQry_Body.fieldbyname('BatchNo').AsString,
'R',MEdt_BillDate.Text,
//AdoQry_Head.fieldbyname('WHCode').AsString,
//AdoQry_Head.fieldbyname('OWhPositionCode').AsString,
getCode(CmBx_OWarehouse.text),
getCode(CmBx_OWhPosition.text),
AdoQry_Body.fieldbyname('InvBillQty').AsFloat);
end;
if True then //更改移动平均价格
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
' if not exists (select ItemCode from AveragePrice '+
' where whCode='''+getCode(CmBx_OWarehouse.text)+''''+
' and ItemCode='''+AdoQry_Body.fieldbyname('ItemCode').asstring+''')'+
' insert AveragePrice(whCode,ItemCode,Apqty) '+
' Values('''+getCode(CmBx_OWarehouse.text)+''','+
''''+AdoQry_Body.fieldbyname('ItemCode').asstring+''','+
'-('+AdoQry_Body.fieldbyname('InvBillQty').asstring+')) '+
' else '+
' update AveragePrice set '+
' Apqty=Apqty-('+AdoQry_Body.fieldbyname('InvBillQty').asstring+'),'+
//旧单价*新数量
' ApAmount=case when Apqty=0 then AveragePrice*(Apqty-('+AdoQry_Body.fieldbyname('InvBillQty').asstring+')) '+
' else (ApAmount/Apqty)*(Apqty-('+AdoQry_Body.fieldbyname('InvBillQty').asstring+')) end '+
' where whCode='''+getCode(CmBx_OWarehouse.text)+''''+
' and ItemCode='''+AdoQry_Body.fieldbyname('ItemCode').asstring+''''+
' update InvOutBillline set InvBillnotaxPrice=AveragePrice,'+
' InvBillnotaxAmount=InvBillqty*AveragePrice from AveragePrice'+
' where InvBillid='+Bill_id+' and AveragePrice.whCode='+QuotedStr(getCode(CmBx_OWarehouse.text))+
' and AveragePrice.ItemCode=InvOutBillline.ItemCode '+
' and InvOutBillline.ItemCode='+QuotedStr(AdoQry_Body.fieldbyname('ItemCode').asstring));
end;
AdoQry_Body.Next;
Bill_LineNo:=Bill_LineNo+1;
end;
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.SQL.Text:='Insert Inv_WhToWh'+
'(BillDate,'+
' BillNo,'+
' WHCode,'+
' WhPositionCode,'+
' ToWHCode,'+
' ToWhPositionCode,'+
' DeptCode,'+
' toDeptCode,'+
' InvInBillNo,'+
' InvOutBillNo,'+
' Create_EmployeeCode,'+
' RemArk,'+
' Create_Date )'+
'Values('
+''''+MEdt_BillDate.text+''''
+','''+Edt_BillNo.text+''''
+','''+getCode(CmBx_Warehouse.text)+''''
+','''+getCode(CmBx_WhPosition.text)+''''
+','''+getCode(CmBx_OWarehouse.text)+''''
+','''+getCode(CmBx_OWhPosition.text)+''''
+','''+LEdt_DeptCode.text+''''
+','''+LEdt_ToDeptCode.text+''''
+','''+IBill_No+''''
+','''+oBill_No+''''
+','''+UserCode+''''
+','''+Edt_RemArk.text+''''
+','''+formatdatetime('yyyy.mm.dd hh:mm:ss',now)+''''
+')';
AdoQry_tmp.ExecSQL;
DBConnect.CommitTrans;
AdoQry_Head.edit;
AdoQry_Head.fieldbyname('InvOutBillNo').AsString:=OBill_No;
AdoQry_Head.fieldbyname('InvInBillNo').AsString:=IBill_No;
AdoQry_Head.post;
AdoQry_Body.EnableControls ;
except
DBConnect.RollBackTrans;
DispInfo(DispStr,3);
AdoQry_Body.EnableControls ;
Abort;
end;
end;
procedure TFrm_Inv_Enter_WhToWh.SaveHeadData;
begin//把表头控件写入缓存,没Post
inherited;
with AdoQry_Head do
begin//把根据表头当前数据初始化,表头控件
fieldbyname('BillNo').asstring:=edt_Billno.text;
fieldbyname('WHCode').AsString:=getCode(CmBx_Warehouse.Text);
fieldbyname('WHName').AsString:=GetName(CmBx_Warehouse.Text);
fieldbyname('WhPositionCode').AsString:=getCode(CmBx_WhPosition.Text);
fieldbyname('WhPositionName').AsString:=GetName(CmBx_WhPosition.Text);
fieldbyname('ToWHCode').AsString:=getCode(CmBx_OWarehouse.Text);
fieldbyname('ToWHName').AsString:=getName(CmBx_OWarehouse.Text);
fieldbyname('ToWhPositionCode').AsString:=getCode(CmBx_OWhPosition.Text);
fieldbyname('TOWhPositionName').AsString:=GetName(CmBx_OWhPosition.Text);
fieldbyname('DeptCode').AsString:=LEdt_DeptCode.Text;
fieldbyname('DeptName').AsString:=Edt_DeptName.Text;
fieldbyname('ToDeptCode').AsString:=LEdt_TODeptCode.Text;
fieldbyname('ToDeptName').AsString:=Edt_ToDeptName.Text;
fieldbyname('BillDate').AsString:=MEdt_BillDate.Text;
fieldbyname('RemArk').AsString:=Edt_ReMArk.Text;
end;
end;
procedure TFrm_Inv_Enter_WhToWh.SetStatus(CurrentStatus: String;
var AnswerStatus, EnableControls: String);
begin
inherited;
if(CurrentStatus='Edit')then
begin
AnswerStatus:='ReadOnly';
EnableControls:='';
end
else if (CurrentStatus='Add') then
begin
AnswerStatus:='Add';
EnableControls:='Edt_RemArk,';
end;
end;
procedure TFrm_Inv_Enter_WhToWh.FormCreate(Sender: TObject);
begin
inherited;
Frm_Entry_Detail:=TFrm_Inv_Enter_WhToWh_D.Create(Self);
SetFocus_Control:=CmBx_Warehouse;
end;
procedure TFrm_Inv_Enter_WhToWh.CmBx_WarehouseChange(Sender: TObject);
begin
inherited;
AllChange(Sender);
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.SQL.Text:='Select WhPosition.WhPositionCode'
+'+'' ''+WhPosition.WhPositionName As WhPositionCodeName'
+' From WhPosition'
+' Where WhPosition.WHCode='''+GetCode(CmBx_Warehouse.Text)+''''
+' And WhPosition.WhPositionType<>1';
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);
//CmBx_OWhPosition.Items.Add(AdoQry_tmp.fieldbyname('WhPositionCodeName').AsString);
AdoQry_tmp.Next;
end;
InitCmBxText(CmBx_WhPosition,AdoQry_Head.fieldbyname('WhPositionCode').AsString);
//InitCmBxText(CmBx_OWhPosition,AdoQry_Head.fieldbyname('OWhPositionCode').AsString);
end;
procedure TFrm_Inv_Enter_WhToWh.CmBx_OWhPositionChange(Sender: TObject);
begin
inherited;
AllChange(Sender);
end;
procedure TFrm_Inv_Enter_WhToWh.CmBx_OWhPositionExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='ToolButton4' then
Abort;
if CmBx_OWhPosition.Text=CmBx_WhPosition.Text then
begin
DispInfo('移入货位不能与移出货位相同!',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_Enter_WhToWh.MEdt_BillDateExit(Sender: TObject);
begin
inherited;
DateCheck(Sender);
if WHClsPeriodCheck(AdoQry_tmp,GetCode(CmBx_Warehouse.Text),
Copy(TEdit(Sender).Text,1,7))=False then
begin
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_Enter_WhToWh.FormActivate(Sender: TObject);
begin
inherited;
//ToolButton4.left:=TlBtn_Print.left+ToolButton4.Width;
Act_Excel.Enabled :=False;
Act_Excel.Visible :=False;
end;
procedure TFrm_Inv_Enter_WhToWh.Act_PreviewExecute(Sender: TObject);
begin
//inherited;
//BillPrint(DBConnect,GetCode(CmBx_Warehouse.text),Edt_BillNo.text,'1101',ModuleCode,True,False,True,'');
if GetInvOutBillNo='' then
begin
DispInfo('此单没有保存不能打印预览',3);
abort;
end;
WhToWhBillPrint(DBConnect,GetCode(CmBx_Warehouse.text),GetInvOutBillNo,'1101',ModuleCode,True,False,True,'');
end;
procedure TFrm_Inv_Enter_WhToWh.Act_PrintExecute(Sender: TObject);
begin
//inherited;
//BillPrint(DBConnect,GetCode(CmBx_Warehouse.text),Edt_BillNo.text,'1101',ModuleCode,False,False,True,'');
if GetInvOutBillNo='' then
begin
DispInfo('此单没有保存不能打印览',3);
abort;
end;
WhToWhBillPrint(DBConnect,GetCode(CmBx_Warehouse.text),GetInvOutBillNo,'1101',ModuleCode,False,False,True,'');
end;
procedure TFrm_Inv_Enter_WhToWh.CmBx_OWarehouseExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='ToolButton4' then
Abort;
if CmBx_Warehouse.Text=CmBx_OWarehouse.Text then
begin
DispInfo('移入仓库不能与移出仓库相同!',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_Enter_WhToWh.CmBx_OWarehouseChange(Sender: TObject);
begin
inherited;
AllChange(Sender);
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.sql.Text:='Select WhPosition.WhPositionCode'
+'+'' ''+WhPosition.WhPositionName As WhPositionCodeName'
+' From WhPosition'
+' Where WhPosition.WHCode='''+GetCode(CmBx_oWarehouse.Text)+''''
+' And WhPosition.WhPositionType<>1';
AdoQry_tmp.Open;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -