editbatchrebatefrm.pas
来自「群星医药系统源码」· PAS 代码 · 共 139 行
PAS
139 行
unit EditBatchRebateFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzButton, RzBorder, RzRadChk, RzDBChk, StdCtrls, Mask, RzEdit,
RzDBEdit, GoodsesFm, ceGlobal, DB, DBClient, RzCmboBx;
type
TFmEditBatchRebate = class(TForm)
Label1: TLabel;
Label2: TLabel;
edGoodsID: TRzEdit;
edBatMin: TRzNumericEdit;
edBatMax: TRzNumericEdit;
edGoodsName: TRzEdit;
Label3: TLabel;
edRebate: TRzNumericEdit;
Label4: TLabel;
Label5: TLabel;
chkApplyToRetail: TRzCheckBox;
RzBorder1: TRzBorder;
btnOK: TRzBitBtn;
btnCancel: TRzBitBtn;
Label6: TLabel;
Label7: TLabel;
cbUnit: TRzComboBox;
Label8: TLabel;
procedure FormCreate(Sender: TObject);
procedure btnOKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
class function Execute(strCaption,GoodsID,GoodsName,sUnit1,sUnit2: string;
ClientDataSet: TClientDataSet;IsEdit: boolean=false): boolean;
end;
var
FmEditBatchRebate: TFmEditBatchRebate;
implementation
{$R *.dfm}
class function TFmEditBatchRebate.Execute(strCaption,GoodsID,GoodsName,sUnit1,sUnit2: string;
ClientDataSet: TClientDataSet; IsEdit: boolean): boolean;
var bk: string;
begin
with TFmEditBatchRebate.Create(nil) do
try
Caption := strCaption;
edGoodsID.Text := GoodsID;
edGoodsName.Text := GoodsName;
if Trim(sUnit1)<>'' then cbUnit.Add(sUnit1);
if Trim(sUnit2)<>'' then cbUnit.Add(sUnit2);
if cbUnit.Count =0 then exit else cbUnit.ItemIndex := 0;
with ClientDataSet do begin
if not Active then exit;
if IsEdit then begin
edBatMin.IntValue := FieldByName('BatMinQty').AsInteger;
edBatMax.IntValue := FieldByName('BatMaxQty').AsInteger;
edRebate.IntValue := FieldByName('Rebate').AsInteger;
cbUnit.ItemIndex := cbUnit.IndexOf(FieldByName('Unit').AsString);
chkApplyToRetail.Checked := FieldByName('RetailAble').AsBoolean;
end;
if RecordCount = 0 then
cbUnit.Enabled :=true
else begin //已有批量折扣记录时,不再允许改变单位
bk := Bookmark;
RecNo := 1;
cbUnit.ItemIndex := cbUnit.IndexOf(FieldByName('Unit').AsString);
if not (IsEdit and (RecordCount=1)) then
cbUnit.Enabled :=false;
Bookmark := bk;
end;
end;
while ShowModal=mrOK do
begin
with ClientDataSet do
begin
if not (state in dsEditModes) then
if IsEdit then Edit else Insert;
FieldByName('GoodsID').AsString := edGoodsID.Text;
FieldByName('BatMinQty').AsInteger := edBatMin.IntValue;
FieldByName('BatMaxQty').AsInteger := edBatMax.IntValue;
FieldByName('Unit').AsString := cbUnit.Text;
FieldByName('Rebate').AsInteger := edRebate.IntValue;
FieldByName('RetailAble').AsBoolean := chkApplyToRetail.Checked;
try
Post;
Result :=true;
Break;
Except
on E: Exception do
Application.MessageBox(PChar(E.Message), '错误', MB_ICONERROR);
end;
end;
end;
if ClientDataSet.state in dsEditModes then
begin
ClientDataSet.Cancel;
ClientDataSet.CancelUpdates;
end;
finally
Free;
end;
end;
procedure TFmEditBatchRebate.FormCreate(Sender: TObject);
begin
Color := FormBackColor;
edGoodsID.FocusColor := FormBackColor;
edGoodsName.FocusColor := FormBackColor;
end;
procedure TFmEditBatchRebate.btnOKClick(Sender: TObject);
begin
if edBatMin.IntValue < 0 then begin
MessageBox(Handle,'最小批量设置错误!',nil,MB_ICONHAND);
exit;
end;
if edBatMin.IntValue = 0 then
if MessageBox(Handle,'你指定的最小批量是0,要继续吗?','警告',MB_ICONEXCLAMATION or MB_YESNO)= IDNO then exit;
if (edBatMax.IntValue <> -1)and(edBatMax.IntValue <= edBatMin.IntValue) then begin
MessageBox(Handle,'最大批量必须大于最小批量!',nil,MB_ICONHAND);
exit;
end;
if edRebate.IntValue = 0 then begin
MessageBox(Handle,'请输入折扣!','提示',MB_ICONEXCLAMATION);
exit;
end;
ModalResult := mrOK;
//close;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?