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

📄 inv_enter_mounitmnrequestauditing.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 5 页
字号:
              ' where ItemListid='+TmpAdoQry.fieldbyname('ItemListid').asstring
            else
              AdoQry_tmp.sql.text:=
              'update mnItemList set '+
              '  MoRealqty=MoRealqty+'+floattostr(ThisRequestQty)+
              ' where ItemListid='+TmpAdoQry.fieldbyname('ItemListid').asstring;
            AdoQry_tmp.execsql;
            ScLL(AdoQry_tmp,
                 AdoQry_Body.fieldbyname('ItemCode').asstring,
                 'MOScLL',
                 TmpAdoQry.fieldbyname('mono').asstring,
                 strtoint(TmpAdoQry.fieldbyname('MoLineno').asstring));
          TmpAdoQry.Next;
        end;
      end;
      next;
      end;
    end;
    // 更新 MnItemList.MORequestQty 已制单量 (021114 by zks)
    with AdoQry_Body do
    begin
      AdoQry_Body.First;
      while not  AdoQry_Body.eof do
      begin
        ExecuteSQl(TmpAdoQry,'select * from #MnItemList1 '
                      +' where ItemCode='+QuotedStr(AdoQry_Body.fieldbyname('ItemCode').AsString)
                      +'   and IsTotal=0 ',0);
        TmpAdoQry.First;
        While Not TmpAdoQry.Eof do
        begin
          AdoQry_tmp.Close;
          AdoQry_tmp.sql.clear;
          AdoQry_tmp.sql.text:=
            'update mnItemList set '+
            //'  MORequestQty=MORequestQty-('+floattostr(ThisRequestQty)+')'+
            '  MORequestQty=MORequestQty-('+TmpAdoQry.fieldbyname('MoRequestQty').asstring+')'+
            ' where ItemListid='+TmpAdoQry.fieldbyname('ItemListid').asstring+
            ' and MORequestQty<>0  ';
          AdoQry_tmp.execsql;
          TmpAdoQry.next;
        end;
        AdoQry_Body.next;
      end;
    end;
    //  更新 #TmPMoLine1  ;
    AdoQry_tmp.Close;
    AdoQry_tmp.sql.clear;
    AdoQry_tmp.sql.text:=
      ' update  #TmPMoLine1  '+
      ' set InvBillWhchck=1 '+
      ' where InvBillid='+AdoQry_Head.fieldbyname('InvBillid').asstring;
       //'   and InvBillqty=0 ';
    AdoQry_tmp.execsql;
    {with AdoQuery1 do
    begin
      First;
      while not eof do
      begin
        AdoQry_tmp.Close;
        AdoQry_tmp.sql.clear;
        if tmp_Backflush=1 then
          AdoQry_tmp.sql.text:=
             ' update mnItemList set '+
             '   BFrealqty='+fieldbyname('MoRealqty').asstring+
              '  where ItemListid='+fieldbyname('ItemListid').asstring
        else
          AdoQry_tmp.sql.text:=
             ' update mnItemList set '+
             '   MoRealqty='+fieldbyname('MoRealqty').asstring+
              '  where ItemListid='+fieldbyname('ItemListid').asstring;
        AdoQry_tmp.execsql;
        next;
      end;
    end;}
    AdoQry_Head.Connection.CommitTrans;
    DBGridEh.Enabled :=True;
    AdoQry_Body.EnableControls ;
    //保存后设置各控键状态
    dbgrideh.SetFocus;
    dbgrideh.Columns[7].ReadOnly:=True;
    AdoQry_Head.Edit ;
    AdoQry_Head.fieldbyname('WhEmployeeCode').asstring:=Edt_WhEmployeeCode.text;
    AdoQry_Head.fieldbyname('InvBillWhchck').asstring:='1';
    AdoQry_Head.Post ;
    act_Check.Enabled:=False;
    act_auto.Enabled :=False;
    medt_Date.enabled:=False;
    Extedt_memo.enabled:=False;
  except
    begin     
      AdoQry_Head.Connection.RollBackTrans;
      DBGridEh.Enabled :=True;
      AdoQry_Body.EnableControls ;
      //if not BeforeSaveError then
        DispInfo(' 存盘不成功,请稍后再试! ',1);
    end;
  end;
end;


procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.Act_QuitExecute(
  Sender: TObject);
begin
  Close;
end;

function TFrm_Inv_Enter_MoUnitMnRequestAuditing.GetUserName(
  userCode: string): string;
begin
  Executesql(AdoQry_tmp,'select EmployeeName from Employee '+
                               ' where EmployeeCode='''+userCode+'''',0);
  Result:=AdoQry_tmp.fieldbyname('EmployeeName').asstring;
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.InitForm(
  AdOConnection: TAdOConnection; FormStatus: String; AdoQuery: TAdoQuery);
begin
  inherited;
  if FormStatus='Query' then
  begin
    medt_Date.enabled:=False;
    Extedt_memo.enabled:=False;
    act_Check.Enabled :=False;
    act_auto.Enabled :=False;
    dbgrideh.columns[7].ReadOnly:=True;
    if AdoQry_Head.fieldbyname('InvBillWhchck').asinteger=1 then
    Edt_WhEmployeeCode.text:=AdoQry_Head.fieldbyname('WhEmployeeCode').asstring
                            +' '+GetUserName(AdoQry_Head.fieldbyname('WhEmployeeCode').asstring);
  end
  else
  begin
    Edt_WhEmployeeCode.text:=userCode+' '+GetUserName(userCode);
    medt_Date.enabled:=True;
    Extedt_memo.enabled:=True;
    act_Check.Enabled :=True;
    act_auto.Enabled :=True;
   // act_Check.Enabled :=False;
    dbgrideh.columns[7].ReadOnly:=False;
  end;

end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.Act_PreviewExecute(
  Sender: TObject);
begin
  inherited;
  SetReport;
  ExtPrintReport.preview;

  //BillPrint(AdoQry_Tmp.Connection,GetCode(cmbbx_WhCode.text),Extedt_Billno.Text,Param1,ModuleCode,True,False,True,'all');
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.Act_PrintExecute(
  Sender: TObject);
begin
  inherited;
 // BillPrint(AdoQry_Tmp.Connection,GetCode(cmbbx_WhCode.text),Extedt_Billno.Text,Param1,ModuleCode,False,False,True,'all');
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.SetReport;
var
  i,j:integer;
begin
  if DBGridEh.DataSource.DataSet.Active=False then
    Abort;
  ExtPrintReport.DataSet :=nil;
  ExtPrintReport.Headers.clear;
  i:=0;
  with ExtPrintReport do
  begin
    for j:=0 to DBGridEH.Columns.Count-1 do
      if DBGridEH.Columns[j].Visible then
      begin
        Headers.Add;
        Headers.Items[i].Caption :=DBGridEH.Columns[j].Title.Caption;
        Headers.Items[i].FieldName :=DBGridEH.Columns[j].FieldName;
        Headers.Items[i].DisplayWidth:=(DBGridEH.Columns[j].Width div (DBGridEH.Canvas.TextWidth(' ')));
        Headers.Items[i].Alignment :=DBGridEH.Columns[j].Alignment;
        if((DBGridEh.Columns[j].PickList.Count>0)and
          (DBGridEh.Columns[j].KeyList.Count>0))
          or(DBGridEh.Columns[j].Field.DataType in [ftFloat])then
        begin
          Headers.Items[i].style:=dstransform;
          Headers.Items[i].TransformFunction:=GetTransValue;
        end
        else
          SetColumnsStyle(i,DBGridEH.Columns[j].FieldName);
        inc(i);
      end;
    DataSet:=DBGridEh.DataSource.DataSet;
    initprint;
  end;
end;


procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.GetTransValue(FieldName,
  OldValue: String; var NewValue: String);
var
  i:integer;
begin
  NewValue:=OldValue;
  if DBGridEh<>nil then
    for i:=0 to DBGridEh.Columns.Count-1 do
      if(DBGridEh.Columns[i].FieldName=FieldName)then
      begin
        if(DBGridEh.Columns[i].Field.DataType in [ftFloat])
          and(TFloatField(DBGridEh.Columns[i].Field).DisplayFormat<>'')
          and(OldValue<>'')then
        begin//转换定义了格式显示的数据
          NewValue:=FormatFloat(TFloatField(DBGridEh.Columns[i].Field).DisplayFormat,StrToFloat(OldValue));
        end
        else if DBGridEh.Columns[i].KeyList.IndexOf(OldValue)<>-1 then
        begin//转换有pickList,keyList对应关系的数据
          NewValue:=DBGridEh.Columns[i].PickList.Strings[DBGridEh.Columns[i].
            KeyList.IndexOf(OldValue)];
        end;
        break;
      end;
end;


procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.SetColumnsStyle(
  ItemIndex: Integer; FieldName: String);
begin

end;

function TFrm_Inv_Enter_MoUnitMnRequestAuditing.repstr(str: string;
  times: integer): string;
var
  i:integer;
begin
  for i:=0 to times-1  do
  Result:=Result+str;
end;

procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.Button2Click(
  Sender: TObject);
begin
  OutputMOList(0); 
end;


procedure TFrm_Inv_Enter_MoUnitMnRequestAuditing.OutputMOList(I: integer);  //0:preview;1:Print;
var SqlText : String;
    TmpAdoQry : TAdoQuery;
    TmpAdoQry1 : TAdoQuery;
begin
  inherited;
  {If Act_Save.Enabled then
  begin
    DispInfo('请先保存数据!',3);
    abort;
  end;}
  TmpAdoQry := TAdoQuery.Create(self);
  TmpAdoQry.Connection := Dbconnect;
  TmpAdoQry.EnableBCD := False;
  TmpAdoQry1 := TAdoQuery.Create(self);
  TmpAdoQry1.Connection := Dbconnect;
  TmpAdoQry1.EnableBCD := False;
  Try
    SqlText := 'select Distinct #MnItemList1.MoNo,#MnItemList1.MoLineNo,MoLine.ItemCode,Item.ItemName from #MnItemList1 '
              +' join MoLine on (#MnItemList1.MoNo=MoLine.MoNo and #MnItemList1.MoLineNo=MoLine.MoLineNo) '
              +' left join Item on MoLine.ItemCode=Item.ItemCode '
              +' where IsTotal=0 ';
              //+'   and ThisRequestQty>0 ';
    ExecuteSql(TmpAdoQry1,SqlText,0);

    while Not TmpAdoQry1.Eof do
    begin
      SqlText := 'select #MnItemList1.*,Item.ItemName from  #MnItemList1 '
                +' left join Item on #MnItemList1.ItemCode=Item.ItemCode '
                +' where IsTotal=0 '
               // +'   and ThisRequestQty>0 '
                +'   and MoNo='+QuotedStr(TmpAdoQry1.fieldbyname('MoNo').AsString)
                +'   and MoLineNO='+TmpAdoQry1.fieldbyname('MoLineNO').AsString;
      ExecuteSql(TmpAdoQry,SqlText,0);
      Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P,Frm_Sfc_MnOut_NotSave_P);
      if i=0 then
        Frm_Sfc_MnOut_NotSave_P.SetFormParam('',getCode(cmbbx_WhCode.text),'0201','Preview',ModuleCode,'');
      if i=1 then
        Frm_Sfc_MnOut_NotSave_P.SetFormParam('',getCode(cmbbx_WhCode.text),'0201','print',ModuleCode,'');
      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:=Edt_Dept.Text;
      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:=TmpAdoQry1.fieldbyname('MoNo').AsString;
      Frm_Sfc_MnOut_NotSave_P.QLMoLineNo.Caption:=TmpAdoQry1.fieldbyname('MoLineNo').AsString;
      Frm_Sfc_MnOut_NotSave_P.qlItemCodeName.Caption:=TmpAdoQry1.fieldbyname('ItemCode').AsString+' '+TmpAdoQry1.fieldbyname('ItemName').AsString;
      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='''+TmpAdoQry1.fieldbyname('MoNo').AsString+''' and MoLineno='+TmpAdoQry1.fieldbyname('MoLineNo').AsString);
        open;
      end;
      Frm_Sfc_MnOut_NotSave_P.qlmoqty.Caption:=AdoQry_tmp.fieldbyname('moqty').asstring;
      Frm_Sfc_MnOut_NotSave_P.QuickRep1.DataSet:=TmpAdoQry;
      Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataSet :=TmpAdoQry;
      Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataField :='ItemCode';
      Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataSet := TmpAdoQry;
      Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataField :='moCtrlqty';
//       Frm_Sfc_MnOut_NotSave_P.QRExpr2.Expression:='COPY(TmpAdoQry.ItemName,1,44)';
//       Frm_Sfc_MnOut_NotSave_P.QRExpr3.Expression :='COPY(TmpAdoQry.ItemName,45,16)';
      Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataSet := TmpAdoQry;
      Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataField :='UomName';
      Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataSet := TmpAdoQry;
      Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataField :='MoRequestQty';//'ThisRequestqty';
      Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataSet := TmpAdoQry;
      Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataField:='ThisRequestQty';//'MoRealqty';
//       Frm_Sf

⌨️ 快捷键说明

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