?? sledsale.pas
字號:
unit SLEdSale;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseVoucherEdit, Menus, ActnList, DB, ComCtrls, StdCtrls, Mask,
DBCtrls, ExtCtrls, ToolWin, Grids, DBGrids, QLDBGrid, ADODB, GEdit,
QLDBLkp, QuickRpt;
type
TSLEdSaleForm = class(TBaseVoucherEditForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ClientName: TADODataSet;
EmployeeName: TADODataSet;
GoodName: TADODataSet;
Label5: TLabel;
PackUnit: TADODataSet;
dsPackUnit: TDataSource;
DSClientName: TDataSource;
DSEmployeeName: TDataSource;
ClientQLDBLookup: TQLDBLookupComboBox;
LookupEmployee: TQLDBLookupComboBox;
Label6: TLabel;
Label7: TLabel;
LookupPackUint: TQLDBLookupComboBox;
TempAds: TADODataSet;
adsMaster: TADODataSet;
adsDetail: TADODataSet;
adsDetailID: TAutoIncField;
adsDetailMasterID: TIntegerField;
adsDetailGoodsID: TIntegerField;
adsDetailQuantity: TBCDField;
adsDetailQuantityPcs: 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;
adsDetailPackUnit: TStringField;
DiscountMode: TAction;
adsMasterEmployeeID: TIntegerField;
adsMasterApportion: TStringField;
adsMasterDeliver: TStringField;
adsMasterOriginID: TIntegerField;
adsMasterOriginTable: TStringField;
adsMasterBillAffix: TBytesField;
adsDetailMemo: TStringField;
adsMasterBrief: TStringField;
BriefComboBox: TDBComboBox;
Label9: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
Label10: TLabel;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
Label4: TLabel;
DBEdit5: TDBEdit;
GEdit1: TGEdit;
adsDetailTaxAmount: TBCDField;
adsDetailGoodsSpec: TStringField;
adsGoodsSpec: TADODataSet;
dsGoodsSpec: TDataSource;
adsMasterEmployee: TStringField;
GoalUnit: TADODataSet;
dsGoalUnit: TDataSource;
adsDetailGoalUnit: TStringField;
adsMasterModeDC: TIntegerField;
adsMasterModeC: TIntegerField;
adsMasterWarehouseID: TIntegerField;
TempActualCost: TADODataSet;
adsDetailPriceCost: TBCDField;
adsDetailGoodsName: TStringField;
FillInPrintAction: TAction;
FillInPrintMenu: TMenuItem;
NoCreditSale: TCheckBox;
ADODataSet1: TADODataSet;
PackUintFltAQ: TADODataSet;
PackUintFltDS: TDataSource;
adsDetailPriceGoal: TBCDField;
DBEdit6: TDBEdit;
adsMasterCashDiscount: TBCDField;
DiscountTempAct: TMenuItem;
adsDetailPriceRate: TFloatField;
adsDetailDiscountAmount: TFloatField;
adsDetailPriceStandard: TFloatField;
RepeatPrintAction: TAction;
RepeatPrintMenu: TMenuItem;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure adsDetailQuantityChange(Sender: TField);
procedure adsDetailGoodsIDChange(Sender: TField);
procedure ClientQLDBLookupEnter(Sender: TObject);
procedure ClientQLDBLookupExit(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormDeactivate(Sender: TObject);
procedure FillInPrintActionExecute(Sender: TObject);
procedure LookupPackUintEnter(Sender: TObject);
procedure NoCreditSaleClick(Sender: TObject);
procedure LookupPackUintExit(Sender: TObject);
procedure adsDetailPackUnitIDChange(Sender: TField);
procedure DBEdit6Enter(Sender: TObject);
procedure DiscountTempActClick(Sender: TObject);
procedure RepeatPrintActionExecute(Sender: TObject);
private
{ Private declarations }
protected
function CreateReport: TQuickRep; override;
procedure InternalSave; override;
public
SLPubQuerrySql,SLPubQuerryCaption,NewOrEditFlag:string;
PriceBeforeDiscount,ReplacePoint:Real;
{ Public declarations }
procedure Open(VoucherID: Integer); override;
procedure New; override;
end;
var
SLEdSaleForm: TSLEdSaleForm;
implementation
uses CommonDM, WSUtils, WSSecurity, SLRpSale, BaseVoucherRpt, CRCtrls, Math, QLDBAgg;
{$R *.dfm}
procedure TSLEdSaleForm.New;
begin
inherited;
adsMaster.FieldByName('Date').AsDateTime:=Date;
adsMaster.FieldByName('Code').AsString:=GetMaxCode('Code','SLSaleMaster',number);
adsMaster.FieldByName('CreateUserID').AsInteger :=Guarder.UserID;
adsMaster.FieldByName('BIllMode').ReadOnly :=False;
if NoCreditSale.Checked then adsMaster.FieldByName('BillMode').AsString:='現款銷售'
else adsMaster.FieldByName('BillMode').AsString:='銷售開單';
adsMaster.FieldByName('ModeDC').AsInteger :=1;
adsMaster.FieldByName('ModeC').AsInteger :=1;
adsMaster.FieldByName('Deliver').AsString:='--';
adsMaster.FieldByName('Apportion').AsString:='--';
adsMaster.FieldByName('OriginTable').AsString:='SLSaleMaster';
NewOrEditFlag :='新增狀態';
end;
procedure TSLEdSaleForm.Open(VoucherID: Integer);
var
SaveOnClick: TNotifyEvent;
begin
inherited Open(VoucherID);
SaveOnClick := NoCreditSale.OnClick;
NoCreditSale.OnClick := nil;
if Trim(adsMaster.FieldByName('BillMode').AsString)='現款銷售' then
NoCreditSale.Checked :=True
else NoCreditSale.Checked :=False;
NoCreditSale.OnClick := SaveOnClick;
end;
procedure TSLEdSaleForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
adsMaster.Close;
adsDetail.Close;
ClientName.Close;
EmployeeName.Close;
GoodName.Close;
PackUnit.Close;
adsGoodsSpec.Close;
end;
procedure TSLEdSaleForm.FormCreate(Sender: TObject);
var GoodsSpecStr:string;
begin
inherited;
VoucherTableName := 'SLSale';
ClientName.Open;
EmployeeName.Open;
GoodName.Open;
PackUnit.Open;
PackUintFltAQ.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;
TempAds.Close;
TempAds.CommandText :=' select Distinct brief from SLSaleMaster';
TempAds.Open;
TempAds.First;
while not TempAds.Eof do
begin
BriefComboBox.Items.Add(TempAds.FieldByName('brief').AsString);
TempAds.Next;
end;
if TempAds.IsEmpty then BriefComboBox.Items.Add('銷售');
NewOrEditFlag :='編輯狀態';
end;
procedure TSLEdSaleForm.adsDetailGoodsIDChange(Sender: TField);
var SGoodsID,SClientID:integer;
begin
inherited;
if (adsDetail.fieldbyname('GoodsID').IsNull) then exit;
SGoodsID :=adsDetail.fieldbyname('GoodsID').AsInteger;
if (adsMaster.fieldbyname('ClientID').IsNull) then SClientID :=0
else SClientID :=adsMaster.fieldbyname('ClientID').AsInteger;
TempAds.Close;
TempAds.CommandText :=' select ID,UnitID from DAGoods where ID='+inttostr(SGoodsID);
TempAds.Open;
if (TempAds.FieldByName('UnitID').IsNull) then
begin
adsDetail.FieldByName('GoalUnitID').AsInteger :=1;
adsDetail.FieldByName('PackUnitID').AsInteger :=1;
end else
begin
adsDetail.FieldByName('GoalUnitID').AsInteger :=TempAds.FieldByName('UnitID').AsInteger;
adsDetail.FieldByName('PackUnitID').AsInteger :=TempAds.FieldByName('UnitID').AsInteger;
end;
TempActualCost.Close;
TempActualCost.CommandText :=' select CostPrice from #TpCostPrice'
+' where GoodsID= '+ Inttostr(SGoodsID) ;
TempActualCost.Open;
adsDetail.FieldByName('PriceCost').AsFloat := TempActualCost.FieldByName('CostPrice').AsFloat ;
if Guarder.ContractSLPrice='是' then
begin
TempAds.Close; //取當前客戶的合同售價
TempAds.CommandText :=' SELECT b.Date,a.PriceGoal '
+' FROM SLContractPriceDetail a '
+' LEFT JOIN SLContractPriceMaster b on b.ID=a.MasterID '
+' where b.RecordState<>'+Quotedstr('刪除')
+' and b.RecordState<>'+Quotedstr('作廢')
+' and a.GoodsID='+inttostr(SGoodsID)
+' and b.ClientID='+inttostr(SClientID)
+' order by b.Date DESC ';
TempAds.Open;
end else
begin
TempAds.Close; //取當前客戶的合同售價和標準單位
TempAds.CommandText :=' SELECT b.Date,a.PriceGoal '
+' FROM SLContractPriceDetail a '
+' LEFT JOIN SLContractPriceMaster b on b.ID=a.MasterID '
+' where 1=2 ' ;
TempAds.Open;
end;
if (Guarder.LastadjustSLPrice='是') and (TempAds.IsEmpty) then
begin
TempAds.Close; //取當前商品的最新調價
TempAds.CommandText :=' SELECT b.Date,a.PriceGoal '
+' FROM SLSalePriceDetail a '
+' LEFT JOIN SLSalePriceMaster b on b.ID=a.MasterID '
+' where b.RecordState<>'+Quotedstr('刪除')
+' and b.RecordState<>'+Quotedstr('作廢')
+' and a.GoodsID='+inttostr(SGoodsID)
+' order by b.Date DESC ';
TempAds.Open;
// Memo1.Text := TempAds.CommandText;
end;
// showmessage('----');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -