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

📄 inv_opout_b.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  {  if not postflag then
  begin
    if checkrepeat then
    begin
      DispInfo('在同一张单据中不能出现相同物料!',1);
      AdoQry_Body.Cancel;
      abort;
    end;
  end;}
  act_Save.Enabled :=True;
end;

procedure TFrm_Inv_OpOut_B.Act_PreviewExecute(Sender: TObject);
begin
 //inherited;
  BillPrint(AdoQry_Tmp.Connection,GetCode(Cmbx_WhCodeName.text),Edt_BillNo.text,'0202'{RecTypeCode},ModuleCode,True,False,True,'');
end;

procedure TFrm_Inv_OpOut_B.Act_PrintExecute(Sender: TObject);
begin
  //inherited;
  BillPrint(AdoQry_Tmp.Connection,GetCode(Cmbx_WhCodeName.text),Edt_BillNo.text,'0202'{RecTypeCode},ModuleCode,False,False,True,'');
end;


function TFrm_Inv_OpOut_B.CheckAllSame: boolean;
{var
  I:integer;
  Temp,Temp1:real;
begin
  AdoQry_Body.First;
  for i:=0 to AdoQry_Body.RecordCount-1 do
  begin
    if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
    Temp1:=AdoQry_Body.fieldbyname('POOutQty').asfloat;
    break;
  end;
  AdoQry_Body.First;
  for i:=0 to AdoQry_Body.RecordCount-1 do
  with AdoQry_Body do
  begin
    Temp:=Temp1*fieldbyname('POOutQty').asfloat;
    if Temp<0 then
    begin
      Result:=False;
      exit;
    end;
//    Temp:=Temp1;
    next;
  end;
  Result:=True;
end;}
var
  i:integer;
  flag:boolean;
begin
  AdoQry_Body.First;
  for i:=0 to AdoQry_Body.RecordCount-1 do
  begin
    if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
    begin
      if AdoQry_Body.fieldbyname('POOutQty').asfloat>0 then
      flag:=True
      else flag:=False;
      break;
    end;
    AdoQry_Body.next;
  end;
  AdoQry_Body.First;
  for i:=0 to AdoQry_Body.RecordCount-1 do
  begin
    if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
    begin
      if ((flag) and (AdoQry_Body.fieldbyname('POOutQty').asfloat<0)) or
      ((not flag) and (AdoQry_Body.fieldbyname('POOutQty').asfloat>0)) then
      begin
        Result:=False;
        exit;
      end;
    end;
    AdoQry_Body.next;
  end;
  Result:=True;
end;

function TFrm_Inv_OpOut_B.CheckNotZero: boolean;
var
  I:integer;
begin
  AdoQry_Body.First;
  for i:=0 to AdoQry_Body.RecordCount-1 do
  begin
    if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
    begin
      Result:=True;
      exit;
    end;
    AdoQry_Body.next;
  end;
  Result:=False;
end;

procedure TFrm_Inv_OpOut_B.DisableAll(flag: boolean);
begin
  Cmbx_WhCodeName.Enabled:=flag;
  Cmbx_Position.Enabled:=flag;
  //Edt_BillNo.Enabled:=flag;
  //act_Save.Enabled:=flag;
  Act_Modify.Enabled:=flag;
  Medt_Date.Enabled:=flag;
  Edt_Memo.Enabled:=flag;
  DBGridEh.ReadOnly:=not flag;
end;

procedure TFrm_Inv_OpOut_B.refreshall;
var
  tmpfields,isshowall:string;
  i:integer;
  IsHave:boolean;
  mypost:TDataSetNotifyEvent;
begin
  ishave:=False;
  mypost:=AdoQry_Body.BeforePost;
  AdoQry_Body.BeforePost:=nil;
  //刷新Query 及其它相关控件
  With AdoQry_Body do
  begin
    tmpfields:=getInvfield(AdoQry_tmp,getCode(Cmbx_WhCodeName.text),getCode(Cmbx_Position.text),'CurrentInv');
    if CheckBox1.Checked then isshowall:='' else
    isshowall:=' and (Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' or '+
               ' c.'+tmpFields+'>0)';
    Close;
    Sql.clear;
    If IsOverPlan then
    begin
      Sql.Add('select '+
              '  op.pono,Op.PoLIneNo,Op.ItemCode, '+
              '  Item.ItemName,Uom.UomName, '+
              '  op.BilllineremArk BatchNo, '+
              '  Op.PoCtrlQty,Op.PoRealQty,op.POOutQty, '+
              '  c.'+tmpfields+' as UseableStore, '+
              '  op.ItemListId,'+
              '  op.BillLineRemArk, '+
              '  op.Ite_ItemCode,'+
              '  op.usestyle,'+
              '  op.BomQty,op.BomScrAp_Percent '+
           'from OpItemList OP '+
           ' left join CurrentInv c '+
                ' on c.whCode='''+getCode(Cmbx_WhCodeName.text)+''''+
                ' and c.WhPositionCode='''+getCode(cmbx_Position.text)+''''+
                ' and c.ItemCode=op.ItemCode '+
            'left Join Item on Item.ItemCode=Op.ItemCode '+
            'left join Uom  on Uom.UomCode=Item.UomCode '+
            'left join poline on poline.pono=op.pono and '+
            ' poline.polineno=op.polineno '+
      ' where round(op.PoCtrlQty,0)-round(op.PoRealQty,0)<=0 '+
              ' and Op.PoNo='''+FPoNo+''' '+
              ' and poline.POLineStatus=6 '+
              isshowall+
//              ' and (Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' or '+
//              ' c.'+tmpFields+'>0)'+
              ' Order by Op.PoLineNo');
//    set_OverPlan(True);
    end
    Else
    begin
      Sql.Add('select '+
              '  op.pono,Op.PoLIneNo,Op.ItemCode, '+
              '  Item.ItemName,Uom.UomName, '+
              '  op.BilllineremArk BatchNo, '+
              '  op.ItemListId,'+
              '  op.usestyle,'+
              '  Op.PoCtrlQty,Op.PoRealQty,Op.POOutQty, '+
              '  case when c.'+tmpfields+' is Null then 0 else '+
              '  c.'+tmpfields+' end as UseableStore,op.BillLineRemArk,op.ite_ItemCode,'+
              '  op.BomQty,op.BomScrAp_Percent '+
              'from OpItemList OP '+
              ' left join CurrentInv c '+
              ' on c.whCode='''+getCode(Cmbx_WhCodeName.text)+''''+
              ' and c.WhPositionCode='''+getCode(cmbx_Position.text)+''''+
              ' and c.ItemCode=op.ItemCode '+
              'Join Item on Item.ItemCode=Op.ItemCode '+
              //'Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' '+
              'join Uom  on Uom.UomCode=Item.UomCode '+
              ' join poline on poline.pono=op.pono and '+
              ' poline.polineno=op.polineno '+
        ' where poline.POLineStatus=6  '+
              ' and Op.PoNo='''+FPoNo+''' '+
              //' and Op.PoCtrlQty>0 '+
//              ' and round(op.PoCtrlQty,0)-round(op.PoRealQty,0)>=0 '+
              isshowall+
//              ' and (Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' or '+
//              ' C.'+tmpfields+'>0)'+
              ' Order by Op.PoLineNo');
//      set_OverPlan(False);
    end;
    Open;
    for i:=0 to recordCount-1 do
    begin
      edit;
      fieldbyname('BatchNo').asstring:='';
      fieldbyname('POOutQty').asfloat:=0;
      fieldbyname('PoCtrlQty').asfloat:=round(fieldbyname('PoCtrlQty').asfloat);
      post;
      if fieldbyname('usestyle').asinteger=0 then
         ishave:=True;
      next;
    end;
    First;
  end;
  act_Save.Enabled :=ishave;
  AdoQry_Body.BeforePost:=mypost;
  //act_Save.Enabled:=False;
end;

procedure TFrm_Inv_OpOut_B.Act_autoExecute(Sender: TObject);
var
  i:integer;
  mypost:TDataSetNotifyEvent;
  Tmp_var:Double;
  BatchNo:String;
begin
{  Param5:=GetCode(Cmbx_WhCodeName.Text);
  Param6:=GetCode(Cmbx_Position.Text);
  If Param5='' then
  begin
    DispInfo('请选择一个仓库!',1);
    Abort;
  end;
  If Param6='' then
  begin
    DispInfo('请选择一个货位!',1) ;
    Abort;
  end;
  Frm_Entry_Detail.SetFormParam(AllowNegative,'','','','','');
  Frm_Entry_Detail.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
  inherited;}
  mypost:=AdoQry_Body.BeforePost;
  AdoQry_Body.BeforePost:=nil;
  AdoQry_Body.First;
  with AdoQry_Body do
  for i:=0 to recordCount-1 do
  begin
    Tmp_var:=
    min(round(fieldbyname('PoCtrlQty').asfloat)-round(fieldbyname('PoRealQty').asfloat),
    fieldbyname('UseableStore').asfloat);
    if BatchCtrl(AdoQry_Tmp,fieldbyname('ItemCode').asString) then
    begin
      BatchNo:=GiveBatchNo(AdoQry_Tmp,getCode(Cmbx_WhCodeName.text),
                     getCode(Cmbx_Position.text),fieldbyname('ItemCode').asString,
                     Medt_Date.text,Tmp_var);
      if BatchNo='' then
      begin
        next;
        continue;
      end
    end;
    edit;
    fieldbyname('BatchNo').asString:=BatchNo;
    fieldbyname('PooutQty').asfloat:=Tmp_var;
    if fieldbyname('PooutQty').asfloat<0 then fieldbyname('PooutQty').asfloat:=0;
    post;
    next;
  end;
  AdoQry_Body.First;
  DBGridEh.Refresh;
  act_Save.Enabled:=True;
  AdoQry_Body.BeforePost:=mypost;
end;

function TFrm_Inv_OpOut_B.InitwhposIfSpec:integer;
var
  i:integer;
  Str:string;
  Ado_tmp:TAdoQuery;
begin
  if IsSpecial then
  begin
    Ado_tmp:=TAdoQuery.Create(nil);
    Ado_tmp.Connection:=AdoQry_Body.Connection;
    Ado_tmp.SQL.text:='select WhPositionCode '+
                      '  from WhPosition '+
                      ' where WHCode='''+getCode(Cmbx_WhCodeName.Text)+''' and '+
                      '       WhPositionType=2';
    Ado_tmp.Open;
    Str:=Ado_tmp.fieldbyname('WhPositionCode').asstring;
    For i:=0 to Cmbx_Position.Items.Count-1 do
    if getCode(Cmbx_Position.Items[i])=Trim(str) then
    begin
      Result:=i;
      exit;
    end;
  end
  else  Result:=0;
end;

procedure TFrm_Inv_OpOut_B.DBGridEhKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  BatchStr:string;
  i:integer;
begin
  if not((key=vk_return)or(key=vk_f9)) then
  begin
    if dbgrideh.DataSource.DataSet.fieldbyname('usestyle').asinteger=1 then
    begin
      for i:=0 to dbgrideh.Columns.Count-1 do
         dbgrideh.Columns[i].ReadOnly :=True;
    end
    else
    begin
      dbgrideh.Columns[8].ReadOnly :=False;
      dbgrideh.Columns[9].ReadOnly :=False;
      dbgrideh.Columns[12].ReadOnly :=False;
    end;
  end;
  inherited;
  If Word(Key)=VK_F9 then
    with AdoQry_Body do
    begin
      BatchStr:=BatchHint(AdoQry_Tmp.Connection,fieldbyname('ItemCode').asstring,
                '',getCode(Cmbx_WhCodeName.text),getCode(Cmbx_Position.Text));
      if BatchStr<>'' then
      begin
        if not BatchInvCheck(AdoQry_Tmp,BatchStr,'c',
                      getCode(Cmbx_WhCodeName.text),
                      getCode(Cmbx_Position.text),
                      fieldbyname('POOutQty').asFloat) then Abort;
        edit;
        fieldbyname('BatchNo').asstring:=BatchStr;
        post;
      end;
    end;

end;

procedure TFrm_Inv_OpOut_B.Btn_QryOpCurrentInvClick(Sender: TObject);
begin
  inherited;
  Frm_Sys_Hint:=TFrm_Sys_Hint.Create(nil);
  Frm_Sys_Hint.InitForm(DBConnect,
              'select O.ItemCode+'' ''+I.ItemName 物料标识,'+
              '       O1.InvBlncQty 上月结存,'+
              '       O.OpInv 当月结存  '+
              'from OpCurrentInv O left join Item I on o.ItemCode=i.ItemCode'+
              '  left join OpMonthSum o1 on o.ItemCode=o1.ItemCode and o.VendorCode=o1.VendorCode '+
              '     and o1.InvMonth='''+formatdatetime('yyyy.mm',incMonth(strtodatetime(medt_Date.text),-1))+''' '+
              '  where O.ItemCode=I.ItemCode and '+
              '       O.VendorCode='''+getCode(Lbl_VendorCodeName.Caption)+''' '+
              '  Order by O.ItemCode ');
  Frm_Sys_Hint.ShowModal;
  Frm_Sys_Hint.Release;
end;

procedure TFrm_Inv_OpOut_B.DBGridEhEnter(Sender: TObject);
begin
  Medt_DateExit(sender);
  inherited;

end;

procedure TFrm_Inv_OpOut_B.DBGridEhGetCellParams(Sender: TObject;
  Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  inherited;
  if dbgrideh.DataSource.DataSet.fieldbyname('usestyle').asinteger=1 then
  begin
     Background:=clblue;
     afont.Color:=clwhite;
  end;
end;

end.

⌨️ 快捷键说明

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