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

📄 sfc_mnrequestoverplan_b.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
                inttostr(cmbx_WipWaster.Itemindex)+','+
                ''''+Extedt_memo.text+''')');
      AdoQry_tmp.execsql;

    //取单据头InvBillID
    AdoQry_tmp.Close;
    AdoQry_tmp.sql.clear;
    AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
    AdoQry_tmp.open;
    Billid:=AdoQry_tmp.fieldbyname('Billid').asstring;


    with AdoQry_Body do
    begin
      First;
      for M:=0 to recordCount-1 do
      begin
        if (copy(fieldbyname('tmpItemCode').asstring,1,1)<>'+') and
           (copy(fieldbyname('tmpItemCode').asstring,1,1)<>'-') and
          (fieldbyname('moCtrlqty').asstring='') and
          (fieldbyname('moRequestqty').asfloat<>0) then
        begin
         //如果MNItemList不存在的物料,则增加一条物料记录
            AdoQry_tmp.Close;
            AdoQry_tmp.SQL.clear;
            AdoQry_tmp.SQL.text:=
             ' if not exists (select ItemCode from '+
                 'mnItemList where '+
                 ' mono='''+lbl_Mono.Caption+''' and '+
                 ' MoLineno='+lbl_MoLineno.Caption+' and '+
                 ' ite_ItemCode='' '' and '+
                 ' ItemCode='''+fieldbyname('ItemCode').asstring+''') '+
                 ' insert mnItemList '+
                  '  (mono,'+
                  '   MoLineno,'+
                  '   ItemCode,'+
                  '   ite_ItemCode,'+
                  '   moRequestqty) '+
               ' Values('''+lbl_Mono.Caption+''','+
                        lbl_MoLineno.Caption+','+
                        ''''+fieldbyname('ItemCode').asstring+''','+
                        ''''+getCode(lbl_Item.Caption)+''','+
                        '0) ';

          AdoQry_tmp.ExecSQL;
          AdoQry_tmp.Close;
          AdoQry_tmp.sql.clear;
          AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
          AdoQry_tmp.open;
          Billid1:=AdoQry_tmp.fieldbyname('Billid').asstring;
        end;
        //增加表InvOutBillLINE
        if (fieldbyname('moRequestqty').asstring='0') or
           (fieldbyname('moRequestqty').asstring='') then
        begin
        end
        else
        begin
          if (copy(fieldbyname('tmpItemCode').asstring,1,1)<>'+') and
           (copy(fieldbyname('tmpItemCode').asstring,1,1)<>'-') and
          (fieldbyname('moRequestqty').asfloat<>0) then
          begin
            AdoQry_tmp.Close;
            AdoQry_tmp.sql.clear;
            if fieldbyname('ItemListid').asstring<>'' then
            AdoQry_tmp.sql.Add(
              'insert InvOutBillline'+
                       '(InvBillid,'+
                       'InvBilllineno,'+
                       'mono,'+
                       'MoLineno,'+
                       'ItemCode,'+
                       'ite_ItemCode,'+
                       'BilllineremArk,'+
                       'Batchno,'+
                       'InvBillSfcqty,'+
                       'alterNative,'+
                       'ItemListid,'+
                       'Parentid)'+
               'Values('+Billid+','+
                       ''''+inttostr(M+1)+''','+
                       ''''+lbl_Mono.Caption+''','+
                       fieldbyname('MoLineno').asstring+','+
                       ''''+fieldbyname('ItemCode').asstring+''','+
                       ''''+fieldbyname('ite_ItemCode').asstring+''','+
                       ''''+fieldbyname('BilllineremArk').asstring+''','+
                       ''''+fieldbyname('Batchno').asstring+''','+
                       fieldbyname('moRequestqty').asstring+','+
                       fieldbyname('alterNative').asstring+','+
                       fieldbyname('ItemListid').asstring+','+
                       fieldbyname('Parentid').asstring+')')
            else
            AdoQry_tmp.sql.Add(
              'insert InvOutBillline'+
                       '(InvBillid,'+
                       'InvBilllineno,'+
                       'mono,'+
                       'MoLineno,'+
                       'ItemCode,'+
                       'ite_ItemCode,'+
                       'BilllineremArk,'+
                       'Batchno,'+
                       'InvBillSfcqty,'+
                       'alterNative,'+
                       'ItemListid,'+
                       'Parentid)'+
               'Values('+Billid+','+
                       ''''+inttostr(M+1)+''','+
                       ''''+lbl_Mono.Caption+''','+
                       fieldbyname('MoLineno').asstring+','+
                       ''''+fieldbyname('ItemCode').asstring+''','+
                       ''''+fieldbyname('ite_ItemCode').asstring+''','+
                       ''''+fieldbyname('BilllineremArk').asstring+''','+
                       ''''+fieldbyname('Batchno').asstring+''','+
                       fieldbyname('moRequestqty').asstring+','+
                       '0,'+
                       Billid1+','+
                       '0)');
            AdoQry_tmp.ExecSQL;
          end;
        end;
        next;
      end;
    end;
    AdoQry_Body.GotoBookmArk(saveplace);
    AdoQry_Body.freeBookmArk(saveplace);
    AdoQry_Body.EnableControls;
    AdoQry_Body.Connection.CommitTrans;
    Extedt_Billno.text:=Billno;
  except
    begin
      AdoQry_Body.Connection.RollBackTrans;
      AdoQry_Body.EnableControls;
      DispInfo(' 存盘不成功,请稍后再试! ',1);
    end;
  end;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.Act_NewExecute(Sender: TObject);
begin
  Extedt_Billno.text:='';
  IsAfterprint:=False;
  inherited;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.Act_InsertLineExecute(
  Sender: TObject);
begin
  Isinsert:=True;          //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制
  Frm_Entry_Detail.SetFormParam(Lbl_MoNo.Caption,Lbl_MoLineNo.Caption,getCode(cmbbx_WhCode.text),getCode(cmbbx_WhPositionCode.text),medt_Date.text,'');
  inherited;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.Act_ModifyExecute(Sender: TObject);
begin
 if (Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)='+')  then
 begin
   DispInfo('结构虚项不允许修改!',1);
   exit;
 end;

 if  Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)='-' Then
 begin
   DispInfo('替代虚项不允许修改',1);
   exit;
 end;

 Frm_Entry_Detail.SetFormParam(Lbl_MoNo.Caption,Lbl_MoLineNo.Caption,getCode(cmbbx_WhCode.text),getCode(cmbbx_WhPositionCode.text),'','');
 inherited;

end;

procedure TFrm_Sfc_MnRequestOverPlan_B.Act_DeleteLineExecute(
  Sender: TObject);
begin
 if Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)='+' Then
 begin
   DispInfo('结构虚项不允许删除!',1);
   exit;
 end;

 if  Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)='-' Then
 begin
   DispInfo('替代虚项不允许删除!',1);
   exit;
 end;

 if AdoQry_Body.fieldbyname('moCtrlqty').asfloat=0.0 then
    inherited
   else
     DispInfo('领料清单中存在的记录不允许删除!',1);
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.AdoQry_BodyAfterPost(
  DataSet: TDataSet);
begin
  inherited;
 IOType:=AdoQry_Body.fieldbyname('moRequestqty').asfloat;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.DateCheck(Sender: TObject);
begin
  inherited;
    //当前的日期不能超过结帐日期
    if not WHClsPeriodCheck(AdoQry_tmp,getCode(cmbbx_WhCode.text),copy(medt_Date.text,1,7)) then
    begin
      twincontrol(sender).setfocus;
      abort;
    end;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.cmbbx_WhPositionCodeExit(
  Sender: TObject);
begin
  inherited;

  if Isinsert then exit;       //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制

  if (cmbbx_WhPositionCode.text<>'') and (cmbbx_WhPositionCode.text<>oldWhPosition) then
  begin
    showdbgrid;
  end ;
  oldWhPosition:=cmbbx_WhPositionCode.text;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.CheckBox2Click(Sender: TObject);
begin
  inherited;
  showdbgrid;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.CheckBox1Click(Sender: TObject);
begin
  inherited;
  showdbgrid;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.DBGridEhGetCellParams(
  Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  inherited;
  if (gdSelected in State)or(gdFocused in State) then
  begin
    Background:=clNavy;
    AFont.Color:=clWindow;
  end
  else
  begin
    if Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)='+' Then
      AFont.Color:=ClRed;
    if Copy(AdoQry_Body.fieldbyname('TmpItemCode').AsString,1,1)='-' Then
      AFont.Color:=Clblue;
  end;

end;

procedure TFrm_Sfc_MnRequestOverPlan_B.cmbbx_WhEmployeeExit(
  Sender: TObject);
begin
  inherited;
  if Isinsert then exit;     //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制
  showdbgrid;
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.initprint;
begin
  //初始化未保存前打印
   Frm_Sfc_MnOut_NotSave_P.QLWHCode.Caption:=cmbbx_WhCode.text;
   Frm_Sfc_MnOut_NotSave_P.QLWhPositionCode.Caption:=cmbbx_WhPositionCode.text;
   Frm_Sfc_MnOut_NotSave_P.qlWhEmployee.Caption:=cmbbx_WhEmployee.text;
   Frm_Sfc_MnOut_NotSave_P.QLInvBillNo.Caption:=Extedt_Billno.text;
   Frm_Sfc_MnOut_NotSave_P.QLDeptCode.Caption:=lbl_Dept.Caption;
   Frm_Sfc_MnOut_NotSave_P.QLshifttime.Caption:=cmbbx_Shift.text;
   Frm_Sfc_MnOut_NotSave_P.QLInvBillDate.Caption:=medt_Date.text;
   Frm_Sfc_MnOut_NotSave_P.QLMONo.Caption:=lbl_Mono.Caption;
   Frm_Sfc_MnOut_NotSave_P.QLMoLineNo.Caption:=lbl_MoLineno.Caption;
   Frm_Sfc_MnOut_NotSave_P.qlItemCodeName.Caption:=lbl_Item.Caption;
   Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCodea.Caption:='';
   Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCode.Caption:='';
   Frm_Sfc_MnOut_NotSave_P.qlmemo.Caption:='超订单 '+Extedt_memo.text;
   with AdoQry_tmp do
   begin
     Close;
     sql.clear;
     sql.Add('select EmployeeCode,EmployeeName from Employee where EmployeeCode='''+userCode+'''');
     open;
   end;
   Frm_Sfc_MnOut_NotSave_P.QLEmployeeCodeA.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
   Frm_Sfc_MnOut_NotSave_P.QLEmployeeCode.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
   with AdoQry_tmp do
   begin
     Close;
     sql.clear;
     sql.Add('select moqty from MoLine where mono='''+lbl_Mono.Caption+''' and MoLineno='+lbl_MoLineno.Caption);
     open;
   end;
   Frm_Sfc_MnOut_NotSave_P.qlmoqty.Caption:=AdoQry_tmp.fieldbyname('moqty').asstring;

   Frm_Sfc_MnOut_NotSave_P.QuickRep1.DataSet:=AdoQry_Body;
   Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataSet :=AdoQry_Body;
   Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataField :='ItemCode';
   Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataSet := AdoQry_Body;
   Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataField :='ItemCode2';
   Frm_Sfc_MnOut_NotSave_P.QRExpr2.Expression:='COPY(AdoQry_Body.ItemName,1,44)';
   Frm_Sfc_MnOut_NotSave_P.QRExpr3.Expression :='COPY(AdoQry_Body.ItemName,45,16)';
   Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataSet :=AdoQry_Body;
   Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataField :='UomName';
   Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataSet :=AdoQry_Body;
   Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataField :='moRequestqty';
   Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataSet :=AdoQry_Body;
   Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataField:='MoRealqty';
//   Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataSet :=AdoQry_Body;
 //  Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataField:='BilllineremArk';
end;

procedure TFrm_Sfc_MnRequestOverPlan_B.cmbx_WipWasterChange(
  Sender: TObject);
begin
  inherited;
  WipWaster:=cmbx_WipWaster.ItemIndex ;
end;

end.

⌨️ 快捷键说明

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