📄 uhgoodsopt.pas
字号:
unit uHGoodsOpt;
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,
cxCalendar, cxDBEdit, cxDropDownEdit, cxCalc, cxButtonEdit, cxContainer,
cxTextEdit, cxMaskEdit, DateUtils, fr_Class;
type
TfrmHGoodsOpt = class(TfrmBasic)
Label6: TLabel;
cxComboBox1: TcxComboBox;
Label4: TLabel;
cxDBButtonEdit2: TcxDBButtonEdit;
Label7: TLabel;
cxDBCalcEdit1: TcxDBCalcEdit;
Label3: TLabel;
cxDBTextEdit1: TcxDBTextEdit;
cxDBDateEdit1: TcxDBDateEdit;
Label2: TLabel;
cxDBDateEdit2: TcxDBDateEdit;
Label1: TLabel;
cxDBButtonEdit3: TcxDBButtonEdit;
Label5: TLabel;
colCode: TcxGridDBColumn;
colName: TcxGridDBColumn;
colColor: TcxGridDBColumn;
colMs: TcxGridDBColumn;
colDW: TcxGridDBColumn;
colSL: TcxGridDBColumn;
colDj: TcxGridDBColumn;
colJe: TcxGridDBColumn;
colNil: TcxGridDBColumn;
cxDBTextEdit2: TcxDBTextEdit;
Label8: TLabel;
StatusBar1: TStatusBar;
procedure cxDBDateEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxComboBox1Exit(Sender: TObject);
procedure cxDBButtonEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBButtonEdit2PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxDBButtonEdit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDBButtonEdit3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxDBCalcEdit1KeyDown(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 FormShow(Sender: TObject);
procedure colCodePropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cdItemBeforePost(DataSet: TDataSet);
procedure cdMasterNewRecord(DataSet: TDataSet);
private
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 CheckOperation(sender :Tobject):integer;OVERRIDE;
procedure documentPrint;
function ApplyData():boolean;Override;
public
{ Public declarations }
end;
var
frmHGoodsOpt: TfrmHGoodsOpt;
implementation
uses
uGlobal, uGetData, uPublic;
{$R *.dfm}
{ TfrmHGoodsOP }
function TfrmHGoodsOpt.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 cdMaster.FieldByName('cdh').AsString = '' 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.IApplyUpdateHGoods(cdMaster.Data,cdItem.Data) = 1 then begin
documentPrint;
cxComboBox1.SetFocus;
Result := True;
end;
end;
function TfrmHGoodsOpt.CheckOperation(sender: Tobject): integer;
begin
Result := 0;
IF (TcomboBox(sender).Text = '31') OR
(TcomboBox(sender).Text = '裁床登记') THEN Begin
TcomboBox(sender).Text := '裁床登记';
Label1.Caption := '裁床人:';
cxDBTextEdit2.Visible := true;
cxDBDateEdit2.Visible := FALSE;
Label4.Caption := '车间编号:';
Label5.Caption := '车间名称:';
Label8.Caption := '裁床登记单';
result := 31;
End;
IF (TcomboBox(sender).Text = '32') OR
(TcomboBox(sender).Text = '加工收货') THEN Begin
TcomboBox(sender).Text := '加工收货';
Label1.Caption := '收货人:';
cxDBTextEdit2.Visible := true;
cxDBDateEdit2.Visible := FALSE;
Label4.Caption := '加工厂号:';
Label5.Caption := '加工厂名:';
Label8.Caption := '加工收货单';
result := 32;
End;
IF (TcomboBox(sender).Text = '-31') OR
(TcomboBox(sender).Text = '半成品出仓') THEN Begin
TcomboBox(sender).Text := '半成品出仓';
Label1.Caption := '收货人:';
cxDBTextEdit2.Visible := TRUE;
cxDBDateEdit2.Visible := FALSE;
Label4.Caption := '部门编号:';
Label5.Caption := '部门名称:';
Label8.Caption := '半成品出仓单';
result := -31;
End;
IF (TcomboBox(sender).Text = '-32') OR
(TcomboBox(sender).Text = '委外加工') THEN Begin
TcomboBox(sender).Text := '委外加工';
Label1.Caption := '交货日期:';
cxDBTextEdit2.Visible := FALSE;
cxDBDateEdit2.Visible := TRUE;
Label4.Caption := '加工厂号:';
Label5.Caption := '加工厂名:';
Label8.Caption := '委外加工单';
result := -32;
End;
IF Result = 0 then BEGIN
TcomboBox(sender).SetFocus;
Label8.Caption := '';
infoWnd('提示:请确定业务类别!');
END;
end;
procedure TfrmHGoodsOpt.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('CMs').Value := fieldbyname('CMs').Value;
cdItem.FieldByName('Ccolor').Value := fieldbyname('Ccolor').Value;
cdItem.FieldByName('Cdw').Value := fieldbyname('cdw').Value;
statusBar1.Panels[1].Text := '数量 ['+fieldbyname('fsl').AsString + ']';
end;
end;
function TfrmHGoodsOpt.GetCpData: boolean;
begin
result := false;
with frmMain.cdPub do begin
close;
commandText := 'select Ikey,ccode,cname,CMs,ccolor,cdw,fsl from T_HGoods'+#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('CMs').DisplayLabel := '码数';
fieldbyname('CMS').DisplayWidth := 8;
fieldbyname('CCOLOR').DisplayLabel := '颜色';
fieldbyname('CColor').DisplayWidth := 6;
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 TfrmHGoodsOpt.GridEnterColNilToDo(col: TcxCustomGridTableItem);
begin
inherited;
IF col <> colNil THEN EXIT;
cdItem.Append;
colCode.Focused := true;
end;
function TfrmHGoodsOpt.GridItemChange(col1,
col2: TcxCustomGridTableItem): boolean;
begin
result := ((col1 = colCode) and (col2 = colName));
end;
procedure TfrmHGoodsOpt.init;
begin
inherited;
Label8.Caption := '';
lbLittle.Caption := '操作步骤:';
ActiveControl := cxComboBox1;
end;
function TfrmHGoodsOpt.SetGritItemFocused(B: Boolean): boolean;
begin
result := true;
if B then
colSl.Focused := true
else Begin
colCode.Focused:=true;
infoWnd('提示:没有该编码的半成品,请检查!');
abort;
end;
end;
procedure TfrmHGoodsOpt.cxDBDateEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxGrid4.SetFocus;
end;
end;
procedure TfrmHGoodsOpt.cxComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
case key of
vk_return : if not cxComboBox1.DroppedDown then
cxDBButtonEdit2.SetFocus;
end;
end;
procedure TfrmHGoodsOpt.cxComboBox1Exit(Sender: TObject);
begin
inherited;
IF CheckOperation(sender) = -32 THEN Begin
colDJ.Visible := true;
colJe.Visible := true;
exit;
end;
colDJ.Visible := false;
colJe.Visible := false;
end;
procedure TfrmHGoodsOpt.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 TfrmHGoodsOpt.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 TfrmHGoodsOpt.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);
end;
end;
procedure TfrmHGoodsOpt.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 TfrmHGoodsOpt.cxDBCalcEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
case key of
vk_return : IF cxDBTextEdit2.CanFocus then cxDBTextEdit2.SetFocus
Else IF cxDBDateEdit2.CanFocus then cxDBDateEdit2.SetFocus
end;
end;
procedure TfrmHGoodsOpt.cxDBTextEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxDBTextEdit1.SetFocus;
end;
end;
procedure TfrmHGoodsOpt.cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
case key of
vk_return: cxDBDateEdit1.SetFocus;
end;
end;
procedure TfrmHGoodsOpt.FormShow(Sender: TObject);
begin
inherited;
cxComboBox1.Text := intTostr(tag);
CheckOperation(cxComboBox1);
end;
procedure TfrmHGoodsOpt.colCodePropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
inherited;
SetGritItemFocused(GetCpData);
end;
procedure TfrmHGoodsOpt.documentPrint;
var fje: real;
iOpt: integer;
begin
iOpt := CheckOperation(cxComboBox1);
if iOpt >= 0 then exit;
IF not queryWnd('保存成功,打印单据吗?') Then exit;
fje := cdMaster.fieldbyname('Fje').asfloat;
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;
if iOpt = -31 then
frmReport.ReportS(38, 0, '', cdItem.Data);
if iOpt = -32 then
frmReport.ReportS(39, 0, '', cdItem.Data);
end;
function TfrmHGoodsOpt.CheckBeforePost(iOpt: integer): boolean;
var fsl: real;
begin
result := false;
if iOpt = 0 then exit;
with frmMain.cdPub do begin
close;
commandText := 'execute CheckBfrPostHGoods @ccode ='+#13+
quotedStr(trim(cdItem.fieldByname('ccode').AsString))+
',@cMs = ' + quotedStr(cdItem.fieldByname('cMs').AsString)+
',@ccolor = ' + quotedStr(trim(cdItem.fieldByname('ccolor').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;
procedure TfrmHGoodsOpt.cdItemBeforePost(DataSet: TDataSet);
begin
inherited;
CheckBeforePost(CheckOperation(cxComboBox1));
end;
procedure TfrmHGoodsOpt.cdMasterNewRecord(DataSet: TDataSet);
begin
inherited;
cdMaster.FieldByName('ddatePZ').AsDateTime := date;
cdMaster.FieldByName('ddateJh').AsDateTime := date;
cdMaster.FieldByName('cuser').AsString := user;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -