unit Input_SCB;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, StdCtrls, Mask, DBCtrls, ExtCtrls,Dm1, Buttons;
type
TForm_Input_SCB = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Label1: TLabel;
DBLookupComboBox1: TDBLookupComboBox;
Label2: TLabel;
DBLookupComboBox2: TDBLookupComboBox;
Label3: TLabel;
Label4: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
Label5: TLabel;
DBEdit3: TDBEdit;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
BB_Close: TBitBtn;
Label6: TLabel;
DBEdit4: TDBEdit;
Label7: TLabel;
DBEdit5: TDBEdit;
Label8: TLabel;
DBEdit6: TDBEdit;
Label9: TLabel;
DBEdit7: TDBEdit;
Label10: TLabel;
DBEdit8: TDBEdit;
DBEdit9: TDBEdit;
BB_UP: TBitBtn;
BB_down: TBitBtn;
BB_Append: TBitBtn;
BB_repair: TBitBtn;
BB_abort: TBitBtn;
BB_del: TBitBtn;
BB_save: TBitBtn;
Edit1: TEdit;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Edit_Name: TEdit;
Edit2: TEdit;
Edit3: TEdit;
BitBtn1: TBitBtn;
Edit4: TEdit;
procedure FormActivate(Sender: TObject);
procedure BB_CloseClick(Sender: TObject);
procedure BB_AppendClick(Sender: TObject);
procedure BB_repairClick(Sender: TObject);
procedure BB_abortClick(Sender: TObject);
procedure BB_saveClick(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure Edit1Exit(Sender: TObject);
procedure BB_AppendKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBLookupComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBLookupComboBox1Exit(Sender: TObject);
procedure BB_UPClick(Sender: TObject);
procedure BB_downClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
BB_Append_Sattus:Boolean; //显示BB_APPEND按钮状态
public
{ Public declarations }
end;
var
Form_Input_SCB: TForm_Input_SCB;
implementation
uses plastic;
{$R *.DFM}
//对各个字段的Enabled进行赋值
Procedure Init_input_Enabled(Y_N,N_N:Boolean);
Begin
With Form_Input_Scb do
Begin
DBLookupComboBox1.Enabled:=Y_N;
DBEdit1.Enabled:=Y_N;
DBEdit2.Enabled:=Y_N;
DbGrid2.ReadOnly:=Y_N;
DBGrid1.Enabled:=N_N;//增加时为True,修改时为False
End;
End;
//对各个按钮进行使能控制
Procedure Init_BB_Enabled(A_YN,R_YN,B_YN,D_YN,S_YN,V_DB_YN,V_E_YN:Boolean);
Begin
With Form_input_SCB Do
Begin
BB_Append.Enabled:=A_YN;
BB_Repair.Enabled:=R_YN;
BB_Abort.Enabled:=B_YN;
BB_Del.Enabled:=D_YN;
BB_Save.Enabled:=S_YN;
Dbedit1.visible:=V_DB_YN;
Edit1.Visible :=V_E_YN;
End;
End;
Procedure Check_Null(Var Pass:Boolean);
Label Last;
Var
Mes:String;
Begin
Pass:=True;
If (Dm_1.T_SCB.FieldByName('CPDm').Asstring = Null) Or
(Dm_1.T_SCB.FieldByName('CPDm').Asstring = '') Then
Begin
Mes:='请输入产品代码!';
Pass:=False;
Form_Input_SCB.DBLookupComboBox1.SetFocus;
Goto Last
End;
If (Form_Input_SCB.DBEdit1.Text = Null) Or (Form_Input_SCB.DBEdit1.Text = '') Then
Begin
Mes:='请输入生产日期!';
Pass:=False;
If Form_Input_SCB.Edit1.Enabled=True Then
Form_Input_SCB.Edit1.SetFocus;
Goto Last
End;
If (Dm_1.T_SCB.FieldByName('SCSL').Asstring = Null) Or
(Dm_1.T_SCB.FieldByName('SCSL').Asstring = '') Or
(Dm_1.T_SCB.FieldByName('SCSL').Asstring = '0') Then
Begin
Mes:='生产数量不能为空或是‘0’!';
Pass:=False;
Form_Input_SCB.DBEdit2.SetFocus;
Goto Last
End;
Last:
If (Mes='') or (Mes=Null) Then
Else
ShowMessage(Mes);
end;
procedure TForm_Input_SCB.FormActivate(Sender: TObject);
begin
Dm_1.T_SCB.Active:=True;
Dm_1.T_CPB.Active:=True;
Edit_Name.Text:=Form_plastic.S_XM;
Edit2.Text:=IntToStr(DM_1.T_SCB.RecNo);
Edit3.Text:=IntToStr(DM_1.T_SCB.RecordCount);
Init_input_Enabled(False,False);
Init_BB_Enabled(True,True,False,False,False,True,False);
BB_Append_Sattus:=False;
end;
procedure TForm_Input_SCB.BB_CloseClick(Sender: TObject);
begin
Dm_1.T_SCB.Active:=False;
Dm_1.T_CPB.Active:=False;
Close;
end;
procedure TForm_Input_SCB.BB_AppendClick(Sender: TObject);
begin
Init_input_Enabled(True,True);
Init_BB_Enabled(False,False,True,False,True,False,True);
Dm_1.T_SCB.Append;
BB_Append_Sattus:=True;
Edit2.Text:=IntToStr(DM_1.T_SCB.RecNo);
Edit3.Text:=IntToStr(DM_1.T_SCB.RecordCount + 1);
end;
procedure TForm_Input_SCB.BB_repairClick(Sender: TObject);
var
D_Date:TDateTime;
begin
Init_input_Enabled(True,False);
Init_BB_Enabled(False,True,True,False,True,False,True);
D_Date:=Dm_1.T_scb.FieldByName('SCRQ').Value;
Edit1.Text:=DateToStr(D_date);
Dm_1.T_SCB.Edit;
end;
procedure TForm_Input_SCB.BB_abortClick(Sender: TObject);
begin
Edit3.Text:=IntToStr(DM_1.T_SCB.RecordCount );
BB_Append_Sattus:=False;
Init_BB_Enabled(True,True,False,False,False,True,False);
Init_input_Enabled(False,False);
Dm_1.T_SCB.Cancel;
BB_Append.SetFocus;
end;