⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mrp_param.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Mrp_Param;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Dialog, Db, AdODB, StdCtrls, ExtCtrls, ComCtrls, Mask;

Type
  TFrm_Mrp_Param = Class(TFrm_Base_Dialog)
    Label2: TLabel;
    Cmbx_autoCloseMps: TComboBox;
    Label9: TLabel;
    cmbx_autoBalanceMps: TComboBox;
    Label1: TLabel;
    Cmbx_CanOverPlan: TComboBox;
    Label11: TLabel;
    Edt_SSDay: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Cmbx_WhereRunMrp: TComboBox;
    EDt_AutoRunMrp: TMaskEdit;
    Label7: TLabel;
    Cmb_AutoRunMrp: TComboBox;
    Label10: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    MEdt_AutoRunPSI1: TMaskEdit;
    MEdt_AutoRunPSI2: TMaskEdit;
    MEdt_AutoRunPSI3: TMaskEdit;
    Panel3: TPanel;
    Panel1: TPanel;
    Panel2: TPanel;
    Label14: TLabel;
    Cmb_ReceiveOrder: TComboBox;
    Label15: TLabel;
    cmb_Mrpds: TComboBox;
    Bevel1: TBevel;
    procedure Edt_BuyerCtrlTypeChange(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure btn_CancelClick(Sender: TObject);
    procedure Edt_SSDayExit(Sender: TObject);
    procedure EDt_AutoRunMrpExit(Sender: TObject);
    procedure MEdt_AutoRunPSI1Exit(Sender: TObject);
    procedure MEdt_AutoRunPSI2Exit(Sender: TObject);
    procedure MEdt_AutoRunPSI3Exit(Sender: TObject);
    procedure MEdt_AutoRunPSI1Change(Sender: TObject);
  private
    { Private declarations }
    FReadOnly:Boolean;
  public
   procedure InitForm(AdoConnection:TAdoConnection;ReadOnly:Boolean);
    { Public declarations }
  end;

var
  Frm_Mrp_Param: TFrm_Mrp_Param;

implementation

{$R *.DFM}
uses Sys_Global;
{ TFrm_Bas_Param }


procedure TFrm_Mrp_Param.InitForm(AdoConnection: TAdoConnection;
  ReadOnly: Boolean);
var I: integer;
begin
  FReadOnly:=ReadOnly;
  AdoQry_Tmp.Connection:=AdOConnection;
  AdoQry_Tmp.Close ;
  AdoQry_Tmp.SQL.clear ;
  AdoQry_Tmp.SQL.Add('select * from MrpParam');
  AdoQry_Tmp.Open ;
  With AdoQry_Tmp do
  begin     
    if Locate('MrpParamCode','autoCloseMps',[]) then
      cmbx_autoCloseMps.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;

    if Locate('MrpParamCode','ReceiveOrder',[]) then
      Cmb_ReceiveOrder.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;

{    if Locate('MrpParamCode','autoCloseMo',[]) then
      cmbx_autoCloseMo.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;
}
    if Locate('MrpParamCode','autoBalanceMps',[]) then
      cmbx_autoBalanceMps.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;

    if Locate('MrpParamCode','canOverPlan',[]) then
      cmbx_CanOverPlan.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;

    If  Locate('MrpParamCode','SSForWArdDay',[])  then
      Edt_SSDay.text:=IntToStr(fieldbyname('MrpParamValuen').AsInteger);

    If  Locate('MrpParamCode','AutoRunMrp',[])  then
      EDt_AutoRunMrp.text:=fieldbyname('MrpParamValueC').Asstring;
//
    If  Locate('MrpParamCode','MrpdatAreSource',[])  then
      cmb_Mrpds.ItemIndex:=fieldbyname('MrpParamValueN').Asinteger-1;

    If  Locate('MrpParamCode','AutoRunPSI1',[])  then
      MEdt_AutoRunPSI1.text:=fieldbyname('MrpParamValueC').Asstring;

    If  Locate('MrpParamCode','AutoRunPSI2',[])  then
      MEdt_AutoRunPSI2.text:=fieldbyname('MrpParamValueC').Asstring;

    If  Locate('MrpParamCode','AutoRunPSI3',[])  then
      MEdt_AutoRunPSI3.text:=fieldbyname('MrpParamValueC').Asstring;


//
    if Locate('MrpParamCode','AutoRunMrp',[]) then
      Cmb_AutoRunMrp.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;

{
    If  Locate('MrpParamCode','Overqtydeny_Percent',[])  then
      Edt_Overqtydeny_Percent.text:=fieldbyname('MrpParamValueN').Asstring;
}
    if Locate('MrpParamCode','WhereRunMrp',[]) then
      Cmbx_WhereRunMrp.ItemIndex:=fieldbyname('MrpParamValueN').asinteger;

    if Cmb_AutoRunMrp.ItemIndex=0 then
      EDt_AutoRunMrp.Enabled := False
     else
       EDt_AutoRunMrp.Enabled := True;
    Btn_OK.enabled:=False;
    cmbx_autoCloseMps.SetFocus;
  end;
end;

procedure TFrm_Mrp_Param.Edt_BuyerCtrlTypeChange(Sender: TObject);
begin
  inherited;
  if Cmb_AutoRunMrp.ItemIndex=0 then
  begin
    EDt_AutoRunMrp.Enabled := False;
    EDt_AutoRunMrp.Text :='';
  end
  else
    EDt_AutoRunMrp.Enabled := True;
  if not FReadOnly then
    Btn_Ok.Enabled :=True;
end;

procedure TFrm_Mrp_Param.btn_okClick(Sender: TObject);
var sqltext:string;
begin
  inherited;
{  With AdoQry_Tmp do
  begin  }
    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('autoCloseMps');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin
      sqltext:='insert into MrpParam(MrpParamCode,MrpParamName,MrpParamValuen,MrpParamValuec) '
              +' Values ('+quotedstr('autoCloseMps')      +','
              +quotedstr('完成后是否自动关闭主计划行')+','
              +inttostr(cmbx_autoCloseMps.Itemindex)+','
              +quotedstr('')+')';
      Executesql(AdoQry_tmp,sqltext,1);
    end
    else 
    begin
      sqltext:=' Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_autoCloseMps.ItemIndex)+
               ' where MrpParamCode='''+'autoCloseMps'+'''';
      Executesql(AdoQry_tmp,sqltext,1);
    end;
//------------------------------------------------------------------------------------------------------------------------------
{    Close ;
    SQL.clear ;
    SQL.Add('Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_autoCloseMps.ItemIndex)+
      ' where MrpParamCode='''+'autoCloseMps'+'''');
    ExecSql;}

    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('ReceiveOrder');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin
      sqltext:='insert into MrpParam(MrpParamCode,MrpParamName,MrpParamValuen,MrpParamValuec) '
              +' Values ('+quotedstr('autoCloseMps')      +','
              +quotedstr('接生产/采购建议是否可以超出系统建议余量')+','
              +inttostr(cmb_receiveOrder.Itemindex)+','
              +quotedstr('')+')';
      Executesql(AdoQry_tmp,sqltext,1);
              
    end
    else 
    begin
      sqltext:=' Update MrpParam Set MrpParamValueN='+inttostr(Cmb_receiveOrder.ItemIndex)+
               ' where MrpParamCode='''+'ReceiveOrder'+'''';
      Executesql(AdoQry_tmp,sqltext,1);
    end;
//-----------------------------------------------------------------------------------------

{    Close ;
    SQL.clear ;
    SQL.Add('Update MrpParam Set MrpParamValueN='+inttostr(Cmb_ReceiveOrder.ItemIndex)+
      ' where MrpParamCode='''+'ReceiveOrder'+'''');
    ExecSql;
 }
{    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('autoCloseMo');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin
      sqltext:='insert into MrpParam(MrpParamCode,MrpParamName,MrpParamValuen,MrpParamValuec) '
              +' Values ('+quotedstr('autoCloseMo')      +','
              +quotedstr('完成后是否自动关闭订单行')+','
              +inttostr(cmbx_autoCloseMo.Itemindex)+','
              +quotedstr('')+')';
      Executesql(AdoQry_tmp,sqltext,1);
              
    end
    else 
    begin
      sqltext:=' Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_autoCloseMo.ItemIndex)+
               ' where MrpParamCode='''+'autoCloseMo'+'''';
      Executesql(AdoQry_tmp,sqltext,1);
    end;
}//-------------------------------------------------------------------------------------------
{    Close ;
    SQL.clear ;
    SQL.Add('Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_autoCloseMo.ItemIndex)+
      ' where MrpParamCode='''+'autoCloseMo'+'''');
    ExecSql;
}
    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('autoBalanceMps');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin
      sqltext:='insert into MrpParam(MrpParamCode,MrpParamName,MrpParamValuen,MrpParamValuec) '
              +' Values ('+quotedstr('autoBalanceMps')      +','
              +quotedstr('销售出库时是否自动核销主计划行')+','
              +inttostr(cmbx_autoBalanceMps.Itemindex)+','
              +quotedstr('')+')';
      Executesql(AdoQry_tmp,sqltext,1);
              
    end
    else 
    begin
      sqltext:=' Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_autoBalanceMps.ItemIndex)+
               ' where MrpParamCode='''+'autoBalanceMps'+'''';
      Executesql(AdoQry_tmp,sqltext,1);
    end;
//-----------------------------------------------------------------------------------------------------
{    Close ;
    SQL.clear ;
    SQL.Add('Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_autoBalanceMps.ItemIndex)+
      ' where MrpParamCode='''+'autoBalanceMps'+'''');
    ExecSql;
}
    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('canOverPlan');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin
      sqltext:='insert into MrpParam(MrpParamCode,MrpParamName,MrpParamValuen,MrpParamValuec) '
              +' Values ('+quotedstr('canOverPlan')      +','
              +quotedstr('手工核销主计划时,是否允许超生产订货量')+','
              +inttostr(cmbx_CanOverPlan.Itemindex)+','
              +quotedstr('')+')';
      Executesql(AdoQry_tmp,sqltext,1);
              
    end
    else 
    begin
      sqltext:=' Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_CanOverPlan.ItemIndex)+
               ' where MrpParamCode='''+'canOverPlan'+'''';
      Executesql(AdoQry_tmp,sqltext,1);
    end;
//-------------------------------------------------------------------------------------------
{    Close ;
    SQL.clear ;
    SQL.Add('Update MrpParam Set MrpParamValueN='+inttostr(Cmbx_CanOverPlan.ItemIndex)+
      ' where MrpParamCode='''+'canOverPlan'+'''');
    ExecSql;
}
    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('autoRunMrp');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin
      sqltext:='insert into MrpParam(MrpParamCode,MrpParamName,MrpParamValuen,MrpParamValuec) '
              +' Values ('+quotedstr('autoRunMrp')      +','
              +quotedstr('每天自动运行Mrp的时间')+','
              +inttostr(cmb_autoRunMrp.Itemindex)+','
              +quotedstr('')+')';
      Executesql(AdoQry_tmp,sqltext,1);
              
    end
    else 
    begin
      sqltext:=' Update MrpParam Set MrpParamValueN='+inttostr(Cmb_autoRunMrp.ItemIndex)+
               ' where MrpParamCode='''+'autoRunMrp'+'''';
      Executesql(AdoQry_tmp,sqltext,1);
    end;
//---------------------------------------------------------------------------------------------------
{    Close ;
    SQL.clear ;
    SQL.Add('Update MrpParam Set MrpParamValueN='+inttostr(Cmb_AutoRunMrp.ItemIndex)+
      ' where MrpParamCode='''+'AutoRunMrp'+'''');
    ExecSql;
}
    sqltext:='select * from MrpParam where MrpParamCode='+quotedstr('MrpdatAreSource');
    Executesql(AdoQry_Tmp,sqltext,0)    ;
    if AdoQry_tmp.RecordCount=0 then
    begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -