📄 sal_enter_passbackshiporder.pas
字号:
unit Sal_Enter_PassBackShipOrder;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Check_Body, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, Mask, ExtEdit, jpeg, linkedit;
Type
TFrm_Sal_Enter_PassBackShipOrder = Class(TFrm_Base_Check_Body)
Label4: TLabel;
Edt_ShipNo: TEdit;
Label5: TLabel;
Edt_SaleTypeCode: TExtEdit;
Label15: TLabel;
Label3: TLabel;
MEdt_CreateDate: TMaskEdit;
Label8: TLabel;
Edt_CurrencyCode: TExtEdit;
Lab_CurrencyName: TLabel;
Label6: TLabel;
Edt_SaleDeptCode: TExtEdit;
Lab_SaleDeptName: TLabel;
Label9: TLabel;
Edt_TaxRate_Percent: TEdit;
Label16: TLabel;
Edt_TotalNoTaxAmount: TEdit;
Label17: TLabel;
Edt_TotalTaxAmount: TEdit;
Edt_ShipModeCode: TExtEdit;
Label12: TLabel;
Label2: TLabel;
Edt_InvoiceNo: TEdit;
Label18: TLabel;
Cx_Assess: TComboBox;
Edt_AssessorEmployeeCode: TEdit;
Label19: TLabel;
Label11: TLabel;
Edt_SaleTermCode: TExtEdit;
Label10: TLabel;
Edt_SaleEmployeeCode: TExtEdit;
Label7: TLabel;
Label1: TLabel;
Edt_CustomerCode: TExtEdit;
Label13: TLabel;
Edt_ShipAddresSCode: TExtEdit;
Label14: TLabel;
Edt_RemArk: TEdit;
Lab_SaleEmployeeName: TLabel;
Lab_SaleTermName: TLabel;
Edt_CreateEmployeeCode: TExtEdit;
Label20: TLabel;
edt_PayTermName: TExtEdit;
edt_DeptName: TExtEdit;
edt_SaleTypeName: TExtEdit;
edt_CustomerName: TExtEdit;
edt_SaleEmployeeName: TExtEdit;
edt_CurrencyName: TExtEdit;
edt_AddressName: TExtEdit;
edt_CreateName: TExtEdit;
edt_ShipModeName: TExtEdit;
edt_assessName: TEdit;
Label21: TLabel;
Edt_WhCode: TLinkEdit;
Edt_WhName: TEdit;
Edt_WhPositionName: TEdit;
Edt_WhPositionCode: TLinkEdit;
Label22: TLabel;
AdoQry_BodyInvBillNo: TStringField;
AdoQry_BodyInvBillId: TFloatField;
AdoQry_BodyInvBillLineNo: TStringField;
AdoQry_BodySloNo: TStringField;
AdoQry_BodySloLineNo: TIntegerField;
AdoQry_BodyBatchNo: TStringField;
AdoQry_BodyItemCode: TStringField;
AdoQry_BodyItemName: TStringField;
AdoQry_BodyItemflag: TStringField;
AdoQry_BodyUomName: TStringField;
AdoQry_BodyWhCode: TStringField;
AdoQry_BodyWhName: TStringField;
AdoQry_Bodywhflag: TStringField;
AdoQry_BodyWhPositionCode: TStringField;
AdoQry_BodyWhPositionName: TStringField;
AdoQry_BodyWhPositionflag: TStringField;
AdoQry_BodyInvBillQty: TFloatField;
AdoQry_BodyInvBillPrice: TFloatField;
AdoQry_BodyInvBillAmount: TFloatField;
AdoQry_BodyInvBillNoTaxPrice: TFloatField;
AdoQry_BodyInvBillNoTaxAmount: TFloatField;
AdoQry_BodyDiSCountRate: TFloatField;
AdoQry_BodyDiSCountAmount: TFloatField;
AdoQry_BodyBillLineRemArk: TStringField;
procedure Act_CheckExecute(Sender: TObject);
procedure Act_CancelCheckExecute(Sender: TObject);
procedure AdoQry_BodyAfterPost(DataSet: TDataSet);
procedure AdoQry_BodyBeforeInsert(DataSet: TDataSet);
procedure AdoQry_BodyInvBillQtyGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
procedure AdoQry_BodyInvBillAmountGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
procedure AdoQry_BodyInvBillNoTaxAmountGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
procedure AdoQry_BodyDiSCountAmountGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
private
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;FormStatus:String;
AdoQuery:TAdoQuery);Override;
procedure InitControls; Override;
{ Public declarations }
function judgeShipqty:boolean;
function Addqty:boolean;
Function CreateOutBill(ShipNo:String):Integer; //返回新产生单据的id号
end;
var
Frm_Sal_Enter_PassBackShipOrder: TFrm_Sal_Enter_PassBackShipOrder;
slono:string;
slolineno:integer;
implementation
uses Sys_Global;
{$R *.DFM}
{ TFrm_Sa_Enter_PassShipOrder }
procedure TFrm_Sal_Enter_PassBackShipOrder.InitControls;
begin
inherited;
end;
procedure TFrm_Sal_Enter_PassBackShipOrder.InitForm(
AdOConnection: TAdOConnection; FormStatus: String; AdoQuery: TAdoQuery);
var
SqlText:string;
begin
inherited;
With AdoQuery do
begin
Edt_ShipNo.Text :=fieldbyname('InvBillNo').AsString;
Edt_CustomerCode.Text:=fieldbyname('CustomerCode').AsString;
Edt_CustomerName.text:=fieldbyname('CustomerName').AsString;
Edt_CreateEmployeeCode.Text:=fieldbyname('Sal_EmployeeCode').AsString;
edt_CreateName.Text:=fieldbyname('createEmployeeName').asstring;
MEdt_CreateDate.Text:=Formatdatetime('yyyy.mm.dd',fieldbyname('InvBillDate').asdatetime);
Edt_SaleDeptCode.Text:=fieldbyname('DeptCode').AsString;
edt_DeptName.Text:=fieldbyname('DeptName').asstring;
Edt_SaleTypeCode.Text:=fieldbyname('SaleType').AsString;
edt_SaleTypeName.Text:=fieldbyname('SaleTypeName').asstring;
Edt_SaleEmployeeCode.Text:=fieldbyname('SaleEmployeeCode').AsString;
edt_SaleEmployeeName.Text:=fieldbyname('SaleEmployeeName').asstring;
Edt_CurrencyCode.Text:=fieldbyname('CurrencyCode').AsString;
edt_CurrencyName.Text:=fieldbyname('currencyName').asstring;
Edt_WhCode.Text := fieldbyname('WhCode').AsString;
Edt_WhName.Text := fieldbyname('WhName').AsString;
Edt_WhPositionCode.Text := fieldbyname('WhPositionCode').AsString;
Edt_WhPositionName.Text := fieldbyname('WhPositionName').AsString;
Edt_TaxRate_Percent.Text:=fieldbyname('InvBillTaxRate').AsString;
Edt_ShipModeCode.Text:=fieldbyname('ShipModeCode').AsString;
edt_ShipModeName.Text:=fieldbyname('ShipModeName').asstring;
Edt_ShipAddresSCode.Text:=fieldbyname('ShipAddresSCode').AsString;
edt_AddressName.Text:=fieldbyname('ShipAddressName').asstring;
Edt_SaleTermCode.Text:=fieldbyname('PayTermCode').AsString;
edt_PayTermName.Text:=fieldbyname('PayTermName').asstring;
Edt_RemArk.Text:=fieldbyname('RemArk').AsString;
Edt_TotalNoTaxAmount.Text:=FloatToStr(-fieldbyname('TotalInvBillNoTaxAmount').AsFloat);
Edt_TotalTaxAmount.Text:=FloatToStr(-fieldbyname('TotalInvBillAmount').AsFloat);
Edt_InvoiceNo.Text:=fieldbyname('InvoiceNo').AsString;
Edt_AssessorEmployeeCode.Text:=fieldbyname('Wh_EmployeeCode').AsString;
edt_assessName.Text:=fieldbyname('assessName').asstring;
Cx_Assess.ItemIndex :=fieldbyname('InvBillWhChCk').AsInteger;
SqlText:=' Select InvOutBill.InvBillNo,InvOutBillLine.InvBillId,InvOutBillLine.InvBillLineNo,InvOutBillLine.SloNo,'
+' InvOutBillLine.SloLineNo,BatchNo, '
+' InvOutBillLine.ItemCode,ItemName, '
+' InvOutBillLine.ItemCode+'' ''+Item.ItemName as Itemflag, '
+' UomName, '
+' InvOutBill.WhCode,WhName, '
+' InvOutBill.whCode+'' ''+Warehouse.whName as whflag, '
+' InvOutBill.WhPositionCode,WhPositionName, '
+' InvOutBill.WhPositionCode+'' ''+WhPosition.WhPositionName as WhPositionflag, '
+' InvBillQty, InvBillPrice,InvBillAmount,InvBillNoTaxPrice,InvBillNoTaxAmount, '
+' InvOutBillLine.DiSCountRate,InvOutBillLine.DiSCountAmount,BillLineRemArk '
+' From InvOutBillLine '
+' Join InvOutBill on InvOutBillLine.InvBillId = InvOutBill.InvBillId '
+' Left Join Item '
+' On Item.ItemCode=InvOutBillLine.ItemCode '
+' Left Join Uom '
+' On Item.UomCode=Uom.UomCode'
+' Left Join Warehouse'
+' On InvOutBill.WhCode=Warehouse.WhCode'
+' Left Join WhPosition '
+' On (WhPosition.WhPositionCode=InvOutBill.WhPositionCode)'
+' and (WhPosition.WhCode=InvOutBill.WhCode)'
+' where InvBillNo= '''+fieldbyname('InvBillNo').AsString+''' ' ;
AdoQry_Body.Close;
AdoQry_Body.SQL.Text:=SqlText;
AdoQry_Body.Open;
end ;
end;
procedure TFrm_Sal_Enter_PassBackShipOrder.Act_CheckExecute(Sender: TObject);
var SqlText:String;
begin
inherited;
If (AdoQry_Head.Eof) And (AdoQry_Head.Bof) Then
Exit;
If Cx_Assess.ItemIndex = 1 then exit;
If (DispInfo('确认真的要审核这张销售退货单吗?',2)<>'y') Then exit;
try
Dbconnect.beginTrans ;
If AdoQry_Body.State in [dsinsert,dsedit] then
AdoQry_Body.Post;
judgeShipqty;
// saveBackShipOrderHistory(dbconnect,edt_Shipno.Text,userCode,3);
SQlText:=' UpDate InvOutBill Set InvBillWhChCk=1, '
+' Wh_EmployeeCode='''+UserCode+''' Where InvBillNo='''+Edt_ShipNo.Text+''' ';
AdoQry_Tmp.Close;
AdoQry_Tmp.sql.clear ;
AdoQry_Tmp.SQL.Text := SqlText;
AdoQry_Tmp.ExecSQL ;
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('InvBillWhChCk').AsInteger:=1;
AdoQry_Head.fieldbyname('Wh_EmployeeCode').AsString:=UserCode;
AdoQry_Head.Post;
Cx_Assess.ItemIndex :=1;
Edt_AssessorEmployeeCode.Text := userCode;
Executesql(AdoQry_tmp,'select EmployeeName from Employee where EmployeeCode='+quotedstr(userCode),0);
edt_assessName.Text:=AdoQry_tmp.fieldbyname('EmployeeName').asstring;
SqlText:=' Update customer With(RowLock) '
+' Set BackShipSumTotal=IsNull(BackShipSumTotal,0)+(-('+Edt_TotalTaxAmount.Text+'))'
+' where CustomerCode='+QuotedStr(Edt_CustomerCode.Text);
Executesql(AdoQry_Tmp,SqlText,1) ;
CreateOutBill(Edt_ShipNo.Text);
If dbconnect.InTransaction then
Dbconnect.CommitTrans;
DispInfo('核定成功!',3);
except
if dbconnect.InTransaction then dbconnect.RollBackTrans;
DispInfo('核定失败!',3);
end;
end;
function TFrm_Sal_Enter_PassBackShipOrder.CreateOutBill(
ShipNo: String): Integer;//ShipNo : 发货单号
var AdoQry : TAdoQuery;
SqlText : String;
OutBillNo : String; //出库单号
InvBillId : Integer; //出库单id号
begin
Result := 0;
{产生一张仓库出库单,内容和销售发货单一样}
AdoQry := TAdoQuery.Create(self);
AdoQry.Connection := Dbconnect;
AdoQry.EnableBCD := False;
Try
OutBillNo:=getno(dbConnect,Edt_WhCode.Text+'C'+copy(medt_Createdate.text,3,2)+copy(medt_Createdate.text,6,2)
,'InvBill' );
SqlText:='Insert InvOutBill '
+' (InvBillNo,InvBillDate,InvBillMonth,InvBillCreateTime,Sal_EmployeeCode,SaleEmployeeCode,DeptCode, '
+' CustomerCode,WhCode,WhPositionCode,ShipAddresSCode,ShipModeCode,SaleType,BillTypeCode,CurrencyCode,'
+' PayTermCode,InvBillTaxRate,ExchRate,TotalInvBillNoTaxAmount,TotalInvBillAmount, TotalInvBillNoTaxAmountC, '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -