📄 sfc_moinqry_c.pas
字号:
unit Sfc_MoInQry_C;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Condition, Db, AdODB, StdCtrls, ExtEdit, linkedit;
Type
TFrm_Sfc_MoInQry_C = Class(TFrm_Base_Condition)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Cmbx_LineStatus: TComboBox;
Label5: TLabel;
ExtEdt_DeptCode: TLinkEdit;
Lbl_DeptName: TEdit;
Edt_StArtMoNo: TLinkEdit;
Edt_EndMoNo: TLinkEdit;
procedure Edt_StArtMoNoExit(Sender: TObject);
procedure Edt_EndMoNoExit(Sender: TObject);
procedure Edt_StArtMoNoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn_okClick(Sender: TObject);
procedure Cmbx_LineStatusExit(Sender: TObject);
procedure ExtEdt_DeptCodeExit(Sender: TObject);
procedure Edt_StArtMoNoButtonClick(Sender: TObject);
private
{ Private declarations }
public
FStArtMoNo,FendMoNo,FDeptCode :String;
FLineStatus :Integer;
{ Public declarations }
end;
var
Frm_Sfc_MoInQry_C: TFrm_Sfc_MoInQry_C;
implementation
Uses Sys_Global,Sfc_MoOutQry_Hint;
{$R *.DFM}
procedure TFrm_Sfc_MoInQry_C.Edt_StArtMoNoExit(Sender: TObject);
begin
inherited;
If ActiveControl.Name='btn_Cancel' then
Exit;
If Edt_StArtMoNo.Text='' then
begin
DispInfo('起始订单号不能为空!',1);
Edt_StArtMoNo.SetFocus;
Abort;
end;
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Select Count(*) As RecCount from Mo '+
' Where MoNo='''+Edt_StArtMoNo.Text+''''+
' and DeptCode='''+ExtEdt_DeptCode.Text+'''');
Open;
If fieldbyname('RecCount').AsInteger<=0 then
begin
DispInfo('订单号不存在,或领料部门不正确!',1);
Abort;
end;
end;
If Edt_EndMoNo.Text='' then Edt_EndMoNo.Text:=Edt_StArtMoNo.Text;
end;
procedure TFrm_Sfc_MoInQry_C.Edt_EndMoNoExit(Sender: TObject);
begin
inherited;
If ActiveControl.Name='btn_Cancel' then
Exit;
If Edt_EndMoNo.Text<>'' then
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Select Count(*) As RecCount from Mo '+
' Where MoNo='''+Edt_EndMoNo.Text+''''+
' and DeptCode='''+ExtEdt_DeptCode.Text+'''');
Open;
If fieldbyname('RecCount').AsInteger<=0 then
begin
DispInfo('订单号不存在,或领料部门不正确!',1);
Abort;
end;
end;
If (Edt_EndMoNo.Text<Edt_StArtMoNo.Text) and (Edt_EndMoNo.Text<>'') then
begin
DispInfo('终止订单号不能小于起始订单号!',1);
Abort;
end;
end;
procedure TFrm_Sfc_MoInQry_C.Edt_StArtMoNoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If key=Vk_F9 then
begin
If Trim(ExtEdt_DeptCode.Text)='' then
begin
DispInfo('请先输入部门代码!',1);
ExtEdt_DeptCode.SetFocus;
Abort;
end;
Application.CreateForm(TFrm_Sfc_MoOutQry_Hint,Frm_Sfc_MoOutQry_Hint);
Frm_Sfc_MoOutQry_Hint.InitFrom(AdoQry_Tmp.Connection,ExtEdt_DeptCode.Text);
If Frm_Sfc_MoOutQry_Hint.ShowModal=MrOk then
begin
TEdit(Sender).Text:=Frm_Sfc_MoOutQry_Hint.AdoQry_Tmp.fieldbyname('MoNo').AsString;
end;
Frm_Sfc_MoOutQry_Hint.Release;
end;
end;
procedure TFrm_Sfc_MoInQry_C.btn_okClick(Sender: TObject);
var OldendMoNo :String;
begin
// inherited;
OldendMoNo:=Edt_EndMoNo.Text;
Edt_StArtMoNoExit(Edt_StArtMoNo);
Edt_EndMoNo.Text:=OLdendMoNo; //此处之所以这样处理,是因为在起始订单号的验证中可能改变endMONO的值
Edt_EndMoNoExit(Edt_EndMoNo);
Cmbx_LineStatusExit(Cmbx_LineStatus);
FLineStatus:=Cmbx_LineStatus.ItemIndex+6;
FDeptCode:=Trim(ExtEdt_DeptCode.Text);
FStArtMoNo:=Trim(Edt_StArtMoNo.Text);
If Trim(Edt_EndMoNo.Text)<>'' then
FendMoNo:=Trim(Edt_EndMoNo.Text)
Else
FendMoNo:='ZZZZZZZZ'; //如果为空则表示没有上限,为了写SQL语句简单,取可能的最大值;
Condition:='';
If Edt_EndMoNo.text<>'' then
ConditionHint:='生产订单号从:'+FStArtMoNo+' 到:'+Edt_EndMoNo.Text+
'; 领料部门:'+ExtEdt_DeptCode.text+' '+Lbl_DeptName.text
Else
ConditionHint:='生产订单号起始:'+FStArtMoNo+'(结束无)'+
'; 领料部门:'+ExtEdt_DeptCode.text+' '+Lbl_DeptName.text;
ModalResult:=Mrok;
end;
procedure TFrm_Sfc_MoInQry_C.Cmbx_LineStatusExit(Sender: TObject);
begin
inherited;
If Cmbx_LineStatus.Text='' then
begin
DispInfo('请选择一种行状态!',1);
Cmbx_LineStatus.SetFocus;
Abort;
end;
end;
procedure TFrm_Sfc_MoInQry_C.ExtEdt_DeptCodeExit(Sender: TObject);
begin
inherited;
with AdoQry_tmp do
begin
Close;
sql.text:='select DeptName from Dept where DeptCode='+QuotedStr(ExtEdt_DeptCode.text);
open;
if not eof then
Lbl_DeptName.Text:=fieldbyname('DeptName').AsString;
end;
end;
procedure TFrm_Sfc_MoInQry_C.Edt_StArtMoNoButtonClick(Sender: TObject);
begin
inherited;
If Trim(ExtEdt_DeptCode.Text)='' then
begin
DispInfo('请先输入部门代码!',1);
ExtEdt_DeptCode.SetFocus;
Abort;
end;
Application.CreateForm(TFrm_Sfc_MoOutQry_Hint,Frm_Sfc_MoOutQry_Hint);
Frm_Sfc_MoOutQry_Hint.InitFrom(AdoQry_Tmp.Connection,ExtEdt_DeptCode.Text);
If Frm_Sfc_MoOutQry_Hint.ShowModal=MrOk then
begin
TEdit(Sender).Text:=Frm_Sfc_MoOutQry_Hint.AdoQry_Tmp.fieldbyname('MoNo').AsString;
end;
Frm_Sfc_MoOutQry_Hint.Release;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -