📄 pm_enter_simplesureno_d.pas
字号:
unit Pm_Enter_SimpleSureNo_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, linkedit, Grids,
DBGrids;
Type
TFrm_Pm_Enter_SimpleSureNo_D = Class(TFrm_Base_Detail)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edt_StArtDate: TEdit;
Edt_EndDate: TEdit;
LEdt_VendorCode: TLinkEdit;
LEdt_ItemCode: TLinkEdit;
Lbl_VendorName: TLabel;
Lbl_ItemName: TLabel;
Edt_Itemsampleno: TEdit;
Label5: TLabel;
procedure LEdt_VendorCodeExit(Sender: TObject);
procedure LEdt_ItemCodeExit(Sender: TObject);
procedure Edt_ItemsamplenoExit(Sender: TObject);
procedure btn_CancelClick(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
oldItemsampleId,oldItemsampleno:string;
procedure InitControls; Override;
procedure SaveData;Override;
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_Pm_Enter_SimpleSureNo_D: TFrm_Pm_Enter_SimpleSureNo_D;
implementation
uses Sys_Global,Pm_Enter_SimpleSureNo;
{$R *.DFM}
procedure TFrm_Pm_Enter_SimpleSureNo_D.LEdt_VendorCodeExit(Sender: TObject);
begin
inherited;
If (ActiveControl.Name='btn_Cancel') Or (Trim(TLinkEdit(Sender).Text)='') Then
begin
Lbl_VendorName.Caption:='';
Exit;
end;
VendorCodeCheck(Sender);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select VendorName From Vendor Where VendorCode='''+Trim(TLinkEdit(Sender).Text)+'''';
AdoQry_Tmp.Open;
Lbl_VendorName.Caption:=AdoQry_Tmp.fieldbyname('VendorName').AsString;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.LEdt_ItemCodeExit(Sender: TObject);
begin
inherited;
If (ActiveControl.Name='btn_Cancel') Or (Trim(TLinkEdit(Sender).Text)='') Then
begin
Lbl_ItemName.Caption:='';
Exit;
end;
ItemCodeCheck(Sender);
if Add then
begin
with AdoQry_Tmp do
begin
Close;
sql.Text:='select Itemsampleno from Itemsampleno'+
' where Itemsampleno='''+Trim(Edt_Itemsampleno.Text)+''''+
' and ItemCode='''+Trim(LEdt_ItemCode.Text)+''''+
' and VendorCode='''+Trim(LEdt_VendorCode.Text)+'''';
open;
if not(IsEmpty)and(activecontrol.Name<>'btn_Cancel') then
begin
DispInfo('同供应商同物料的样品确认单号'+#13+#10+' 已经存在,不允许增加!',1);
TWinControl(Edt_Itemsampleno).SetFocus;
Abort;
end;
end;
end
else
with AdoQry_Tmp do
begin
Close;
sql.text:='select * from Itemsampleno'+
' where Itemsampleno='''+Edt_Itemsampleno.Text+''''+
' and VendorCode='''+Trim(LEdt_VendorCode.Text)+''''+
' and ItemCode='''+Trim(LEdt_ItemCode.Text)+'''';
open;
if (fieldbyname('Itemsampleid').asstring<>OldItemsampleId)and(not IsEmpty)and(ActiveControl.Name<>'btn_Cancel') then
begin
DispInfo('同供应商同物料的样品确认单号'+#13+#10+' 已经存在,不允许或修改!',1);
TWinControl(Edt_Itemsampleno).SetFocus;
Abort;
end;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select ItemName From Item Where ItemCode='''+Trim(TLinkEdit(Sender).Text)+'''';
AdoQry_Tmp.Open;
Lbl_ItemName.Caption:=AdoQry_Tmp.fieldbyname('ItemName').AsString;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.InitControls;
begin
inherited;
with AdoQry_Tmp do
begin
Close;
sql.text:='select * from Itemsampleno '+
' where Itemsampleno='''+AdoQry_Maintain.fieldbyname('Itemsampleno').asstring+'''';
open;
Edt_Itemsampleno.Text:=fieldbyname('Itemsampleno').asstring;
oldItemsampleId:=fieldbyname('ItemsampleId').asstring;
oldItemsampleno:=fieldbyname('Itemsampleno').asstring;
LEdt_VendorCode.Text:=fieldbyname('VendorCode').asstring;
LEdt_ItemCode.Text:=fieldbyname('ItemCode').asstring;
Edt_StArtDate.Text:=fieldbyname('stArtdate').asstring;
Edt_EndDate.Text:=fieldbyname('enddate').asstring;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select VendorName From Vendor Where VendorCode='''+Trim(LEdt_VendorCode.Text)+'''';
AdoQry_Tmp.Open;
Lbl_VendorName.Caption:=AdoQry_Tmp.fieldbyname('VendorName').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=' Select ItemName From Item Where ItemCode='''+Trim(LEdt_ItemCode.Text)+'''';
AdoQry_Tmp.Open;
Lbl_ItemName.Caption:=AdoQry_Tmp.fieldbyname('ItemName').AsString;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.SaveData;
var
Itemsamplenostr:string;
begin
BlankCheck(Edt_Itemsampleno.Text,'样品确认单号');
if Edt_Itemsampleno.Text='' then
begin
Edt_Itemsampleno.SetFocus;
abort;
end;
if Add then
with AdoQry_Tmp do
begin
Close;
sql.Text:='insert Itemsampleno( '+
'ItemCode,'+
'VendorCode,'+
'Itemsampleno,'+
'stArtdate,'+
'enddate)'+
'Values( '+
''''+LEdt_ItemCode.text+''','+
''''+LEdt_VendorCode.Text+''','+
''''+Edt_Itemsampleno.Text+''','+
''''+Edt_StArtDate.Text+''','+
''''+Edt_EndDate.Text+''')';
ExecSQL;
end
else
with AdoQry_Tmp do
begin
Close;
sql.Text:='update Itemsampleno set '+
'ItemCode='''+LEdt_ItemCode.text+''','+
'VendorCode='''+LEdt_VendorCode.Text+''','+
'Itemsampleno='''+Edt_Itemsampleno.Text+''','+
'stArtdate='''+Edt_StArtDate.Text+''','+
'enddate='''+Edt_EndDate.Text+''''+
'where Itemsampleid='''+OldItemSampleId+'''';
ExecSQL;
end;
with AdoQry_Maintain do
begin
fieldbyname('Itemsampleno').asstring:=Edt_Itemsampleno.Text;
fieldbyname('ItemCode').asstring:=LEdt_ItemCode.text;
fieldbyname('ItemName').asstring:=Lbl_ItemName.Caption;
fieldbyname('VendorCode').asstring:=LEdt_VendorCode.Text;
fieldbyname('VendorName').asstring:=Lbl_VendorName.Caption;
fieldbyname('stArtdate').asstring:=Edt_StArtDate.Text;
fieldbyname('enddate').asstring:=Edt_EndDate.Text;
end;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.Edt_ItemsamplenoExit(
Sender: TObject);
begin
inherited;
BlankCheck(Edt_Itemsampleno.Text,'样品确认单号');
if Edt_Itemsampleno.Text='' then
begin
Edt_Itemsampleno.SetFocus;
abort;
end;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.btn_CancelClick(Sender: TObject);
begin
inherited;
try
if (AdoQry_Maintain.State=dsinsert) or (AdoQry_Maintain.State=dsedit) then
AdoQry_Maintain.Post;
except
end;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.btn_okClick(Sender: TObject);
begin
if Add then
begin
with AdoQry_Tmp do
begin
Close;
sql.Text:='select Itemsampleno from Itemsampleno'+
' where Itemsampleno='''+Trim(Edt_Itemsampleno.Text)+''''+
// ' and ItemCode='''+Trim(LEdt_ItemCode.Text)+''''+
' and VendorCode<>'''+Trim(LEdt_VendorCode.Text)+'''';
open;
if (not IsEmpty) and(activecontrol.Name<>'btn_Cancel') then
begin
DispInfo('不同供应商已有该样品确认单号,'+#13+#10+' 不允许增加!',1);
TWinControl(Edt_Itemsampleno).SetFocus;
Abort;
end;
Close;
sql.Text:='select Itemsampleno from Itemsampleno'+
' where Itemsampleno='''+Trim(Edt_Itemsampleno.Text)+''''+
' and ItemCode='''+Trim(LEdt_ItemCode.Text)+''''+
' and VendorCode='''+Trim(LEdt_VendorCode.Text)+'''';
open;
if not(IsEmpty)and(activecontrol.Name<>'btn_Cancel') then
begin
DispInfo('同供应商同物料的样品确认单号'+#13+#10+' 已经存在,不允许增加!',1);
TWinControl(Edt_Itemsampleno).SetFocus;
Abort;
end;
end;
end
else
with AdoQry_Tmp do
begin
Close;
sql.text:='select * from Itemsampleno'+
' where Itemsampleno='''+Edt_Itemsampleno.Text+''''+
' and VendorCode<>'''+Trim(LEdt_VendorCode.Text)+'''';
//' and ItemCode='''+Trim(LEdt_ItemCode.Text)+'''';
open;
if (not IsEmpty)and(ActiveControl.Name<>'btn_Cancel') then
begin
DispInfo('不同供应商已有该样品确认单号,'+#13+#10+' 不允许修改!',1);
TWinControl(Edt_Itemsampleno).SetFocus;
Abort;
end;
Close;
sql.text:='select * from Itemsampleno'+
' where Itemsampleno='''+Edt_Itemsampleno.Text+''''+
' and VendorCode='''+Trim(LEdt_VendorCode.Text)+''''+
' and ItemCode='''+Trim(LEdt_ItemCode.Text)+'''';
open;
if (fieldbyname('Itemsampleid').asstring<>OldItemsampleId)and(not IsEmpty)and(ActiveControl.Name<>'btn_Cancel') then
begin
DispInfo('同供应商同物料的样品确认单号'+#13+#10+' 已经存在,不允许或修改!',1);
TWinControl(Edt_Itemsampleno).SetFocus;
Abort;
end;
end;
inherited;
end;
procedure TFrm_Pm_Enter_SimpleSureNo_D.FormShow(Sender: TObject);
begin
inherited;
Edt_Itemsampleno.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -