📄 upartinfo.pas
字号:
unit uPartinfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, LBDBGrid, StdCtrls, LBCtrls, LBDBCtrls,
ActnList, DBCtrls, FR_DSet, FR_DBSet, FR_Class, LBDBScrollBar;
type
TfrmPartinfo = class(TForm)
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
DataDBGrid: TLBDBGrid;
Panel8: TPanel;
Shape1: TShape;
ActionList1: TActionList;
Action1: TAction;
Action2: TAction;
Action3: TAction;
Action5: TAction;
Action6: TAction;
Action4: TAction;
Action7: TAction;
Action8: TAction;
Report: TfrReport;
ReportDataSet: TfrDBDataSet;
plData: TPanel;
Shape18: TShape;
Shape17: TShape;
Shape16: TShape;
Shape15: TShape;
Shape2: TShape;
Label1: TLabel;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape9: TShape;
Shape10: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Label6: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label12: TLabel;
Label13: TLabel;
Label5: TLabel;
Label15: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label16: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
LBDBEdit1: TLBDBEdit;
LBDBEdit2: TLBDBEdit;
LBDBEdit3: TLBDBEdit;
LBDBEdit14: TLBDBEdit;
LBDBEdit15: TLBDBEdit;
LBDBEdit16: TLBDBEdit;
LBDBComboBox2: TLBDBComboBox;
LBDBComboBox4: TLBDBComboBox;
LBDBComboBox5: TLBDBComboBox;
LBDBNumberEdit2: TLBDBNumberEdit;
LBDBNumberEdit3: TLBDBNumberEdit;
LBDBNumberEdit4: TLBDBNumberEdit;
LBDBNumberEdit5: TLBDBNumberEdit;
LBDBNumberEdit6: TLBDBNumberEdit;
LBDBComboBox6: TLBDBComboBox;
Label7: TLabel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
DBText5: TDBText;
Label14: TLabel;
DBText6: TDBText;
Panel7: TPanel;
Image1: TImage;
Shape22: TShape;
Shape23: TShape;
Shape24: TShape;
Shape25: TShape;
Panel2: TPanel;
Panel5: TPanel;
Panel9: TPanel;
Panel11: TPanel;
EnterButton: TLBButton;
CancelButton: TLBButton;
LBDBScrollBar1: TLBDBScrollBar;
LBSpeecButton2: TLBSpeecButton;
LBSpeecButton1: TLBSpeecButton;
LBSpeecButton3: TLBSpeecButton;
LBSpeecButton4: TLBSpeecButton;
LBSpeecButton5: TLBSpeecButton;
LBSpeecButton6: TLBSpeecButton;
Shape26: TShape;
Label21: TLabel;
LBDBEdit4: TLBDBEdit;
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Action2Execute(Sender: TObject);
procedure Action1Execute(Sender: TObject);
procedure Action3Execute(Sender: TObject);
procedure Action5Execute(Sender: TObject);
procedure Action6Execute(Sender: TObject);
procedure Action4Execute(Sender: TObject);
procedure Action7Execute(Sender: TObject);
procedure Action8Execute(Sender: TObject);
procedure LBDBEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DataDBGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormDestroy(Sender: TObject);
procedure LBDBComboBox2Enter(Sender: TObject);
procedure LBDBComboBox4Enter(Sender: TObject);
procedure LBDBComboBox5Enter(Sender: TObject);
procedure LBDBComboBox6Enter(Sender: TObject);
procedure LBDBEdit2Exit(Sender: TObject);
procedure LBDBEdit16KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
procedure SetView;
public
{ Public declarations }
end;
var
frmPartinfo: TfrmPartinfo;
isStateEdit, isEdit: Boolean;
OldCode: string;
implementation
uses uDataMo, uPublicvar, uMain, uConst, uSelectPart, Tools;
{$R *.dfm}
procedure TfrmPartinfo.SetView;
begin
DataDBGrid.Enabled:=not DataDBGrid.Enabled;
plData.Enabled:=not plData.Enabled;
Action1.Enabled:=not Action1.Enabled;
Action2.Enabled:=not Action2.Enabled;
Action3.Enabled:=not Action3.Enabled;
Action4.Enabled:=not Action4.Enabled;
Action5.Enabled:=not Action5.Enabled;
Action6.Enabled:=not Action6.Enabled;
Action7.Enabled:=not Action7.Enabled;
Action8.Enabled:=not Action8.Enabled;
EnterButton.Visible:=not EnterButton.Visible;
CancelButton.Visible:=not CancelButton.Visible;
end;
procedure TfrmPartinfo.FormShow(Sender: TObject);
begin
SetView;
OpenData('select * from Partinfo Order by Code', dmData.sdsPartinfo);
isStateEdit:=False;
end;
procedure TfrmPartinfo.FormActivate(Sender: TObject);
begin
GetWindowsItem(Caption, Self);
end;
procedure TfrmPartinfo.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
frmPartinfo:=Nil;
end;
procedure TfrmPartinfo.Action1Execute(Sender: TObject);
begin
SetView;
LBDBEdit1.SetFocus;
with dmData.sdsPartinfo do
begin
Append;
FieldByName('Del').asstring:='0';
FieldByName('InPutPrice').asfloat:=0;
FieldByName('OutPoutPrice').asfloat:=0;
FieldByName('TradePrice').asfloat:=0;
FieldByName('Preferential').asfloat:=0;
FieldByName('ForeignPrice').asfloat:=0;
end;
OldCode:='';
isEdit:=False;
isStateEdit:=True;
end;
procedure TfrmPartinfo.Action2Execute(Sender: TObject);
begin
if dmData.sdsPartinfo.IsEmpty then
begin
Application.MessageBox(NotEditData, Hintinfo,$30);
Exit;
end;
SetView;
LBDBEdit1.SetFocus;
dmData.sdsPartinfo.Edit;
OldCode:=dmData.sdsPartinfo.Fieldbyname('Code').asstring ;
isEdit:=True;
isStateEdit:=True;
end;
procedure TfrmPartinfo.Action3Execute(Sender: TObject);
begin
DeleteData(dmData.sdsPartinfo, True);
end;
procedure TfrmPartinfo.Action5Execute(Sender: TObject);
begin
FindData(dmData.sdsPartinfo, '商品资料查询', 'Partinfo');
end;
procedure TfrmPartinfo.Action6Execute(Sender: TObject);
begin
OpenData('select * from Partinfo Order by Code', dmData.sdsPartinfo);
end;
procedure TfrmPartinfo.Action4Execute(Sender: TObject);
begin
PrintView('RepPartinfo.frf', Report);
end;
procedure TfrmPartinfo.Action7Execute(Sender: TObject);
begin
if Trim(LBDBEdit1.Text)='' then
begin
Application.MessageBox('请输入商品编号。',Hintinfo,$30);
LBDBEdit1.SetFocus;
Exit;
end;
if Trim(LBDBEdit2.Text)='' then
begin
Application.MessageBox('请输入商品名称。',Hintinfo,$30);
LBDBEdit2.SetFocus;
Exit;
end;
if isExist('PartInfo', 'Code', Trim(LBDBEdit1.Text), OldCode, '') then
begin
Application.MessageBox('此商品编号已存在,请重新输入。',Hintinfo,$30);
LBDBEdit1.SetFocus;
Exit;
end;
dmData.sdsPartinfo.ApplyUpdates(-1);
with dmData.sdsInterconvertPart do
begin
Last;
while not Eof do
begin
Edit;
Fieldbyname('ICode').asstring:=Trim(LBDBEdit1.Text);
Next;
end;
ApplyUpdates(-1);
end;
if not isEdit then
begin
LBDBEdit1.SetFocus;
with dmData.sdsPartInfo do
begin
Append;
FieldByName('Del').asstring:='0';
FieldByName('InPutPrice').asfloat:=0;
FieldByName('OutPoutPrice').asfloat:=0;
FieldByName('TradePrice').asfloat:=0;
FieldByName('Preferential').asfloat:=0;
FieldByName('ForeignPrice').asfloat:=0;
end;
end
else
begin
SetView;
isStateEdit:=False;
end;
end;
procedure TfrmPartinfo.Action8Execute(Sender: TObject);
begin
if dmData.sdsPartinfo.Modified then
begin
if Application.MessageBox(OnCancelEdit,HintInfo,$24)=idYes then
begin
dmData.sdsPartinfo.CancelUpdates;
SetView;
end;
end
else
begin
dmData.sdsPartinfo.CancelUpdates;
SetView;
end;
isStateEdit:=False;
end;
procedure TfrmPartinfo.LBDBEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then Perform(WM_NEXTDLGCTL,0,0);
end;
procedure TfrmPartinfo.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=27 then Close;
end;
procedure TfrmPartinfo.DataDBGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=VK_NEXT) or (key=VK_Down) then
if dmData.sdsPartinfo.Eof then
dmData.sdsPartinfo.GetNextPacket;
end;
procedure TfrmPartinfo.FormDestroy(Sender: TObject);
begin
WindowItem.Delete(WindowItem.IndexOfObject(Self));
end;
procedure TfrmPartinfo.LBDBComboBox2Enter(Sender: TObject);
begin
SetListData('select Name from Elseinfo where Code='''+'3''', LBDBComboBox2);
end;
procedure TfrmPartinfo.LBDBComboBox4Enter(Sender: TObject);
begin
SetListData('select Name from Elseinfo where Code='''+'5''', LBDBComboBox4);
end;
procedure TfrmPartinfo.LBDBComboBox5Enter(Sender: TObject);
begin
SetListData('select Name from Elseinfo where Code='''+'4''', LBDBComboBox5);
end;
procedure TfrmPartinfo.LBDBComboBox6Enter(Sender: TObject);
begin
SetListData('select Name from Elseinfo where Code='''+'8''', LBDBComboBox6);
end;
procedure TfrmPartinfo.LBDBEdit2Exit(Sender: TObject);
begin
if (Trim(LBDBEdit2.Text)<>'') and(isStateEdit) then
begin
dmData.sdsPartinfo.Edit;
dmData.sdsPartinfo.FieldByName('HELPNOTENO').asstring:=GetPY(LBDBEdit2.Text);
end;
end;
procedure TfrmPartinfo.LBDBEdit16KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then Action7Execute(Sender);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -