📄 ugoodsxs.pas
字号:
unit uGoodsXs;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uBasic, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,FR_Class,
cxButtonEdit, cxCalc, cxCurrencyEdit, cxDropDownEdit, cxCalendar,
cxDBEdit, cxContainer, cxTextEdit, cxMaskEdit, DBClient,DateUtils,
cxGridCustomView, cxGrid, ExtCtrls, ComCtrls, ToolWin, StdCtrls, jpeg;
type
TfrmGoodsXs = class(TfrmBasic)
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label3: TLabel;
cxDBButtonEdit1: TcxDBButtonEdit;
cxDBButtonEdit2: TcxDBButtonEdit;
cxDBTextEdit1: TcxDBTextEdit;
colCode: TcxGridDBColumn;
colName: TcxGridDBColumn;
colDw: TcxGridDBColumn;
colSl: TcxGridDBColumn;
colDj: TcxGridDBColumn;
colJe: TcxGridDBColumn;
colNil: TcxGridDBColumn;
cxDBDateEdit1: TcxDBDateEdit;
Label5: TLabel;
StatusBar1: TStatusBar;
procedure cxDBButtonEdit1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxDBButtonEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBButtonEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBButtonEdit2PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBDateEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure colCodePropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cdMasterNewRecord(DataSet: TDataSet);
procedure cdItemBeforePost(DataSet: TDataSet);
private
procedure documentPrint;
function CheckBeforePost(iOpt: integer): boolean;
{ Private declarations }
protected
procedure init();override;
procedure GridEnterColNilToDo(col: TcxCustomGridTableItem);override;
function GridItemChange(col1,col2: TcxCustomGridTableItem):boolean;Override;
function GetCpData():boolean;Override;
function SetGritItemFocused(B:Boolean):boolean;Override;
procedure CpToItem;override;
function ApplyData():boolean;Override;
public
{ Public declarations }
end;
var
frmGoodsXs: TfrmGoodsXs;
implementation
uses
uGlobal, uGetData, uPublic;
{$R *.dfm}
function TfrmGoodsXs.ApplyData: boolean;
begin
Result := false;
if cdMaster.FieldByName('iKeyClient').AsInteger <= 0 then begin
infownd('提示:请输入客户信息,请检查!');
Exit;
end;
if (yearof(cdMaster.FieldByName('DDatePz').AsDateTime) <> yearof(date)) or
(monthOf(cdMaster.FieldByName('DDatePz').AsDateTime) < (monthOf(date)-1)) then
if Not QueryWnd('提示:日期值与现在的日期值不大相符,继续保存吗?') then begin
cxDBDateEdit1.SetFocus;
exit;
end;
If frmMain.DCOMCn.AppServer.IApplyUpdateGoods(cdMaster.Data,cdItem.Data) = 1 then begin
if queryWnd('保存成功,打印送货单吗?') then
documentPrint;
cxDBButtonEdit1.SetFocus;
Result := True;
end;
end;
procedure TfrmGoodsXs.CpToItem;
begin
inherited;
with frmMain.cdPub do Begin
cdItem.Edit;
cdItem.FieldByName('IkeyCp').Value := fieldbyname('Ikey').Value;
cdItem.FieldByName('CName').Value := fieldbyname('CName').Value;
cdItem.FieldByName('fdj').Value := fieldbyname('fdj').Value;
cdItem.FieldByName('Cdw').Value := fieldbyname('cdw').Value;
statusBar1.Panels[1].Text := ''+fieldbyname('fsl').AsString;
end;
end;
procedure TfrmGoodsXs.cxDBButtonEdit1PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
inherited;
If GetClientData('CCode',trim(cxDBButtonEdit1.Text)) <= 0 then exit;
IF frmGetData.ShowModal = mrOk THEN BEGIN
ClientToMaster;
cxDBTextEdit1.SetFocus;
END;
end;
function TfrmGoodsXs.GetCpData: boolean;
begin
result := false;
with frmMain.cdPub do begin
close;
commandText := 'select IKey,cname,cdw,fsl,fdj from T_Goods'+#13+
'where ikey like '''+trim(cdItem.fieldbyname('ikeyCp').AsString)+'%''';
open;
fieldbyname('ikey').DisplayLabel := '产品编号';
fieldbyname('ikey').DisplayWidth := 18;
fieldbyname('cname').DisplayLabel := '品名规格';
fieldbyname('cName').DisplayWidth := 20;
fieldbyname('CDW').DisplayLabel := '单位';
fieldbyname('cdw').DisplayWidth := 4;
fieldbyname('FSL').DisplayLabel := '库存量';
fieldbyname('Fsl').DisplayWidth := 8;
fieldbyname('Fdj').DisplayLabel := '销售单价';
fieldbyname('Fdj').DisplayWidth := 8;
if recordcount <= 0 then exit;
if recordcount = 1 then Begin
cpToItem;
Result := true;
end;
if (recordcount > 1) and (frmGetData.ShowModal = mrOk) then Begin
cpToItem;
Result := true;
end;
end;
end;
procedure TfrmGoodsXs.GridEnterColNilToDo(
col: TcxCustomGridTableItem);
begin
inherited;
IF col <> colJe THEN EXIT;
cdItem.Append;
colCode.Focused := true;
end;
function TfrmGoodsXs.GridItemChange(col1,
col2: TcxCustomGridTableItem): boolean;
begin
result := ((col1 = colCode) and (col2 = colName));
end;
procedure TfrmGoodsXs.init;
begin
inherited;
lbLittle.Caption := '操作步骤:';
Label5.Caption := '销售(送货)单';
ActiveControl := cxDBButtonEdit1;
end;
function TfrmGoodsXs.SetGritItemFocused(B: Boolean): boolean;
begin
result := true;
if B then
colSl.Focused := true
else Begin
colCode.Focused:=true;
infoWnd('提示:没有该编码的产品,请检查!');
abort;
end;
end;
procedure TfrmGoodsXs.cxDBButtonEdit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return : if cxDBButtonEdit1.Text = '' THEN
cxDBButtonEdit2.SetFocus
else
cxDBButtonEdit1PropertiesButtonClick(sender,0);
end;
end;
procedure TfrmGoodsXs.cxDBButtonEdit2KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return : if cxDBButtonEdit2.Text = '' THEN
cxDBButtonEdit1.SetFocus
else
cxDBButtonEdit2PropertiesButtonClick(sender,0);
end;
end;
procedure TfrmGoodsXs.cxDBButtonEdit2PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
inherited;
If GetClientData('CName',trim(cxDBButtonEdit2.Text)) <= 0 then exit;
IF frmGetData.ShowModal = mrOk THEN BEGIN
ClientToMaster;
cxDBTextEdit1.SetFocus;
END;
end;
procedure TfrmGoodsXs.cxDBTextEdit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxDBDateEdit1.SetFocus;
end;
end;
procedure TfrmGoodsXs.cxDBDateEdit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxGrid4.SetFocus;
end;
end;
procedure TfrmGoodsXs.colCodePropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
inherited;
SetGritItemFocused(GetCpData);
end;
procedure TfrmGoodsXs.documentPrint;
var fje: real;
begin
fje := fcGetJeTotal(cdItem);
UpperCasePrint(fje);
frVariables['VcodeClient'] := cdMaster.fieldbyname('ccodeClient').asstring;
frVariables['VnameClient'] := cdMaster.fieldbyname('cNameClient').asstring;
frVariables['VdateJH'] := cdMaster.fieldbyname('DDateJh').asdateTime;
frVariables['Vdh'] := cdMaster.fieldbyname('cdh').asstring;
frVariables['VdatePZ'] := cdMaster.fieldbyname('DDatePz').asdatetime;
frVariables['Vje'] := fje;
frVariables['Vdress'] := cdMaster.fieldbyname('cPostDz').asstring;
frVariables['Vtel'] := cdMaster.fieldbyname('cTel').asstring;
frmReport.ReportS(49, 0, '', cdItem.Data);
end;
procedure TfrmGoodsXs.cdMasterNewRecord(DataSet: TDataSet);
begin
inherited;
cdMaster.FieldByName('ddatePZ').AsDateTime := date;
cdMaster.FieldByName('ddateJh').AsDateTime := date;
cdMaster.FieldByName('idl').AsInteger := -41;
cdMaster.FieldByName('cuser').AsString := user;
end;
procedure TfrmGoodsXs.cdItemBeforePost(DataSet: TDataSet);
begin
inherited;
CheckBeforePost(-41);
end;
function TfrmGoodsXs.CheckBeforePost(iOpt: integer): boolean;
var fsl: real;
begin
result := false;
if iOpt = 0 then exit;
with frmMain.cdPub do begin
close;
commandText := 'execute CheckBfrPostGoods @IKey ='+#13+
quotedStr(trim(cdItem.fieldByname('IkeyCp').AsString));
open;
fsl := fieldbyname('fsl').AsFloat;
statusBar1.Panels[1].Text := ''+fieldbyname('fsl').AsString;
if fsl = -1 then begin
colCode.Focused := true;
result := true;
infoWnd('提示:没有该编码的成品,请检查!');
abort;
end;
if (fsl < cdItem.fieldbyname('fsl').AsFloat) and (iOpt < 0) then begin
colSl.Focused := true;
result := true;
infoWnd('提示:库存量不足,请检查!');
abort;
end;
statusBar1.Panels[1].Text := '';
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -