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

📄 sfc_mnlistrequest_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 5 页
字号:
       cmbx_WhCode3.ItemIndex :=-1;

    if (AdoQry_Body.fieldbyname('whCode4').asstring<>'')  then
       InitCmBxText(cmbx_WhCode4,getCode(AdoQry_Body.fieldbyname('whCode4').asstring))
    else if (AdoQry_Body.fieldbyname('whCode4').asstring='') and (cmbx_WhCode4.Enabled) then
       InitCmBxText(cmbx_WhCode4,tmp_WhCode)
    else
       cmbx_WhCode4.ItemIndex :=-1;

    if (AdoQry_Body.fieldbyname('whCode5').asstring<>'')  then
       InitCmBxText(cmbx_WhCode5,getCode(AdoQry_Body.fieldbyname('whCode5').asstring))
    else if (AdoQry_Body.fieldbyname('whCode5').asstring='') and (cmbx_WhCode5.Enabled) then
       InitCmBxText(cmbx_WhCode5,tmp_WhCode)
    else
       cmbx_WhCode5.ItemIndex :=-1;
  end
  else
  begin
    cmbx_WhCode1.ItemIndex:=-1;
    cmbx_WhCode2.ItemIndex:=-1;
    cmbx_WhCode3.ItemIndex:=-1;
    cmbx_WhCode4.ItemIndex:=-1;
    cmbx_WhCode5.ItemIndex:=-1;
  end;
  if status='Add' then
    begin
      cmbx_WhCode1.ItemIndex:=0;
      cmbx_WhCode2.ItemIndex:=-1;
      cmbx_WhCode3.ItemIndex:=-1;
      cmbx_WhCode4.ItemIndex:=-1;
      cmbx_WhCode5.ItemIndex:=-1;
    end;
  //有条件的初始化货位COMBBOX
//  InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode1,'WhPosition','WhPositionCode',
//      'WhPositionName','whCode='''+getCode(cmbx_WhCode1.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
  initcmbx1(cmbx_WhpCode1,Extedt_ItemCode.text,'nwh',getCode(cmbx_WhCode1.Text));
  InitCmBxText(cmbx_WhpCode1,getCode(AdoQry_Body.fieldbyname('WhPositionCode1').asstring));
//  InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode2,'WhPosition','WhPositionCode',
//      'WhPositionName','whCode='''+getCode(cmbx_WhCode2.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
  initcmbx1(cmbx_WhpCode2,Extedt_ItemCode.text,'nwh',getCode(cmbx_WhCode2.Text));
  InitCmBxText(cmbx_WhpCode2,getCode(AdoQry_Body.fieldbyname('WhPositionCode2').asstring));
//  InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode3,'WhPosition','WhPositionCode',
//      'WhPositionName','whCode='''+getCode(cmbx_WhCode3.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
  initcmbx1(cmbx_WhpCode3,Extedt_ItemCode.text,'nwh',getCode(cmbx_WhCode3.Text));
  InitCmBxText(cmbx_WhpCode3,getCode(AdoQry_Body.fieldbyname('WhPositionCode3').asstring));
//
//  InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode4,'WhPosition','WhPositionCode',
//      'WhPositionName','whCode='''+getCode(cmbx_WhCode4.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
  initcmbx1(cmbx_WhpCode4,Extedt_ItemCode.text,'nwh',getCode(cmbx_WhCode4.Text));
  InitCmBxText(cmbx_WhpCode4,getCode(AdoQry_Body.fieldbyname('WhPositionCode4').asstring));
//
//  InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode5,'WhPosition','WhPositionCode',
//      'WhPositionName','whCode='''+getCode(cmbx_WhCode5.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
  initcmbx1(cmbx_WhpCode5,Extedt_ItemCode.text,'nwh',getCode(cmbx_WhCode5.Text));
  InitCmBxText(cmbx_WhpCode5,getCode(AdoQry_Body.fieldbyname('WhPositionCode5').asstring));

  if cmbx_WhCode1.Enabled  then
  begin
    whCode:=getCode(cmbx_WhCode1.Text) ;
    WhPositionCode:=getCode(cmbx_WhpCode1.Text) ;
  end;
  if cmbx_WhCode2.Enabled  then
  begin
    whCode:=getCode(cmbx_WhCode2.Text) ;
    WhPositionCode:=getCode(cmbx_WhpCode2.Text) ;
  end;
  if cmbx_WhCode3.Enabled  then
  begin
    whCode:=getCode(cmbx_WhCode3.Text) ;
    WhPositionCode:=getCode(cmbx_WhpCode3.Text) ;
  end;
//
  if cmbx_WhCode4.Enabled  then
  begin
    whCode:=getCode(cmbx_WhCode4.Text) ;
    WhPositionCode:=getCode(cmbx_WhpCode4.Text) ;
  end;
  if cmbx_WhCode5.Enabled  then
  begin
    whCode:=getCode(cmbx_WhCode5.Text) ;
    WhPositionCode:=getCode(cmbx_WhpCode5.Text) ;
  end;
    CurrentInvfields:=getInvfield(AdoQry_tmp,whCode,WhPositionCode,'CurrentInv');
    with AdoQry_tmp do
    begin
      Close;
      sql.clear;
      sql.Add('select '+CurrentInvfields+ ' as onhandInv from CurrentInv where whCode='''+whCode+''' and WhPositionCode='''+WhPositionCode+''' and ItemCode='''+Extedt_ItemCode.text+'''');
      open;
      if not eof then
        lbl_onhandInv.Caption:=fieldbyname('onhandInv').asstring
      else
      lbl_onhandInv.Caption:='0';
    end;
    if Extedt_ItemCode.Text<>'' then
    begin
      with AdoQry_tmp do
      begin
        Close;
        sql.Text:='select  Item.whCode,Warehouse.whName,onlydefaultwh from Item join Warehouse on Item.whCode=Warehouse.whCode where ItemCode='''+Extedt_ItemCode.text+'''';
        open;
        lbl_WhCode.Caption :=fieldbyname('whCode').asstring+' '+fieldbyname('whName').asstring;
        if fieldbyname('onlydefaultwh').asinteger=0 then
           lbl_useOther.Caption :='否';
        if fieldbyname('onlydefaultwh').asinteger=1 then
           lbl_useOther.Caption :='是';
      end;
    end;
    show_WhName;
end;

procedure TFrm_Sfc_MnListRequest_D.SaveBodyData;
var
  sqltext:string;
begin//把Form的控件值写入缓存,要Post
 inherited;

  with AdoQry_Body do
  begin
    if status='Add' then
    begin
      fieldbyname('UomName').AsString:=lbl_UomName.Caption;
      fieldbyname('MoRealqty').Asstring:='0';
      fieldbyname('moCtrlqty').asstring:='0';
    end;
    fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
    fieldbyname('ItemDESC').AsString:=ExtEdt_ItemCode.Text+' '+lbl_ItemName.Caption;
    if cmbx_WhCode1.Enabled then
    begin
      fieldbyname('whCode1').AsString:=getCode(cmbx_WhCode1.Text)+' '+lbl_CurwhCode.Caption;
      fieldbyname('WhPositionCode1').AsString:=getCode(cmbx_WhpCode1.Text)+' '+lbl_CurWhPosition.Caption;
    end;
    fieldbyname('Batchno1').Asstring:=edt_Batchno1.Text ;
//    fieldbyname('Requestqty1').Asstring:=edt_MoRequestqty1.Text;
    fieldbyname('realoutqty1').asstring:=edt_MoRealqty1.Text ;
    fieldbyname('Requesttime1').asstring:=lbl_Requesttime1.Caption ;
    if cmbx_WhCode2.Enabled then
    begin
      fieldbyname('whCode2').AsString:=getCode(cmbx_WhCode2.Text)+' '+lbl_CurwhCode.Caption;
      fieldbyname('WhPositionCode2').AsString:=getCode(cmbx_WhpCode2.Text)+' '+lbl_CurWhPosition.Caption;
    end;
    fieldbyname('Batchno2').Asstring:=edt_Batchno2.Text ;
//    fieldbyname('Requestqty2').Asstring:=edt_MoRequestqty2.Text;
    fieldbyname('realoutqty2').asstring:=edt_MoRealqty2.Text ;
    if lbl_Requesttime2.Caption<>'' then
       fieldbyname('Requesttime2').asstring:=lbl_Requesttime2.Caption ;
    if cmbx_WhCode3.Enabled then
    begin
      fieldbyname('whCode3').AsString:=getCode(cmbx_WhCode3.Text)+' '+lbl_CurwhCode.Caption;
      fieldbyname('WhPositionCode3').AsString:=getCode(cmbx_WhpCode3.Text)+' '+lbl_CurWhPosition.Caption;
    end;
    fieldbyname('Batchno3').Asstring:=edt_Batchno3.Text ;
//    fieldbyname('Requestqty3').Asstring:=edt_MoRequestqty3.Text;
    fieldbyname('realoutqty3').asstring:=edt_MoRealqty3.Text ;
    if lbl_Requesttime3.Caption<>'' then
       fieldbyname('Requesttime3').asstring:=lbl_Requesttime3.Caption ;
    if cmbx_WhCode4.Enabled then
    begin
      fieldbyname('whCode4').AsString:=getCode(cmbx_WhCode4.Text)+' '+lbl_CurwhCode.Caption;
      fieldbyname('WhPositionCode4').AsString:=getCode(cmbx_WhpCode4.Text)+' '+lbl_CurWhPosition.Caption;
    end;
    fieldbyname('Batchno4').Asstring:=edt_Batchno4.Text ;
//    fieldbyname('Requestqty3').Asstring:=edt_MoRequestqty3.Text;
    fieldbyname('realoutqty4').asstring:=edt_MoRealqty4.Text ;
    if lbl_Requesttime4.Caption<>'' then
       fieldbyname('Requesttime4').asstring:=lbl_Requesttime4.Caption ;
    if cmbx_WhCode5.Enabled then
    begin
      fieldbyname('whCode5').AsString:=getCode(cmbx_WhCode5.Text)+' '+lbl_CurwhCode.Caption;
      fieldbyname('WhPositionCode5').AsString:=getCode(cmbx_WhpCode5.Text)+' '+lbl_CurWhPosition.Caption;
    end;
    fieldbyname('Batchno5').Asstring:=edt_Batchno5.Text ;
//    fieldbyname('Requestqty3').Asstring:=edt_MoRequestqty3.Text;
    fieldbyname('realoutqty5').asstring:=edt_MoRealqty5.Text ;
    if lbl_Requesttime5.Caption<>'' then
       fieldbyname('Requesttime5').asstring:=lbl_Requesttime5.Caption ;
    Post;
  end;
end;

procedure TFrm_Sfc_MnListRequest_D.FormCreate(Sender: TObject);
begin
  inherited;
{  if status='Add' then
    SetFocus_Control:=Extedt_ItemCode //设置新增时要聚焦的控件
  else
    setfocus_Control:=cmbx_WhCode1; }
end;

procedure TFrm_Sfc_MnListRequest_D.SetStatus(CurrentStatus:String;var EnableControls:String);
begin
  inherited;
  //根据条件进行最初的控件的ENABLE
  if status='Add' then
  begin
    SetFocus_Control:=Extedt_ItemCode;
  end
  else
    SetFocus_Control:=cmbx_WhCode1;
  if (AdoQry_Body.fieldbyname('realoutqty1').asstring='')or
    (AdoQry_Body.fieldbyname('realoutqty1').asstring='0')then
  begin
    EnableControls:=EnableControls
      +'cmbx_WhCode1,cmbx_WhpCode1,edt_Batchno1,';
  end;
  if (AdoQry_Body.fieldbyname('realoutqty2').asstring='')or
    (AdoQry_Body.fieldbyname('realoutqty2').asstring='0')then
  begin
    EnableControls:=EnableControls
      +'cmbx_WhCode2,cmbx_WhpCode2,edt_Batchno2,';
  end;
  if (AdoQry_Body.fieldbyname('realoutqty3').asstring='')
    or(AdoQry_Body.fieldbyname('realoutqty3').asstring='0')then
  begin
    EnableControls:=EnableControls
      +'cmbx_WhCode3,cmbx_WhpCode3,edt_Batchno3,';
  end;
  if (AdoQry_Body.fieldbyname('realoutqty4').asstring='')
    or(AdoQry_Body.fieldbyname('realoutqty4').asstring='0')then
  begin
    EnableControls:=EnableControls
      +'cmbx_WhCode4,cmbx_WhpCode4,edt_Batchno4,';
  end;
  if (AdoQry_Body.fieldbyname('realoutqty5').asstring='')
    or(AdoQry_Body.fieldbyname('realoutqty5').asstring='0')then
  begin
    EnableControls:=EnableControls
      +'cmbx_WhCode5,cmbx_WhpCode5,edt_Batchno5,';
  end;
  if status='Add' then
    EnableControls:=EnableControls
      +'Extedt_ItemCode,cmbx_WhCode1,cmbx_WhpCode1,edt_Batchno1,';
end;


procedure TFrm_Sfc_MnListRequest_D.SetFormParam(frmParam1, frmParam2,
  frmParam3, frmParam4, frmParam5, frmParam6: string);
begin
  inherited;
  //BODY FORM 的参数传递
  tmp_Mono:=frmParam1;
  tmp_MoLineno:=frmParam2;
  whCode:=frmParam3;
  WhPositionCode:=frmParam4;
  tmp_Date:=frmParam5;
  tmp_ShiftType:=frmParam6;
end;

procedure TFrm_Sfc_MnListRequest_D.InOutItemCodeCheck(Sender: TObject);
var
  CurrentInvfields:string;
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;

  if status='Add' then
  begin
    //根据当前货位决定取CurrentInv中的那一个字段
    CurrentInvfields:=getInvfield(AdoQry_tmp,whCode,WhPositionCode,'CurrentInv');
    with AdoQry_Tmp do
    begin
      Close;
      SQL.clear;
      SQL.Add(
         'Select Count(*) as rCount '+
           'From mnItemList '+
           'Where ItemCode='''+TEdit(Sender).Text+''' and '+
              'mono='''+tmp_Mono+''' and '+
              'MoLineno='+tmp_MoLineno);
      Open;
      if fieldbyname('rCount').asinteger>0 then
      begin
        DispInfo('该物料已经存在,不允许增加或修改!',1);
        TWinControl(Sender).SetFocus;
        Abort;
      end
      else
      begin
        AdoQry_Body.First;
        if AdoQry_Body.locate('ItemCode',Extedt_ItemCode.text,[]) then
        begin
            DispInfo('该物料已经存在,不允许增加或修改!',1);
            TWinControl(Sender).SetFocus;
            Abort;
        end
        else
        begin
          //显示计量单位
          Close;
          sql.clear;
          sql.Add('select UomName from Uom,Item where Item.ItemCode='''+Extedt_ItemCode.text+''' and Item.UomCode=Uom.UomCode ');
          open;
          lbl_UomName.Caption:=fieldbyname('UomName').asstring;

          //显示可用库存

          Close;
          sql.clear;
          sql.Add('select '+CurrentInvfields+ ' as onhandInv from CurrentInv where whCode='''+whCode+''' and WhPositionCode='''+WhPositionCode+''' and ItemCode='''+Extedt_ItemCode.text+'''');
          open;
          if not eof then
            lbl_onhandInv.Caption:=fieldbyname('onhandInv').asstring
          else
          lbl_onhandInv.Caption:='0';
          lbl_MoCtrlqty.Caption:='0';
          lbl_MoRealqty.Caption:='0';
        end;
      end;
    end;
  end;
//  DefaultWHCheck(AdoQry_tmp,getCode(whCode),Extedt_ItemCode.text);
  with AdoQry_tmp do
  begin
    Close;
    sql.Text:='select Item.whCode,Warehouse.whName,onlydefaultwh from Item join Warehouse on Item.whCode=Warehouse.whCode where ItemCode='''+Extedt_ItemCode.text+'''';
    open;
    lbl_WhCode.Caption :=fieldbyname('whName').asstring;
    if fieldbyname('onlydefaultwh').asinteger=0 then
       lbl_useOther.Caption :='否';
    if fieldbyname('onlydefaultwh').asinteger=1 then
       lbl_useOther.Caption :='是';
  end;
  if cmbx_WhCode1.Enabled then
    InitCmBx1(cmbx_WhCode1,Extedt_ItemCode.text,'wh');
  if cmbx_WhCode2.Enabled then
    InitCmBx1(cmbx_WhCode2,Extedt_ItemCode.text,'wh');
  if cmbx_WhCode3.Enabled then
    InitCmBx1(cmbx_WhCode3,Extedt_ItemCode.text,'wh');
  if cmbx_WhCode4.Enabled then
    InitCmBx1(cmbx_WhCode4,Extedt_ItemCode.text,'wh');
  if cmbx_WhCode5.Enabled then
    InitCmBx1(cmbx_WhCode5,Extedt_ItemCode.text,'wh');

  selectnext(activecontrol,True,True);
  cmbx_WhCode1.ControlStyle:=[cSclickEvents];
  cmbx_WhCode1.ControlState:=[cSclicked];
  if cmbx_WhCode1.CanFocus then

⌨️ 快捷键说明

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