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

📄 inv_enter_mounitmnrequestauditing1.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    dbgrideh.Columns[8].ReadOnly:=False;
       dbgrideh.Columns[9].ReadOnly:=False;
    //dbgrideh.Columns[10].ReadOnly:=False;
  end;}
  //  initUsablewhcmbx(AdoQry_tmp,userCode,cmbbx_WhCode,True);
  {SQl.Text := ' select WhAccessCtrl.WHCode,WHName   '
             +'    from WHAccessCtrl   '
             +'   join Warehouse on WhAccessCtrl.WhCode=Warehouse.WhCode '
             +'   where WhAccessCtrl.EmployeeCode='+QuotedSTr(userCode)
             +'     and ( WhAccessCtrl.WhCode In (select WhCode  from CurrentInv      '
             +'                     where ItemCode in(select distinct ItemCode from opItemList '
             +'                                        where  poNo ='''+AdoQry_Head.fieldbyname('Pono').asstring+ ''''
             +'                                        and Polineno='+AdoQry_Head.fieldbyname('Polineno').asstring+'   ) )     '
             +'          or WhAccessCtrl.WhCode in (select WhCode from Item where ItemCode in( select distinct ItemCode from opItemList '
             +'                                        where  poNo ='''+AdoQry_Head.fieldbyname('Pono').asstring+ ''''
             +'                                        and Polineno='+AdoQry_Head.fieldbyname('Polineno').asstring+'   ) ) )    '
             + '   Order by WhAccessCtrl.WHCode   ';}

  SQlText := ' select WhAccessCtrl.WHCode,WHName   '
             +'    from WHAccessCtrl   '
             +'   join Warehouse on WhAccessCtrl.WhCode=Warehouse.WhCode '
             +'   where WhAccessCtrl.EmployeeCode='+QuotedSTr(userCode)
             +'     and (WhAccessCtrl.WhCode In (select WhCode  from CurrentInv      '
             +'                     where ItemCode in(select distinct ItemCode from MnItemList '
             +'                                        where  MoNo+Convert(varchAr(20),MoLineNo) In ( Select distinct  MoNo+Convert(varchAr(20),MoLineNo) '
                                                            +' from #TmPMoLine1 Where InvBillid='+InvBillid+') ) ) '
             +'          or WhAccessCtrl.WhCode in (select WhCode from Item where ItemCode in( select distinct ItemCode' +' from #TmPMoLine1 Where InvBillid='+InvBillid+'   ) ) )    '

            + '   Order by WhAccessCtrl.WHCode   ';
  ExecuteSql(AdoQry_Tmp,SQlText,0);
 { cmbbx_WhCode.Items.clear;
  Cmbbx_WhCode.Items.Add('');
  While Not AdoQry_Tmp.Eof do
  begin
    Cmbbx_WhCode.Items.Add(AdoQry_Tmp.fieldbyname('WhCode').AsString+' '+AdoQry_Tmp.fieldbyname('WhName').AsString);
    AdoQry_Tmp.Next;
  end;
  Cmbbx_WhCode.ItemIndex := 0; }
  cmbbx_WhCodeexit(cmbbx_WhCode);
  //InitShiftCmBx(AdoQry_tmp,cmbbx_Shift,True);
  //Cmbbx_Shift.ItemIndex := 0;
  Act_CancelCheck.Enabled :=False;
  Act_CancelCheck.Visible :=False;
  tlbtn_Cancelcheck.action:=act_auto;
  //IOType:=0;
  //设置各种状态
  //setstrol;

  //选出替代件的限额数量 ,用于检验    //
  {AdoQuery1.Connection :=AdoQry_Body.Connection ;
  AdoQuery1.EnableBCD :=False;
  AdoQuery1.LockType :=ltBatchOptimistic;
  with AdoQuery1 do
  begin
    Close;
    sql.clear;
    sql.Add('select ItemListid,Parentid,moCtrlqty,MoRealqty '+
            '  from mnItemList '+
            //' where mono='''+AdoQry_Head.fieldbyname('mono').asstring+''''+
            //'   and MoLineno='+AdoQry_Head.fieldbyname('MoLineno').asstring+
            '   where MoNo+Convert(varchAr(20),MoLineNo) In ( Select MoNo+Convert(varchAr(20),MoLineNo) '+
                                                             //+' from #TmPMoLine1 Where InvBilltmpflag=1)   ' ;
                                                            ' from #TmPMoLine1 Where InvBillid='+AdoQry_Head.fieldbyname('InvBillid').asstring+')'+

            '   and alterNative=1 '+
            '   and moCtrlqty>0 ');
    open;
  end;}
  //如果出现冲销的情况,即请领量为负数,就不进行自动获取功能。
  with AdoQry_Body do
  begin
    First;
    for I:=0 to recordCount-1 do
    begin
      if fieldbyname('MoRequestQty').asfloat<0 then
      begin
        act_auto.Enabled :=False;
        break;
      end;
      next;
    end;
  end;
  // InitCmBxText(cmbbx_Shift,Frm_Sfc_Enter_MoUnitMnRequestH.tmp_MoRequestshift);
  cmbbx_WhCode.Enabled :=False;
  cmbbx_WhPositionCode.Enabled :=False;
  cmbbx_WhEmployee.Enabled :=False;
  Extedt_Billno.Enabled :=False;
  cmbbx_Shift.Enabled :=False;
  Edt_Dept.Enabled :=False;
  Edt_WhEmployeeCode.Enabled :=False;
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.initprint;
begin
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select SysParamValueC'+
                       ' From SysParam'+
                       ' Where SysParamCode=''Name0''';
  AdoQry_Tmp.Open;
  ExtPrintReport.Title1:=AdoQry_Tmp.fieldbyname('SysParamValueC').AsString;

  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select ReportName1,ISOCode1'+
                       ' From ReportCtrl'+
                       ' Where SysMenuId='+MenuId;
  AdoQry_Tmp.Open;
  ExtPrintReport.Title2:=AdoQry_Tmp.fieldbyname('ReportName1').AsString;
  ExtPrintReport.SubTitle1:=AdoQry_Tmp.fieldbyname('ISOCode1').AsString;
  ExtPrintReport.SubTitle2:='    仓库:'+cmbbx_WhCode.text+repstr(' ',20-Length(cmbbx_WhCode.text))+'    '
                                     +'货位:'+cmbbx_WhPositionCode.text+repstr(' ',20-Length(cmbbx_WhPositionCode.text))+'    '
                                     +'仓管员:'+cmbbx_WhEmployee.text+repstr(' ',16-Length(cmbbx_WhEmployee.text))+'    '
                                     +'  单据号:'+Extedt_Billno.text ;
  ExtPrintReport.SubTitle3:='领料部门:'+Edt_Dept.text+repstr(' ',20-Length(Edt_Dept.text))+'    '
                                     +'班别:'+cmbbx_Shift.text+repstr(' ',20-Length(cmbbx_Shift.text))+'    '
                                     +'审核人:'+Edt_WhEmployeeCode.text+repstr(' ',16-Length(Edt_WhEmployeeCode.text))+'    '
                                     +'单据日期:'+medt_Date.text;
  ExtPrintReport.SubTitle4:='    备注:'+Extedt_memo.text;
end;



procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.Showdbgrid;
var
  sqltext,tmp_WhEmployee,tmp_DeptCode,tmpfields,oncheckpositionCode:string;
begin
   //取待检货位的代码
   with AdoQry_tmp do
   begin
     Close;
     sql.text:='select WhPositionCode from WhPosition where WhPositionType=1 '+
               'and whCode='+QuotedStr(getCode(cmbbx_WhCode.text));
     open;
     oncheckpositionCode:=fieldbyname('WhPositionCode').asstring;
   end;
  //取数据显示于DBGRID

  //根据仓库代码,货位代码决定选出数据表中的英文字段名,用于下面的SQL语名组合
  tmpfields:=getInvfield(AdoQry_tmp,getCode(cmbbx_WhCode.text),getCode(cmbbx_WhPositionCode.text),'CurrentInv');
  //如果仓库管理员为空或不为空情况下的SQL语名中仓管员条件组合
  if cmbbx_WhEmployee.text<>'' then
    tmp_WhEmployee:='   and i.wh_EmployeeCode='''+getCode(cmbbx_WhEmployee.text)+''''
  else
  tmp_WhEmployee:='';
  tmpTable:='#'+RandomString;
  Try
    ExecuteSql(AdoQry_Tmp,'Drop Table  '+tmpTable,1);
  except
  end;

  SqlText :='Create table '+tmpTable
            +'( IsTotal Int null, '
            +'  ItemListId Int Null, '
            +'  MoNo    varchAr(20) null, '
            +'  MoLineNo  Int Null, '
            +'  ItemCode  varchAr(16) NUll, '
            +'  Ite_ItemCode varchAr(16) null, '
            +'  ItemName   varchAr(200) Null, '
            +'  UomName    varchAr(10) null, '
            +'  OnHandInv  decimal(20,8) null, '
            +'  MoCtrlQty  decimal(20,8) null, '
            +'  MoRealQty  decimal(20,8) null, '
            +'  MoRequestQty decimal(20,8) null, '
            +'  ThisRequestQty decimal(20,8) null, '
            +'  BatchNo     varchAr(30)  null, '
            //+'  RemArk      varchAr(200) null ) '
            +'  BomRemArk      varchAr(200) null , '
            +'  BillLineRemArk      varchAr(200) null ) '

            +'  Insert Into '+tmpTable+'  select  0 as IsTotal,MnItemList.ItemListId,InvOutBillline.MoNo,  '
            +'         InvOutBillline.MoLineNo, '
            +'         InvOutBillline.ItemCode, '
            +'         InvOutBillline.Ite_ItemCode, '
            +'         Item.ItemName,       '
            +'         Uom.UomName,         '
            +'         IsNull(CurrentInv.'+TmpFields+',0.0) as OnHandInv,'
            +'         MnItemList.MoCtrlQty, '
            +'         MnItemList.MoRealQty,   '
            +'        InvOutBillline.InvBillSfcqty,   '
            +'         0.0 as ThisRequestQty,         '
            +'         ''                           ''  as BatchNo,  '
            +'         '''' as BomRemArk, '
            //+'         convert(varchAr(1000),'''') as RemArk    '
            +'         InvOutBillline.BillLineRemArk as RemArk '
            +' from InvOutBillline  '
            +' Left Join MnItemList on InvOutBillline.ItemListid =MnItemList.ItemListid and MnItemList.AlterNative=0 '
            +' Join Item on InvOutBillline.ItemCode=Item.ItemCode '
            //+iifString(Cmbbx_WhEmployee.Text='' ,'','and Item.Wh_EmployeeCode='+QuotedStr(GetCode(Cmbbx_WhEmployee.Text)))
            +'   left Join CurrentInv on Item.ItemCode=CurrentInv.ItemCode '
            +'                       and  CurrentInv.WhCode='+QuotedStr(GetCode(Cmbbx_WhCode.Text))
            +'                       and  CurrentInv.WhPositionCode='+QuotedStr(GetCode(Cmbbx_WhPositionCode.Text))
            +'   left Join Uom On Item.UomCode=Uom.UomCode   '
            //+'  where AlterNative=0  '
            +' where InvOutBillline.InvBillid='+AdoQry_Head.fieldbyname('InvBillid').asstring;
            //+' and MoRequestQty<>0 '
            //+'    and MoNo+Convert(varchAr(20),MoLineNo) In ( Select MoNo+Convert(varchAr(20),MoLineNo) '
            //                                                 //+' from #TmPMoLine1 Where InvBilltmpflag=1)   ' ;
            //                                                +' from #TmPMoLine1 Where InvBillid='+AdoQry_Head.fieldbyname('InvBillid').asstring+')';
  ExecuteSql(AdoQry_tmp,SqlText,1);
  SqlText := ' Insert '+tmpTable
            +' select  1 as IsTotal,0 as ItemListId,'''' as MoNo,'
                    +' 0 as MoLineNo, '
                    +' ItemCode, '
                    +' '' '' as Ite_ItemCode, '
                    +' ItemName, '
                    +' UomName , '
                    +' OnHandInv, '
                    +' Sum(MoCtrlQty) as MoCtrlQty, '
                    +' sum(MoRealQty) as MoRealQty, '
                    +' Sum(MoRequestQty) as MoRequestQty,'
                    +' Sum(ThisRequestQty) as ThisRequestQty, '
                    +'         ''''  as BatchNo,  '
                    +' '''' as BomRemArk, '
                    +'         convert(varchAr(1000),'''') as RemArk    '

            +' From '+tmpTable
            +' Group By ItemCode,ItemName,UomName ,OnHandInv';
  ExecuteSql(AdoQry_Tmp,SqlText,1);
  Executesql(AdoQry_Body,'select * from '+tmpTable+' where IsTotal=1',0);
end;


procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.FormActivate(
  Sender: TObject);
begin
  inherited;
   if AdoQry_Head.fieldbyname('InvBillWhchck').asinteger=1 then
      dbgrideh.SetFocus
   else
      medt_Date.setfocus;
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if act_Check.Enabled =True then
  begin
    if DispInfo('数据发生改变,是否要审核?',2)='y' then
      act_Check.Execute
    else
      inherited;
  end
  else
    inherited;

end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.DateCheck(
  Sender: TObject);
begin
  inherited;
  if not   medt_Date.enabled then
    medt_Date.enabled:=True;
  if not WHClsPeriodCheck(AdoQry_tmp,getCode(cmbbx_WhCode.text),copy(medt_Date.text,1,7)) then
  begin
    medt_Date.setfocus;
    abort;
  end;
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.DBGridEhKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  if (AdoQry_Body.State in [dsedit]) and
     (dbgrideh.SelectedField.fieldName='Batchno') and
      (key=VK_F9) then
    AdoQry_Body.fieldbyname('Batchno').asstring:=
      BatchHint(AdoQry_tmp.Connection,AdoQry_Body.fieldbyname('ItemCode').asstring,'',getCode(cmbbx_WhCode.text),getCode(cmbbx_WhPositionCode.text));
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing1.DBGridEhColExit(
  Sender: TObject);
var
  tmp_WhCode,tmp_WhPositionCode:string;
begin
  inherited;
  if (AdoQry_Body.State in [dsEdit, dsInsert])
  and (lowercase(dbgrideh.SelectedField.fieldName)='thisRequestqty')
  then
  begin
//    checkbodyIOType;
    checkcoCurrentqty;
  end;

  if (AdoQry_Body.State in [dsEdit, dsInsert])
    and (dbgrideh.SelectedField.fieldName='Batchno') then
  begin

    if (not BatchCtrl(AdoQry_tmp,AdoQry_Body.fieldbyname('ItemCode').asstring)) then
    if  (Trim(dbgrideh.SelectedField.Value)<>'') then
    begin
      DispInfo('该物料不受批次控制,不能录入批次号',1);
      dbgrideh.setfocus;
      abort;
    end;

    if (BatchCtrl(AdoQry_tmp,AdoQry_Body.fieldbyname('ItemCode').asstring)) and
       ((AdoQry_Body.fieldbyname('ThisRequestqty').asstring<>'0') and
        (AdoQry_Body.fieldbyname('ThisRequestqty').asstring<>''))  then
    begin
      if  (Trim(dbgrideh.SelectedField.Value)='') or
          (dbgrideh.SelectedField.Value=Null) then
      begin
        DispInfo('请录入批次号',1);
        dbgrideh.setfocus;
        abort;
      end
      else
      begin
        if not BatchNoCheck(AdoQry_tmp,dbgrideh.SelectedField.Value,AdoQry_Body.fieldbyname('ItemCode').asstring,'',medt_Date.text) then
        begin
          dbgrideh.setfocus;
          abort
        end
        else
        begin
          tmp_WhCode:=getCode(cmbbx_WhCode.text);
          tmp_WhPositionCode:=getCode(cmbbx_WhPositionCode.text);
          if  not BatchInvCheck(AdoQry_tmp,dbgrideh.SelectedField.Value,'C',tmp_WhCode,tmp_WhPositionCode,AdoQry_Body.fieldbyname('moRequestqty').asfloat) then
          begin
            dbgrideh.setfocus;
            abort;
          end;
        end;
      end;
    end
  end;
end;

⌨️ 快捷键说明

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