📄 sfc_wipinv_d.pas
字号:
unit Sfc_WipInv_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Detail, StdCtrls, Db, AdODB, ExtCtrls, ExtEdit, Mask;
Type
TFrm_Sfc_WipInv_D = Class(TFrm_Base_Detail)
Label1: TLabel;
Label4: TLabel;
Lbl_ItemName: TLabel;
Label3: TLabel;
Label6: TLabel;
ExtEdt_ItemCode: TExtEdit;
Label5: TLabel;
Lbl_WipInvMonth: TLabel;
Lbl_Dept: TLabel;
Edt_WipInvQty: TEdit;
Label2: TLabel;
Lbl_ItemCode2: TLabel;
btn_Bomopen: TButton;
procedure ItemCodeCheck(Sender: TObject);
procedure InOutItemCodeCheck(Sender: TObject);
procedure btn_BomopenClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ExtEdt_ItemCodeExit(Sender: TObject);
private
{ Private declarations }
ItemType:string;
public
{ Public declarations }
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,FrmParam6:String);Override;
protected
procedure InitControls; Override;
procedure SaveData; Override;
procedure SetStatus(CurrentStatus:String;var EnableControls:String); Override;
end;
var
Frm_Sfc_WipInv_D: TFrm_Sfc_WipInv_D;
implementation
uses Sys_Global,Sfc_WipBomOpen;
{$R *.DFM}
procedure TFrm_Sfc_WipInv_D.InitControls;
begin
SetFocus_Control:=ExtEdt_ItemCode;
inherited;
btn_Bomopen.Visible:=False;
with AdoQry_Maintain do
begin
ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').AsString;
Lbl_ItemName.Caption:=fieldbyname('ItemName').AsString;
Lbl_ItemCode2.Caption:=fieldbyname('ItemCode2').AsString;
Edt_WipInvQty.Text:=fieldbyname('WipInvQty').AsString;
end;
end;
procedure TFrm_Sfc_WipInv_D.SaveData;
var
yclbcp:integer;
begin
inherited;
if ItemType='z01' then yclbcp:=0;
if ItemType='z02' then yclbcp:=1;
if ItemType='z03' then yclbcp:=2;
if ItemType='p01' then yclbcp:=3;
if ItemType='p02' then yclbcp:=4;
if(Add)then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert WipInv(WipInvMonth,DeptCode,ItemCode,WipInvQty,ItemType)'
+' Values('
+' '''+Lbl_WipInvMonth.Caption+''''
+','''+GetCode(Lbl_Dept.Caption)+''''
+','''+ExtEdt_ItemCode.Text+''''
+','''+Edt_WipInvQty.Text+''','+inttostr(yclbcp)
+')';
AdoQry_Tmp.ExecSQL;
end
else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Update WipInv Set'
+' ItemCode='''+ExtEdt_ItemCode.Text+''''
+',WipInvQty='''+Edt_WipInvQty.Text+''''
+' Where DeptCode='''+AdoQry_Maintain.fieldbyname('DeptCode').AsString+''''
+' And ItemCode='''+AdoQry_Maintain.fieldbyname('ItemCode').AsString+''''
+' And WipInvMonth='''+AdoQry_Maintain.fieldbyname('WipInvMonth').AsString+'''';
AdoQry_Tmp.ExecSQL;
end;
with AdoQry_Maintain do
begin
fieldbyname('ItemCode').AsString:= ExtEdt_ItemCode.Text;
fieldbyname('ItemName').asstring:=Lbl_ItemName.Caption;
fieldbyname('ItemCode2').AsString:=Lbl_ItemCode2.Caption;
fieldbyname('WipInvQty').AsString:=Edt_WipInvQty.Text;
Post;
end;
end;
procedure TFrm_Sfc_WipInv_D.ItemCodeCheck(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
Exit;
if(Add)or((not Add)and
(TEdit(Sender).Text<>AdoQry_Maintain.fieldbyname('ItemCode').AsString))then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Count(*) As RecCount From WipInv'
+' Where ItemCode='''+TEdit(Sender).Text+''''
+' And DeptCode='''+GetCode(Lbl_Dept.Caption)+''''
+' And WipInvMonth='''+Lbl_WipInvMonth.Caption+'''';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('RecCount').AsInteger<>0 then
begin
DispInfo('已经存在相同的记录,不允许增加或修改!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
end;
procedure TFrm_Sfc_WipInv_D.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
FrmParam4, FrmParam5, FrmParam6: String);
begin
inherited;
Lbl_Dept.Caption:=FrmParam1;
Lbl_WipInvMonth.Caption:=FrmParam2;
ItemType:= FrmParam3;
end;
procedure TFrm_Sfc_WipInv_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
EnableControls:='ExtEdt_ItemCode,Edt_WipInvQty,';
end;
procedure TFrm_Sfc_WipInv_D.InOutItemCodeCheck(Sender: TObject);
begin
inherited;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select ItemCode2 From Item'
+' Where ItemCode='''+TEdit(Sender).Text+'''';
AdoQry_Tmp.Open;
Lbl_ItemCode2.Caption:=AdoQry_Tmp.fieldbyname('ItemCode2').AsString;
end;
procedure TFrm_Sfc_WipInv_D.btn_BomopenClick(Sender: TObject);
var
cur_Cursor:tcursor;
begin
with AdoQry_tmp do
begin
Close;
sql.Text:='select * from wipBomopen where ite_ItemCode='''+Extedt_ItemCode.text
+''' and wipInvMonth='''+Lbl_WipInvMonth.Caption
+''' and DeptCode='''+getCode(lbl_Dept.Caption)+'''';
open;
if not eof then
begin
if DispInfo('该物料已分解,是否再分解?',2)='y' then
else
abort;
end;
end;
with AdoQry_tmp do
begin
Close;
sql.Text:='select * from Bom where ite_ItemCode='''+Extedt_ItemCode.text+'''';
open;
if eof then
begin
DispInfo('该物料无子项,不能分解!',3);
abort;
end;
end;
cur_Cursor:=Screen.Cursor ;
Screen.Cursor :=crHourGlass;
inherited;
Frm_Sfc_WipBomOpen:=TFrm_Sfc_WipBomOpen.Create(self);
Frm_Sfc_WipBomOpen.SetFormParam(lbl_WipInvMonth.Caption,lbl_Dept.Caption,edt_WipInvQty.Text,Extedt_ItemCode.Text,lbl_ItemName.Caption,'');
// Frm_Sfc_WipBomOpen.SetSysParam('Ext','Stk','1234','2001.08.21');
Frm_Sfc_WipBomOpen.InitForm(AdoQry_tmp.Connection,False);
Screen.Cursor :=cur_Cursor;
Frm_Sfc_WipBomOpen.ShowModal;
AdoQry_Maintain.DisableControls ;
AdoQry_Maintain.Close;
AdoQry_Maintain.Open ;
AdoQry_Maintain.EnableControls ;
end;
procedure TFrm_Sfc_WipInv_D.FormActivate(Sender: TObject);
begin
inherited;
if ItemType='z01' then
begin
if status='Add' then
begin
btn_Bomopen.Enabled:=True;
btn_Bomopen.Visible:=True;
end
else
begin
btn_Bomopen.Enabled:=False;
btn_Bomopen.Visible:=False;
end;
end;
end;
procedure TFrm_Sfc_WipInv_D.ExtEdt_ItemCodeExit(Sender: TObject);
begin
with AdoQry_Tmp do
begin
Close;
sql.text:='select ItemName,ItemCode2 from Item where ItemCode='
+QuotedStr(ExtEdt_ItemCode.text);
open;
if not eof then
begin
Lbl_ItemName.Caption:=fieldbyname('ItemName').asstring;
Lbl_ItemCode2.Caption:=fieldbyname('ItemCode2').asstring;
end
else
begin
DispInfo('该物料不存在!',1);
ExtEdt_ItemCode.SetFocus;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -