📄 ydedformula.pas
字号:
unit YDEdFormula;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseVoucherEditA, Menus, ActnList, DB, ComCtrls, StdCtrls, Mask,
DBCtrls, ExtCtrls, ToolWin, Grids, DBGrids, QLDBGrid, ADODB, GEdit,
QLDBLkp, Buttons,TypInfo, QLDBFlt, QuickRpt, QRExtra, QLRptBld,WSEdit,
ImgList, WSCstFrm, QLDBCstVw;
type
TYDEdFormulaForm = class(TBaseVoucherEditAForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ClientName: TADODataSet;
EmployeeName: TADODataSet;
GoodName: TADODataSet;
GoodsOut: TADODataSet;
dsGoodsOut: TDataSource;
DSClientName: TDataSource;
DSEmployeeName: TDataSource;
ClientQLDBLookup: TQLDBLookupComboBox;
LookupEmployee: TQLDBLookupComboBox;
Label6: TLabel;
Label7: TLabel;
TempAds: TADODataSet;
adsMaster: TADODataSet;
adsDetail: TADODataSet;
adsDetailID: TAutoIncField;
adsDetailMasterID: TIntegerField;
adsDetailGoodsID: TIntegerField;
adsDetailQuantity: TBCDField;
adsDetailPackUnitID: TIntegerField;
adsDetailPriceBase: TBCDField;
adsDetailAmount: TBCDField;
adsDetailDiscount: TBCDField;
adsDetailGoalQuantity: TBCDField;
adsDetailSundryFee: TBCDField;
adsDetailGoalUnitID: TIntegerField;
adsMasterID: TAutoIncField;
adsMasterCreateDate: TDateTimeField;
adsMasterCreateUserID: TIntegerField;
adsMasterRecordState: TStringField;
adsMasterDate: TDateTimeField;
adsMasterCode: TStringField;
adsMasterClientID: TIntegerField;
adsMasterBillMode: TStringField;
adsMasterPeriodID: TIntegerField;
adsMasterClearDate: TDateTimeField;
adsMasterMemo: TStringField;
adsMasterSundryFee: TBCDField;
Label8: TLabel;
adsMasterClientName: TStringField;
adsDetailGoodsName: TStringField;
DiscountMode: TAction;
adsMasterEmployeeID: TIntegerField;
adsMasterApportion: TStringField;
adsMasterDeliver: TStringField;
adsMasterOriginID: TIntegerField;
adsMasterOriginTable: TStringField;
adsMasterBillAffix: TBytesField;
adsDetailMemo: TStringField;
adsMasterBrief: TStringField;
DbCBxBillMode: TDBComboBox;
Label9: TLabel;
DBEdit2: TDBEdit;
DBEdit4: TDBEdit;
Label4: TLabel;
DBEdit5: TDBEdit;
adsDetailTaxAmount: TBCDField;
LookGoodsOut: TQLDBLookupComboBox;
adsGoodsSpec: TADODataSet;
dsGoodName: TDataSource;
adsMasterEmployee: TStringField;
GoalUnit: TADODataSet;
dsGoalUnit: TDataSource;
adsMasterModeDC: TIntegerField;
adsMasterModeC: TIntegerField;
adsMasterWarehouseID: TIntegerField;
DBCBxBrief: TDBComboBox;
adsGoodsSpecID: TAutoIncField;
adsGoodsSpecCreateDate: TDateTimeField;
adsGoodsSpecCreateUserID: TIntegerField;
adsGoodsSpecRecordState: TStringField;
adsGoodsSpecUpid: TIntegerField;
adsGoodsSpecName: TStringField;
adsGoodsSpecMemo: TStringField;
adsGoodsSpecLevelCode: TStringField;
adsDetailGoodsOutID: TIntegerField;
AdsPackunit: TADODataSet;
dsPackunit: TDataSource;
adsDetailPackUnitName: TStringField;
adsDetailGoalUnitName: TStringField;
adsDetailGoodsOut: TStringField;
SpeedButton1: TSpeedButton;
adsDetailGoodsSpec: TStringField;
DataSource1: TDataSource;
adsDetailQuantityPcs: TBCDField;
CALCosttipPanel: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
adsDetailPriceCost: TBCDField;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
FormulaAssembleAct: TAction;
FormulaAssemblePanel: TPanel;
OKORCancelPanel: TPanel;
OKBitBtn: TBitBtn;
CanelBitBtn: TBitBtn;
N41: TMenuItem;
FormulaAssembleADS: TADODataSet;
FormulaAssembleDS: TDataSource;
FormulaAssembleGrd: TQLDBGrid;
FormulaAssembleADSID: TAutoIncField;
FormulaAssembleADSDSDesigner: TStringField;
FormulaAssembleADSDSDesigner2: TStringField;
FormulaAssembleADSDSDesigner3: TStringField;
FormulaAssembleADSDSDesigner4: TDateTimeField;
FormulaAssembleADSDSDesigner5: TStringField;
FormulaAssembleADSDSDesigner6: TBCDField;
FormulaAssembleADSDSDesigner7: TStringField;
FormulaAssembleADSDSDesigner8: TStringField;
FormulaAssembleADSGoodsID: TIntegerField;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure adsDetailGoodsOutIDChange(Sender: TField);
procedure adsDetailQuantityChange(Sender: TField);
procedure adsDetailGoodsIDChange(Sender: TField);
procedure adsDetailPriceBaseChange(Sender: TField);
procedure GoodsLookupButtonClick(Sender: TObject;
Button: TLookupWindowBtn);
procedure LookGoodsOutButtonClick(Sender: TObject;
Button: TLookupWindowBtn);
procedure SpeedButton1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure UpdateGrid(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure FormulaAssembleActExecute(Sender: TObject);
procedure OKBitBtnClick(Sender: TObject);
procedure CanelBitBtnClick(Sender: TObject);
procedure FormulaAssembleGrdTitleClick(Column: TColumn);
private
FAllowSort: Boolean;
{ Private declarations }
public
SLPubQuerrySql,SLPubQuerryCaption:string;
{ Public declarations }
procedure Open(VoucherID: Integer); override;
procedure New; override;
end;
var
YDEdFormulaForm: TYDEdFormulaForm;
implementation
uses CommonDM, WSUtils, WSSecurity;
{$R *.dfm}
procedure TYDEdFormulaForm.New;
begin
inherited;
adsMaster.FieldByName('Date').AsDateTime:=date;
adsMaster.FieldByName('Code').AsString:=GetMaxCode('Code','YDFormulaMaster',number);
adsMaster.FieldByName('CreateUserID').AsInteger:=Guarder.UserID;
adsMaster.FieldByName('BillMode').AsString:='基础配料清单';
adsMaster.FieldByName('ModeDC').AsFloat:=1;
adsMaster.FieldByName('ModeC').AsFloat:=1;
adsMaster.FieldByName('Deliver').AsString:='--';
adsMaster.FieldByName('Apportion').AsString:='--';
adsMaster.FieldByName('ClearDate').AsDateTime:=date;
adsMaster.FieldByName('OriginTable').AsString:='YDFormulaMaster';
end;
procedure TYDEdFormulaForm.Open(VoucherID: Integer);
begin
inherited Open(VoucherID);
end;
procedure TYDEdFormulaForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
adsMaster.Close;
adsDetail.Close;
ClientName.Close;
EmployeeName.Close;
GoodName.Close;
GoodsOut.Close;
adsGoodsSpec.Close;
end;
procedure TYDEdFormulaForm.FormCreate(Sender: TObject);
var GoodsSpecStr:string;
begin
inherited;
VoucherTableName := 'YDFormula';
adsMaster.Open;
adsDetail.Open;
ClientName.Open;
EmployeeName.Open;
GoodName.Open;
GoodsOut.Open;
TempAds.close;
TempAds.CommandText :='select distinct levelcode from DAAttribute'
+' where name like'+Quotedstr('%商品%')+' and upid=-1';
TempAds.open;
TempAds.First;
GoodsSpecStr :=' where (1<>1 ';
while not TempAds.Eof do
begin
GoodsSpecStr :=GoodsSpecStr+' or Levelcode like '+Quotedstr('%'+
Trim(TempAds.fieldbyname('Levelcode').AsString)+'%') ;
TempAds.Next;
end;
GoodsSpecStr :=' select * from DAAttribute '+ GoodsSpecStr
+' ) and (upid<>-1 and Recordstate<>'+Quotedstr('删除')+')';
adsGoodsSpec.Close;
adsGoodsSpec.CommandText :=GoodsSpecStr;
adsGoodsSpec.Open;
adsGoodsSpec.First;
TempAds.Close;
TempAds.CommandText :=' select Distinct BillMode from YDFormulaMaster';
TempAds.Open;
TempAds.First;
while not TempAds.Eof do
begin
DBCBxBillMode.Items.Add(TempAds.FieldByName('BillMode').AsString);
TempAds.Next;
end;
if TempAds.IsEmpty then DBCBxBillMode.Items.Add('基础配料清单');
TempAds.Close;
TempAds.CommandText :=' select Distinct brief from YDFormulaMaster';
TempAds.Open;
TempAds.First;
while not TempAds.Eof do
begin
DBCBxBrief.Items.Add(TempAds.FieldByName('brief').AsString);
TempAds.Next;
end;
if TempAds.IsEmpty then DBCBxBrief.Items.Add('基础配料清单');
end;
procedure TYDEdFormulaForm.adsDetailGoodsIDChange(Sender: TField);
begin
inherited;
DBGrid.Columns.ColumnByFieldName('PackUnitName').ReadOnly :=false;
adsDetail.FieldByName('PackUnitID').AsInteger :=GoodName.fieldbyname('UnitID').AsInteger;
if adsDetail.FieldByName('PackUnitID').IsNull then adsDetail.FieldByName('PackUnitID').AsInteger :=0;
DBGrid.Columns.ColumnByFieldName('PackUnitName').ReadOnly :=true;
adsDetail.FieldByName('PriceBase').AsFloat :=GoodName.fieldbyname('PricePurchase').AsFloat;
if (adsDetail.FieldByName('Quantity').AsFloat =0) or (adsDetail.FieldByName('Quantity').IsNull) then
adsDetail.FieldByName('Quantity').AsFloat :=1;
if adsDetail.FieldByName('Quantity').IsNull then adsDetail.FieldByName('Quantity').AsInteger:=1;
end;
procedure TYDEdFormulaForm.adsDetailQuantityChange(Sender: TField);
begin
inherited;
adsDetail.Edit;
adsDetail.FieldByName('Amount').AsFloat :=
adsDetail.fieldbyname('Quantity').asfloat
*adsDetail.fieldbyname('PriceBase').AsFloat;
end;
procedure TYDEdFormulaForm.adsDetailGoodsOutIDChange(Sender: TField);
begin
inherited;
adsDetail.Edit;
DBGrid.Columns.ColumnByFieldName('GoalUnitName').ReadOnly :=false;
adsDetail.FieldByName('GoalUnitID').AsInteger :=GoodsOut.fieldbyname('UnitID').AsInteger;
if adsDetail.FieldByName('GoalUnitID').IsNull then
adsDetail.FieldByName('GoalUnitID').AsInteger :=0;
DBGrid.Columns.ColumnByFieldName('GoalUnitName').ReadOnly :=true;
if (adsDetail.FieldByName('GoalQuantity').IsNull) or (adsDetail.FieldByName('GoalQuantity').AsFloat=0) then
adsDetail.FieldByName('GoalQuantity').AsInteger :=1;
end;
procedure TYDEdFormulaForm.adsDetailPriceBaseChange(Sender: TField);
begin
inherited;
adsDetail.Edit;
adsDetail.FieldByName('Amount').AsFloat :=
adsDetail.fieldbyname('Quantity').asfloat
*adsDetail.fieldbyname('PriceBase').AsFloat;
end;
procedure TYDEdFormulaForm.GoodsLookupButtonClick(Sender: TObject;
Button: TLookupWindowBtn);
begin
inherited;
adsDetail.Edit;
adsDetail.FieldByName('GoodsID').AsInteger :=0;
adsDetail.FieldByName('Quantity').Value :=null;
adsDetail.FieldByName('PackUnitID').AsInteger :=0;
adsDetail.FieldByName('PriceBase').Value :=Null;
adsDetail.FieldByName('Amount').Value :=Null;
end;
procedure TYDEdFormulaForm.LookGoodsOutButtonClick(Sender: TObject;
Button: TLookupWindowBtn);
begin
inherited;
adsDetail.Edit;
adsDetail.FieldByName('GoodsOutID').AsInteger :=0;
adsDetail.FieldByName('GoalUnitID').AsInteger :=0;
adsDetail.FieldByName('GoalQuantity').Value :=null;
adsDetail.FieldByName('SundryFee').value :=null;
adsDetail.FieldByName('QuantityPcs').Value :=null;
adsDetail.FieldByName('TaxAmount').Value :=null;
end;
procedure TYDEdFormulaForm.SpeedButton1Click(Sender: TObject);
var TQuan,Tamount,TaxAmount:real;
I:integer;
begin
inherited;
CALCosttipPanel.Visible :=true;
CALCosttipPanel.Repaint;
DBGrid.DataSource :=nil;
adsDetail.First;
TQuan :=0;
Tamount :=0;
while not adsDetail.Eof do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -