pm_pmparam.pas

来自「一个MRPII系统源代码版本」· PAS 代码 · 共 516 行

PAS
516
字号
unit Pm_PmParam;

Interface

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

Type
  TFrm_Pm_PmParam = Class(TFrm_Base_Dialog)
    PageControl1: TPageControl;
    TbSht_InfoSet: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edt_ForwArdDaysDeny: TEdit;
    Label4: TLabel;
    Edt_BackwArdDaysDeny: TEdit;
    Label5: TLabel;
    Edt_OverQtydeny_Percent: TEdit;
    Label6: TLabel;
    Edt_ForWArdDaysOk: TEdit;
    Label7: TLabel;
    Edt_BackwArdDaysOK: TEdit;
    TbSht_ClassInfo2: TTabSheet;
    Label30: TLabel;
    Edt_PoInfo1: TEdit;
    Label31: TLabel;
    Edt_PoInfo2: TEdit;
    Label32: TLabel;
    Edt_PoInfo3: TEdit;
    Label33: TLabel;
    Edt_PoInfo4: TEdit;
    Label34: TLabel;
    Edt_PoInfo5: TEdit;
    Label35: TLabel;
    Edt_PoInfo7: TEdit;
    Label36: TLabel;
    Edt_PoInfo8: TEdit;
    Label37: TLabel;
    Edt_PoInfo9: TEdit;
    Label39: TLabel;
    Edt_PoInfo6: TEdit;
    Label41: TLabel;
    Edt_PoLineNum: TEdit;
    Label42: TLabel;
    Edt_PoPageDefine: TEdit;
    Cmbx_PcNeedAudit: TComboBox;
    Label8: TLabel;
    Cmbx_PoNeedAudit: TComboBox;
    Label9: TLabel;
    cmbx_autoClosePo: TComboBox;
    Label10: TLabel;
    Cmbx_BuyerCtrlType: TComboBox;
    Label11: TLabel;
    Edt_SSDay: TEdit;
    Label12: TLabel;
    cmb_Printassess: TComboBox;
    Label13: TLabel;
    cmb_Printterm: TComboBox;
    Label14: TLabel;
    edt_PoTermCode: TEdit;
    Label15: TLabel;
    Cmb_IsPriceRequestPass: TComboBox;
    Cmb_PoPriceRequestIsPo: TComboBox;
    Label16: TLabel;
    Label17: TLabel;
    Edt_PchOrderSignIn: TEdit;
    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_ForwArdDaysDenyExit(Sender: TObject);
    procedure Edt_OverQtydeny_PercentExit(Sender: TObject);
    procedure Edt_SSDayExit(Sender: TObject);
  private
    { Private declarations }
    FReadOnly:Boolean;
  public
   procedure InitForm(AdoConnection:TAdoConnection;ReadOnly:Boolean);
    { Public declarations }
  end;

var
  Frm_Pm_PmParam: TFrm_Pm_PmParam;

implementation

{$R *.DFM}

uses Sys_Global;
{ TFrm_Bas_Param }


procedure TFrm_Pm_PmParam.InitForm(AdoConnection: TAdoConnection;
  ReadOnly: Boolean);
var I: integer;
begin
  FReadOnly:=ReadOnly;
  if fReadOnly=True then
   self.Caption:='系统参数查询';
  AdoQry_Tmp.Connection:=AdOConnection;
  AdoQry_Tmp.Close ;
  AdoQry_Tmp.SQL.clear ;
  AdoQry_Tmp.SQL.Add('select * from PmParam');
  AdoQry_Tmp.Open ;
  With AdoQry_Tmp do
  begin
    if Locate('PmParamCode','BuyerCtrlType',[]) then
      cmbx_BuyerCtrlType.ItemIndex:=fieldbyname('PmParamValueN').asinteger;

    If  Locate('PmParamCode','PcNeedAudit',[])  then
      Cmbx_PcNeedAudit.ItemIndex :=fieldbyname('PmParamValuen').AsInteger;

    If  Locate('PmParamCode','PoNeedAudit',[])  then
      Cmbx_PoNeedAudit.ItemIndex :=fieldbyname('PmParamValuen').AsInteger;

    If  Locate('PmParamCode','PrintAssess',[])  then
      cmb_Printassess.ItemIndex :=fieldbyname('PmParamValuen').AsInteger;

    If  Locate('PmParamCode','autoClosePo',[])  then
      Cmbx_autoClosePo.ItemIndex :=fieldbyname('PmParamValuen').AsInteger;

    If  Locate('PmParamCode','PmOrderISPrintTerm',[])  then
     begin
       Cmb_Printterm.ItemIndex :=fieldbyname('PmParamValuen').AsInteger;
       edt_PoTermCode.Text:=fieldbyname('PmParamValuec').asstring;
     end;
     
    If  Locate('PmParamCode','ForwArdDaysdeny',[])  then
      Edt_ForwArdDaysdeny.text:=IntToStr(fieldbyname('PmParamValuen').AsInteger);

    If  Locate('PmParamCode','BackwArdDaysdeny',[])  then
      Edt_BackwArdDaysdeny.text:=IntToStr(fieldbyname('PmParamValuen').asInteger);

    If  Locate('PmParamCode','OverQtydeny_Percent',[])  then
      Edt_OverQtydeny_Percent.text:=FloatToStr(fieldbyname('PmParamValuen').AsFloat);

    If  Locate('PmParamCode','ForWArdDaysOk',[])  then
      Edt_ForWArdDaysOk.text:=IntToStr(fieldbyname('PmParamValuen').AsInteger);

    If  Locate('PmParamCode','BackWArdDaysOk',[])  then
      Edt_BackWArdDaysOk.text:=Inttostr(fieldbyname('PmParamValuen').AsInteger);

    If  Locate('PmParamCode','IsPriceRequestPass',[])  then
       Cmb_IsPriceRequestPass.ItemIndex := fieldbyname('PmParamValuen').AsInteger;

    If  Locate('PmParamCode','PoPriceRequestispo',[])  then
       Cmb_PoPriceRequestIsPo.ItemIndex := fieldbyname('PmParamValuen').AsInteger;

    If  Locate('PmParamCode','PchOrderSignIn',[])  then
       Edt_PchOrderSignIn.Text := fieldbyname('PmParamValueC').AsString;

    If  Locate('PmParamCode','PoLineNum',[])  then
      Edt_PoLineNum.text:=IntToStr(fieldbyname('PmParamValuen').AsInteger);

    If  Locate('PmParamCode','PoPageDefine',[])  then
      Edt_PoPageDefine.Text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo1',[])  then
      Edt_PoInfo1.Text :=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo2',[])  then
      Edt_PoInfo2.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo3',[])  then
      Edt_PoInfo3.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo4',[])  then
      Edt_PoInfo4.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo5',[])  then
      Edt_PoInfo5.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo6',[])  then
      Edt_PoInfo6.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo7',[])  then
      Edt_PoInfo7.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo8',[])  then
      Edt_PoInfo8.text:=fieldbyname('PmParamValuec').asstring;

    If  Locate('PmParamCode','PoInfo9',[])  then
      Edt_PoInfo9.text:=fieldbyname('PmParamValuec').asstring;

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

    Btn_OK.enabled:=False;
    TbSht_InfoSet.Show;
    cmbx_BuyerCtrlType.SetFocus;
  end;
end;

procedure TFrm_Pm_PmParam.Edt_BuyerCtrlTypeChange(Sender: TObject);
begin
  inherited;
  if not FReadOnly then
    Btn_Ok.Enabled :=True;
end;

procedure TFrm_Pm_PmParam.btn_okClick(Sender: TObject);
begin
  inherited;
  With AdoQry_Tmp do
  begin
   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValueN='+inttostr(Cmbx_BuyerCtrlType.ItemIndex)+
     ' where PmParamCode='''+'BuyerCtrlType'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValueN='+inttostr(Cmb_IsPriceRequestPass.ItemIndex)+
     ' where PmParamCode='''+'ISPriceRequestPass'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValueN='+inttostr(Cmb_PoPriceRequestIsPo.ItemIndex)+
     ' where PmParamCode='''+'PoPriceRequestIsPo'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValueC='+QuotedStr(Edt_PchOrderSignIn.Text)+
     ' where PmParamCode='''+'PchOrderSignIn'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuen='+IntToStr(Cmbx_PcNeedAudit.ItemIndex)+
     ' where PmParamCode='''+'PcNeedAudit'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuen='+IntToStr(Cmb_Printassess.ItemIndex)+
     ' where PmParamCode='''+'PrintAssess'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuen='+IntToStr(Cmbx_PoNeedAudit.ItemIndex)+
     ' where PmParamCode='''+'PoNeedAudit'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuen='+IntToStr(Cmbx_autoClosePo.ItemIndex)+
     ' where PmParamCode='''+'autoClosePo'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuen='+IntToStr(Cmb_Printterm.ItemIndex)+','
            +'  PmParamValuec='+quotedstr(edt_PoTermCode.Text) +
     ' where PmParamCode='''+'PmOrderISPrintTerm'+'''');
   ExecSql;

   If Edt_PoLineNum.text<>'' then
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen='+Edt_PoLineNum.text+
       ' where PmParamCode='''+'PoLineNum'+'''');
     ExecSql;
   end
   else
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen=0'+
       ' where PmParamCode='''+'PoLineNum'+'''');
     ExecSql;
   end;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo1.text)+''''+
     ' where PmParamCode='''+'PoInfo1'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo2.text)+''''+
     ' where PmParamCode='''+'PoInfo2'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo3.text)+''''+
     ' where PmParamCode='''+'PoInfo3'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo4.text)+''''+
     ' where PmParamCode='''+'PoInfo4'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo5.text)+''''+
     ' where PmParamCode='''+'PoInfo5'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo6.text)+''''+
     ' where PmParamCode='''+'PoInfo6'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo7.text)+''''+
     ' where PmParamCode='''+'PoInfo7'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo8.text)+''''+
     ' where PmParamCode='''+'PoInfo8'+'''');
   ExecSql;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoInfo9.text)+''''+
     ' where PmParamCode='''+'PoInfo9'+'''');
   ExecSql;

   If Edt_ForwArddaysDeny.text<>'' then
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen='+Edt_ForwArddaysDeny.text+
       ' where PmParamCode='''+'ForwArddaysDeny'+'''');
     ExecSql;
   end
   else
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen=0'+
       ' where PmParamCode='''+'ForwArddaysDeny'+'''');
     ExecSql;
   end;

   If  Edt_BackwArddaysDeny.text<>'' then
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen='+Trim(Edt_BackwArddaysDeny.text)+
       ' where PmParamCode='''+'BackwArddaysDeny'+'''');
     ExecSql;
   end
   else
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen=0'+
     ' where PmParamCode='''+'BackwArddaysDeny'+'''');
     ExecSql;
   end;

   if Edt_OverQtydeny_Percent.text<>'' then
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen='+Trim(Edt_OverQtydeny_Percent.text)+
       ' where PmParamCode='''+'OverQtydeny_Percent'+'''');
     ExecSql;
   end
   else
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen=0'+
     ' where PmParamCode='''+'OverQtydeny_Percent'+'''');
     ExecSql;
   end;

   If Edt_ForWArdDaysOk.text<>'' then
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen='+Trim(Edt_ForWArdDaysOk.text)+
       ' where PmParamCode='''+'ForWArdDaysOk'+'''');
     ExecSql;
   end
   else
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen=0'+
     ' where PmParamCode='''+'ForWArdDaysOk'+'''');
     ExecSql;
   end;

   If Edt_BackWArdDaysOk.text<>'' then
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen='+Trim(Edt_BackWArdDaysOk.text)+
       ' where PmParamCode='''+'BackWArdDaysOk'+'''');
     ExecSql;
   end
   else
   begin
     Close ;
     SQL.clear ;
     SQL.Add('Update PmParam Set PmParamValuen=0'+
     ' where PmParamCode='''+'BackWArdDaysOk'+'''');
     ExecSql;
   end;

   Close ;
   SQL.clear ;
   SQL.Add('Update PmParam Set PmParamValuec='''+Trim(Edt_PoPageDefine.text)+''''+
     ' where PmParamCode='''+'PoPageDefine'+'''');
   ExecSql;

   SQL.Add('Update PmParam Set PmParamValueN='+Edt_SSDay.Text+
     ' where PmParamCode='''+'SSForwArdDay'+'''');
   ExecSql;

  end;
  Close;
end;

procedure TFrm_Pm_PmParam.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action:=CaFree;
end;

procedure TFrm_Pm_PmParam.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  If Key=Vk_EScApe then
    Close;
end;

procedure TFrm_Pm_PmParam.btn_CancelClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TFrm_Pm_PmParam.Edt_ForwArdDaysDenyExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel') or FReadOnly then
    exit;
  If TEdit(Sender).Text<>'' then
  try
    StrToInt(Tedit(sender).text);
  except
    DispInfo('请输入整数值!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

procedure TFrm_Pm_PmParam.Edt_OverQtydeny_PercentExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel') or FReadOnly then
    exit;
  IF Self.Text<>'' then
  try
    StrToFloat(Edt_OverQtydeny_Percent.text);
  except
    DispInfo('请输入合法百分比数值!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end;

  IF (Self.Text<>'') and
    ((StrToFloat(Edt_OverQtydeny_Percent.Text)>1000) or (StrToFloat(Edt_OverQtydeny_Percent.Text)<0)) then
  begin
    DispInfo('百分比超出范围!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

procedure TFrm_Pm_PmParam.Edt_SSDayExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel') or FReadOnly then
    exit;
  IF Self.Text<>'' then
  try
    StrToInt(Edt_SSDay.text);
  except
    DispInfo('请输入合法的数值!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
  IF (StrToInt(Edt_SSDay.Text)>99) or (StrToInt(Edt_SSDay.Text)<0) then
  begin
    DispInfo('建议显示天数超出范围!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

end.

⌨️ 快捷键说明

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