📄 ugoodsjc.pas
字号:
unit uGoodsJc;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uBasic, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, DBClient, cxGridLevel, cxClasses,
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxGrid, ExtCtrls, ComCtrls, ToolWin, StdCtrls, jpeg,
cxMaskEdit, cxDropDownEdit, cxCalendar, cxDBEdit, cxContainer, cxTextEdit,
DateUtils, cxButtonEdit, cxCalc;
type
TfrmGoodsJc = class(TfrmBasic)
Label3: TLabel;
cxDBTextEdit1: TcxDBTextEdit;
Label4: TLabel;
cxDBDateEdit1: TcxDBDateEdit;
colKeyCp: TcxGridDBColumn;
colname: TcxGridDBColumn;
coldw: TcxGridDBColumn;
colSl: TcxGridDBColumn;
colNil: TcxGridDBColumn;
Label1: TLabel;
StatusBar1: TStatusBar;
procedure cxDBDateEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure colKeyCpPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cdMasterNewRecord(DataSet: TDataSet);
private
{ 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
frmGoodsJc: TfrmGoodsJc;
implementation
uses
uGlobal, uGetData, uPublic;
{$R *.dfm}
function TfrmGoodsJc.ApplyData: boolean;
begin
Result := false;
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
infoWnd('保存成功,按[回车]继续录入');
cxDBDateEdit1.SetFocus;
Result := True;
end;
end;
procedure TfrmGoodsJc.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('Ccolor').Value := fieldbyname('Ccolor').Value;
cdItem.FieldByName('Cdw').Value := fieldbyname('cdw').Value;
end;
end;
procedure TfrmGoodsJc.cxDBDateEdit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxDBTextEdit1.SetFocus;
end;
end;
procedure TfrmGoodsJc.cxDBTextEdit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxGrid4.SetFocus;
end;
end;
function TfrmGoodsJc.GetCpData: boolean;
begin
result := false;
with frmMain.cdPub do begin
close;
commandText := 'select IKey,cname,cdw,fsl 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;
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 TfrmGoodsJc.GridEnterColNilToDo(
col: TcxCustomGridTableItem);
begin
inherited;
IF col <> colNil THEN EXIT;
cdItem.Append;
colkeyCp.Focused := true;
end;
function TfrmGoodsJc.GridItemChange(col1,
col2: TcxCustomGridTableItem): boolean;
begin
result := ((col1 = colKeyCp) and (col2 = colName));
end;
procedure TfrmGoodsJc.init;
begin
inherited;
lbLittle.Caption := '操作步骤:';
label1.Caption := '成品进仓单';
ActiveControl := cxDBDateEdit1;
end;
function TfrmGoodsJc.SetGritItemFocused(B: Boolean): boolean;
begin
result := true;
if B then
colSl.Focused := true
else Begin
colKeyCp.Focused:=true;
infoWnd('提示:没有该编码的产品,请检查!');
abort;
end;
end;
procedure TfrmGoodsJc.colKeyCpPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
inherited;
SetGritItemFocused(GetCpData);
end;
procedure TfrmGoodsJc.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;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -