📄 ustockopt.pas
字号:
unit uStockOpt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uBasic, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxDBEdit, cxDropDownEdit,
cxCalendar, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit, DBClient,
cxGridLevel, cxClasses, cxControls, cxGridCustomView,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
ExtCtrls, ComCtrls, ToolWin, StdCtrls, DateUtils, jpeg, cxCalc,
cxCurrencyEdit, fr_Class;
type
TfrmStockOpt = class(TfrmBasic)
Label4: TLabel;
Label2: TLabel;
Label5: TLabel;
cxDBButtonEdit3: TcxDBButtonEdit;
cxDBDateEdit1: TcxDBDateEdit;
Label3: TLabel;
cxDBTextEdit1: TcxDBTextEdit;
cxDBButtonEdit2: TcxDBButtonEdit;
Label1: TLabel;
cxDBTextEdit2: TcxDBTextEdit;
colCode: TcxGridDBColumn;
colName: TcxGridDBColumn;
colHd: TcxGridDBColumn;
colKD: TcxGridDBColumn;
colColor: TcxGridDBColumn;
colDw: TcxGridDBColumn;
colSL: TcxGridDBColumn;
colZl: TcxGridDBColumn;
colNil: TcxGridDBColumn;
cxComboBox1: TcxComboBox;
Label6: TLabel;
Label7: TLabel;
cxDBCalcEdit1: TcxDBCalcEdit;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
cxDBDateEdit2: TcxDBDateEdit;
Label8: TLabel;
StatusBar1: TStatusBar;
cdTem: TClientDataSet;
procedure cxDBButtonEdit2PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxDBButtonEdit3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxDBButtonEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBButtonEdit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBTextEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBDateEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBCalcEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxComboBox1Exit(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure colCodePropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cdMasterNewRecord(DataSet: TDataSet);
procedure cdItemBeforePost(DataSet: TDataSet);
procedure ToolButton1Click(Sender: TObject);
private
function CheckBeforePost(iOpt: integer): boolean;
procedure documentPrint;
procedure GetFromStockPlan(cdh:string);
{ 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 CheckOperation(sender :Tobject):integer;OVERRIDE;
function ApplyData():boolean;Override;
public
{ Public declarations }
end;
var
frmStockOpt: TfrmStockOpt;
implementation
uses
uGlobal, uGetData, uPublic, uGetStockPlan;
{$R *.dfm}
{ TfrmStockRanliaoJc }
function TfrmStockOpt.ApplyData: boolean;
var IDL :Integer;
begin
Result := false;
idl := CheckOperation(cxComboBox1);
if idl = 0 then exit;
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
cxDBButtonEdit2.SetFocus;
exit;
end;
cdMaster.Edit;
cdMaster.FieldByName('idl').AsInteger := idl;
cdMaster.Post;
If frmMain.DCOMCn.AppServer.IApplyUpdateStock(cdMaster.Data,cdItem.Data) = 1 then begin
documentPrint;
cxComboBox1.SetFocus;
Result := True;
end;
end;
procedure TfrmStockOpt.CpToItem;
begin
inherited;
with frmMain.cdPub do Begin
cdItem.Edit;
cdItem.FieldByName('IkeyCp').Value := fieldbyname('IKey').Value;
cdItem.FieldByName('CCode').Value := fieldbyname('CCODE').Value;
cdItem.FieldByName('CName').Value := fieldbyname('CName').Value;
cdItem.FieldByName('Fhd').Value := fieldbyname('FHD').Value;
cdItem.FieldByName('FKD').Value := fieldbyname('FKD').Value;
cdItem.FieldByName('Ccolor').Value := fieldbyname('Ccolor').Value;
cdItem.FieldByName('Cdw').Value := fieldbyname('cdw').Value;
statusBar1.Panels[1].Text := '数量 ['+fieldbyname('fsl').AsString + '] '+
'重量 ['+fieldbyname('fzl').AsString + ']';
end;
end;
function TfrmStockOpt.GetCpData: boolean;
begin
result := false;
with frmMain.cdPub do begin
close;
commandText := 'select Ikey,ccode,cname,fhd,fkd,ccolor,cdw,fsl,fzl from T_Stock'+#13+
'where Ccode like '''+trim(cdItem.fieldbyname('ccode').AsString)+'%''';
open;
fieldbyname('ikey').Visible := false;
fieldbyname('ccode').DisplayLabel := '材料编号';
fieldbyname('ccode').DisplayWidth := 18;
fieldbyname('cname').DisplayLabel := '材料名称';
fieldbyname('cName').DisplayWidth := 10;
fieldbyname('FHD').DisplayLabel := '克重';
fieldbyname('FHD').DisplayWidth := 8;
fieldbyname('FKD').DisplayLabel := '宽度';
fieldbyname('FKD').DisplayWidth := 8;
fieldbyname('CCOLOR').DisplayLabel := '颜色';
fieldbyname('CColor').DisplayWidth := 6;
fieldbyname('CDW').DisplayLabel := '单位';
fieldbyname('cdw').DisplayWidth := 4;
fieldbyname('FSL').DisplayLabel := '库存量';
fieldbyname('Fsl').DisplayWidth := 8;
fieldbyname('FZL').DisplayLabel := '重量';
fieldbyname('Fzl').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 TfrmStockOpt.GridEnterColNilToDo(
col: TcxCustomGridTableItem);
begin
inherited;
IF col <> colNil THEN EXIT;
cdItem.Append;
colCode.Focused := true;
end;
function TfrmStockOpt.GridItemChange(col1,
col2: TcxCustomGridTableItem): boolean;
begin
result := ((col1 = colCode) and (col2 = colName));
end;
procedure TfrmStockOpt.init;
begin
inherited;
Label8.Caption := '';
lbLittle.Caption := '操作步骤:';
ActiveControl := cxComboBox1;
end;
function TfrmStockOpt.SetGritItemFocused(B: Boolean): boolean;
begin
result := true;
if B then
colSl.Focused := true
else Begin
colCode.Focused:=true;
infoWnd('提示:没有该编码的材料,请检查!');
abort;
end;
end;
procedure TfrmStockOpt.cxDBButtonEdit2PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
inherited;
If GetClientData('CCode',trim(cxDBButtonEdit2.Text)) <= 0 then exit;
IF frmGetData.ShowModal = mrOk THEN BEGIN
ClientToMaster;
cxDBCalcEdit1.SetFocus;
END;
end;
procedure TfrmStockOpt.cxDBButtonEdit3PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
inherited;
If GetClientData('CName',trim(cxDBButtonEdit3.Text)) <= 0 then exit;
IF frmGetData.ShowModal = mrOk THEN BEGIN
ClientToMaster;
cxDBCalcEdit1.SetFocus;
END;
end;
procedure TfrmStockOpt.cxDBButtonEdit2KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return : if cxDBButtonEdit2.Text = '' THEN
cxDBButtonEdit3.SetFocus
else
cxDBButtonEdit2PropertiesButtonClick(sender,0);
end;
end;
procedure TfrmStockOpt.cxDBButtonEdit3KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
case key of
vk_return : if cxDBButtonEdit3.Text = '' THEN
cxDBButtonEdit2.SetFocus
else
cxDBButtonEdit3PropertiesButtonClick(sender,0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -