📄 udmpo.pas
字号:
unit udmpo;
interface
uses
SysUtils, Classes, DB, DBClient;
type
TDMPO = class(TDataModule)
CPoMas: TClientDataSet;
CPoSub: TClientDataSet;
CPoMasPONo: TStringField;
CPoMasCategory: TStringField;
CPoMasVersion: TSmallintField;
CPoMasOrderDate: TDateTimeField;
CPoMasShipDate: TDateTimeField;
CPoMasStatus: TStringField;
CPoMasVenderID: TStringField;
CPoMasCurrencyID: TStringField;
CPoMasRate: TFloatField;
CPoMasTax: TFloatField;
CPoMasCarriage: TFloatField;
CPoMasAdjust: TFloatField;
CPoMasDiscount1: TFloatField;
CPoMasTotalMoney: TFloatField;
CPoMasRemark: TStringField;
CPoMasCreater: TStringField;
CPoMasCreateDate: TDateTimeField;
CPoMasUpdater: TStringField;
CPoMasUpDateDate: TDateTimeField;
CPoMasApprover: TStringField;
CPoMasApproveDate: TDateTimeField;
CPoMasConfirmer: TStringField;
CPoMasConfirmDate: TDateTimeField;
CPoMasPoSub: TDataSetField;
CPoMasVendorName: TStringField;
CPoMasCurrencyName: TStringField;
CPoSubPONo: TStringField;
CPoSubOrderNo: TStringField;
CPoSubPartNo: TStringField;
CPoSubUnitID: TStringField;
CPoSubQty: TFloatField;
CPoSubPrice: TFloatField;
CPoSubArriveQty: TFloatField;
CPoSubBackQty: TFloatField;
CPoSubArriveDate: TDateTimeField;
CPoSubShipDate: TDateTimeField;
CPoSubRemark: TMemoField;
CPoSubDiscount: TFloatField;
CPoSubSubtotal: TFloatField;
CPoSubPartNameC: TStringField;
CPoSubPartNameE: TStringField;
CPoSubModel: TStringField;
CPoSubColor: TStringField;
CPoSubUnitName: TStringField;
CPoMasDrawBill: TStringField;
CPoMasDeliver: TStringField;
CPoMasShipVia: TStringField;
CPoMasPayTerm: TStringField;
CPoMasPayMode: TStringField;
CPoMasCompanyFrom: TStringField;
CPoMasCompanyTO: TStringField;
CPoMasShipViaName: TStringField;
CPoMasPayTermName: TStringField;
CPoMasPayModeName: TStringField;
CPoMasCategoryName: TStringField;
CShipVia: TClientDataSet;
CShipViaItemType: TSmallintField;
CShipViaItemID: TStringField;
CShipViaItemName: TStringField;
CShipViaRemark: TStringField;
CPayMode: TClientDataSet;
CPayModeItemType: TSmallintField;
CPayModeItemID: TStringField;
CPayModeItemName: TStringField;
CPayModeRemark: TStringField;
CPayTerm: TClientDataSet;
CPayTermItemType: TSmallintField;
CPayTermItemID: TStringField;
CPayTermItemName: TStringField;
CPayTermRemark: TStringField;
CPoCategory: TClientDataSet;
SmallintField1: TSmallintField;
StringField7: TStringField;
StringField8: TStringField;
StringField9: TStringField;
CPoBase: TClientDataSet;
SmallintField2: TSmallintField;
StringField10: TStringField;
StringField11: TStringField;
StringField12: TStringField;
CStatPo: TClientDataSet;
CPoMasFinished: TBooleanField;
CPoSubDifferQty: TFloatField;
procedure CPoMasNewRecord(DataSet: TDataSet);
procedure CPoSubNewRecord(DataSet: TDataSet);
procedure CPoMasCurrencyIDChange(Sender: TField);
procedure CPoSubOrderNoValidate(Sender: TField);
procedure CPoSubPartNoValidate(Sender: TField);
procedure CPoBaseNewRecord(DataSet: TDataSet);
procedure CPoMasReconcileError(DataSet: TCustomClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
procedure CPoSubPartNoChange(Sender: TField);
procedure CPoMasDiscount1Validate(Sender: TField);
procedure CPoSubDiscountValidate(Sender: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
DMPO: TDMPO;
implementation
uses udata, udmbase, SherryLib;
{$R *.dfm}
procedure TDMPO.CPoMasNewRecord(DataSet: TDataSet);
begin
CPoMas['OrderDate']:=Date;
CPoMas['PONo']:=AutoPoNo;
CPoMas['Status']:='0';
CPoMas['Version']:=1;
CPoMas['Category']:=DMPO.CPoCategory['ItemID'];
CPoMas['CurrencyID']:=CurrencyID;
CPoMas['Rate']:=1;
CPoMas['ShipVia']:=DMPO.CShipVia['ItemID'];
CPoMas['PayMode']:=DMPO.CPayMode['ItemID'];
CPoMas['PayTerm']:=DMPO.CPayTerm['ItemID'];
CPoMas['DrawBill']:=DMBase.CCompany['CompanyID'];
CPoMas['Deliver']:=DMBase.CCompany['CompanyID'];
end;
procedure TDMPO.CPoSubNewRecord(DataSet: TDataSet);
begin
CPoSubPONo.Value:=CPoMasPONo.Value;
end;
procedure TDMPO.CPoMasCurrencyIDChange(Sender: TField);
begin
CPoMas['Rate']:=DMBase.CCurrency['Rate'];
end;
procedure TDMPO.CPoSubOrderNoValidate(Sender: TField);
begin
CheckOrderNo(TField(Sender).Value);
end;
procedure TDMPO.CPoSubPartNoValidate(Sender: TField);
begin
CheckPartNo(TField(Sender).Value);
end;
procedure TDMPO.CPoBaseNewRecord(DataSet: TDataSet);
begin
DataSet['ItemType']:=TClientDataSet(DataSet).Params.ParamValues['ItemType'];
end;
procedure TDMPO.CPoMasReconcileError(DataSet: TCustomClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
begin
If (UpdateKind=ukInsert) and (Pos(UpperCase('PK_POMas'),UpperCase(E.Message))>0) then
begin
Action:=raCorrect;
CPoMas.Edit;
CPoMas['PONo']:=AutoPoNo;
CPoMas.Post;
CPoMas.ApplyUpdates(0);
Info(Format('当前单号【%s】已经被占用,系统将自动变更为【%s】!',[DataSet.FieldByName('PONo').OldValue,CPoMas.FieldByName('PONo').NewValue]));
end
else AppException(E);
end;
procedure TDMPO.CPoSubPartNoChange(Sender: TField);
begin
CPoSub['UnitID'] := DMBase.CVMateriel['UnitID'];
end;
procedure TDMPO.CPoMasDiscount1Validate(Sender: TField);
begin
if CPoMas['Discount1']>100 then Error('折扣值必须介於0~100之间!');
end;
procedure TDMPO.CPoSubDiscountValidate(Sender: TField);
begin
if CPoSub['Discount']>100 then Error('折扣值必须介於0~100之间!');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -