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

📄 unitproductin.~pas

📁 仓储系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
      listKw[i]:=fieldbyname('Storeplace_zip').asstring;
      listKwmc[i]:=fieldbyname('Storeplace_name').asstring;
      cbbKw.items.Add(listKw[i]+' '+listKwmc[i]);
      next;
    end;   }
  end;
end;

procedure TfrmProductIn.FormShow(Sender: TObject);
var
  str:string;
begin
  str:=' select a.Xh,a.In_Bill,a.Plan_id,                                 '+
       '      a.Mate_Code,b.Mate_Name,b.Mate_Type,                        '+
       '      a.Dept_id,a.In_Date,                                        '+
       '      a.KfNo,a.KwNo,a.In_Type,                                    '+
       '       c.PlanNum,c.Out_Sum,c.In_Sum,                              '+
       '      b.Stoc_Amount,b.Mate_TotalPrice,                            '+
       '      a.In_Amount,a.In_Price,a.In_Zj,a.In_Post,                   '+
       '      a.In_man,a.Exam_man,a.Oper_id,a.Rk_memo                     '+
       '   from Product_Rk a                                              '+
       '   left outer join Mate_Basic b on a.Mate_Code=b.Mate_Code        '+
       '   left outer join PlanNum c on a.Plan_id=c.PlanNo order by a.Xh  ';
   with dm.qry_ProductIn do
   begin
     close;
     sql.clear;
     sql.add(str);
     open;
   end;
end;

procedure TfrmProductIn.edtRkdhKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
    key:=#0;
    perform(cm_dialogkey,vk_tab,0);
  end;
end;

procedure TfrmProductIn.edtBzKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
    key:=#0;
    btnSave.setfocus;
  end;
end;

procedure TfrmProductIn.edtWlbmExit(Sender: TObject);
begin
{ if btnCancel.Focused then
  begin
    btnCancel.onclick(sender);
    exit;
  end;
  if btnClose.focused   then
  begin
     btnClose.OnClick(Sender);
     exit;
  end;
  //
  with ADOQuery_sql do
  begin
    close;
    sql.Clear;
    sql.Add('select * from mate_basic where (mate_code='''+trim(edtWlbm.text)+''') and (mate_class like ''PPP'' ) ');
    Open;
  end;
  if ADOQuery_sql.recordcount>0 then
  begin
    edtWlmc.text:=trim(ADOQuery_sql.fieldByName('Mate_Name').asstring);
    edtType.text:=trim(ADOQuery_sql.fieldByName('Mate_Type').asstring);
    edtPrice.text:=trim(ADOQuery_sql.fieldByName('Mate_Price').asstring);
    edtStockNum.text:=trim(ADOQuery_sql.fieldByName('Stoc_Amount').asstring);
    edtStockZJ.text:=trim(ADOQuery_sql.fieldByName('Mate_TotalPrice').asstring);
  end else
  begin
    application.messagebox('        基础物料中不存在该物料编码,      '#13#10'该物料不是成品,请重新输入!','提示',mb_ok+mb_iconwarning);
    edtWlbm.text:='';
    edtWlbm.setfocus;
    exit;
    frmMain.OpenMDIChild(TfrmMateBasic,frmMateBasic);
  end;        }
end;

procedure TfrmProductIn.edtRkdhExit(Sender: TObject);
begin
  if dm.qry_ProductIn.Locate('In_Bill',edtRkdh.text ,[loCaseInsensitive]) then
  begin
    application.MessageBox('注意:'+#13+'        入库单号重复,请重新输入!','警告',mb_ok+mb_iconwarning);
    edtRkdh.text:='';
    clear(frmProductIn);
    edtRkdh.SetFocus;
    exit;
  end;
end;

procedure TfrmProductIn.edtNumExit(Sender: TObject);
begin
  if btncancel.Focused then
  begin
    btncancel.OnClick(sender);
    exit;
  end;
  if btnclose.Focused then
  begin
    btnclose.OnClick(sender);
    exit;
  end;
  //
  if edtNum.text='0' then
  begin
    application.messagebox('本系统不允许零出库!','提示',mb_ok+mb_iconwarning);
    edtNum.setfocus;
    exit;
  end;

  //出库数量<计划数量、库存数量
  if strtofloat(edtNum.text)>strtofloat(edtJhNum.text) then
  begin
    application.messagebox('入库数量不能大于计划数量,请重新输入!','提示',mb_ok+mb_iconwarning);
    edtNum.setfocus;
    exit;
  end;
  //
  if (edtTotalIn.Value+edtNum.Value)>(edtJhNum.Value) then  //累计入库数+入库数<=计划数
  begin
    application.messagebox('累计入库数不能大于计划数,请重新输入!','提示',mb_ok+mb_iconwarning);
    edtNum.setfocus;
    exit;
  end;

  edtTotalPrice.text:=FloatToStr(StrToFloat(edtNum.text)*StrToFloat(edtPrice.text));
  edtTotalPrice.enabled:=false;
  edtTotalPrice.color:=clInfoBk;
end;

procedure TfrmProductIn.ds_ProductInDataChange(Sender: TObject;
  Field: TField);
var
  str:string;
  i:integer;
begin
//----------Gys -----------Dept_id
  edtRkdh.text:=dm.qry_ProductIn.fieldbyname('In_Bill').asstring;
  edtJhbh.text:=dm.qry_ProductIn.fieldbyname('Plan_id').asstring;

  edtwlbm.text:=dm.qry_ProductIn.fieldbyname('Mate_Code').asstring;
  edtWlmc.text:=dm.qry_ProductIn.fieldbyname('Mate_Name').asstring;
  edtType.text:=dm.qry_ProductIn.fieldbyname('Mate_Type').asstring;

  if dm.qry_ProductIn.fieldbyname('In_Date').IsNull then
     dtpRk.Date:=now
  else
     dtpRk.date:=dm.qry_ProductIn.fieldbyname('In_Date').asdatetime;

  edtJhNum.text:=dm.qry_ProductIn.fieldbyname('PlanNum').asstring;
  edtTotalIn.text:=dm.qry_ProductIn.fieldbyname('In_Sum').asstring;

  edtStockNum.text:=dm.qry_ProductIn.fieldbyname('Stoc_Amount').asstring;
  edtStockZJ.text:=dm.qry_ProductIn.fieldbyname('Mate_TotalPrice').asstring;

  edtNum.text:=dm.qry_ProductIn.fieldbyname('In_Amount').asstring;
  edtPrice.text:=dm.qry_ProductIn.fieldbyname('In_Price').asstring;
  edtTotalPrice.text:=dm.qry_ProductIn.fieldbyname('In_Zj').asstring;

  edtJsr.text:=dm.qry_ProductIn.fieldbyname('In_man').asstring;
  edtJyr.text:=dm.qry_ProductIn.fieldbyname('Exam_man').asstring;
  edtZdr.text:=dm.qry_ProductIn.fieldbyname('Oper_id').asstring;
  edtBz.text:=dm.qry_ProductIn.fieldbyname('Rk_memo').asstring;
  //---------部门-----------------------
  cbbDept.itemindex:=-1;
  str:=DM.qry_ProductIn.FieldByName('Dept_id').asstring;
  if high(listDept)>=0 then
  begin
    for i:=0 to high(listDept) do
    begin
      if listDept[i]=str then
      begin
        cbbDept.itemindex:=i;
        break;
      end;
    end;
  end;
  //---------库房-----------------------
  cbbKf.itemindex:=-1;
  str:=DM.qry_ProductIn.FieldByName('KfNo').asstring;
  if high(listKf)>=0 then
  begin
    for i:=0 to high(listKf) do
    begin
      if listKf[i]=str then
      begin
        cbbKf.itemindex:=i;
        break;
      end;
    end;
  end;
  //---------库位-----------------------
  cbbKw.itemindex:=-1;
  str:=DM.qry_ProductIn.FieldByName('KwNo').asstring;
  if high(listKw)>=0 then
  begin
    for i:=0 to high(listKw) do
    begin
      if listKw[i]=str then
      begin
        cbbKw.itemindex:=i;
        break;
      end;
    end;
  end;
  //
  //库存数量、库存总价--这里的代码影响基础物料打开后的数据显示
{  with ADOQuery_sql do
  begin
    close;
    sql.Clear;
    sql.Add('select * from mate_basic where mate_code='''+trim(edtWlbm.text)+''' ');
    open;
  end;
  if ADOQuery_sql.RecordCount>0 then
  begin
    edtStockNum.text:=ADOQuery_sql.fieldbyname('Stoc_Amount').asstring;
    edtStockZJ.text:=ADOQuery_sql.fieldbyname('Mate_TotalPrice').asstring;
  end;   }
end;

procedure TfrmProductIn.btnGzClick(Sender: TObject);
var
  seltotal,i:integer;
  myprocess:Tfrmprocess;
  //strdjh:string;
begin
  //根据入库单号、入库标志可直接判断出该单据是否已经过帐
  with dm.qry_ProductInGz do
  begin
    close;
    sql.Clear;
    sql.Add('select * from Product_Rk where (in_bill='''+trim(edtRkdh.text)+''')  and (in_post=''Y'') ');
    open;
  end;
  if dm.qry_ProductInGz.recordcount>0 then
  begin
    application.MessageBox('该单据已经过帐!','警告',mb_ok+mb_iconwarning);
    exit;
  end else     //下面是没有过帐
  begin
     //用1个存储过程进行过帐,更新对应的入库单号的数量、核算价格、和入库单的过帐标志
     if not btnadd.Enabled then
     begin
      application.MessageBox('注意:'+#13#10+'  请先保存或取消当前未完成的工作!','警告',mb_ok+mb_iconwarning);
      exit;
     end;
     seltotal:=DBGrid1.SelectedRows.Count;

     if seltotal=0 then
     begin
       application.MessageBox('注意:'+#13#10+'  请先选择要过帐的单据记录!','提示',mb_ok+mb_iconinformation);
       exit;
     end else//选项不为空
     begin
       //显示进度条
       myprocess:=Tfrmprocess.create(application);
       try
         myprocess.show;
         myprocess.setposition(0);
         //获得选中的记录
         for i:=0 to seltotal - 1 do
         begin
           DM.qry_ProductIn.Bookmark:=DBGrid1.SelectedRows.Items[i];
           //-------------------过帐--------------------------
           with dm.sp_ProductInGz do
           begin
             dm.sp_ProductInGz.ProcedureName:='Product_RkGz;1';
             Parameters.Refresh;
             Parameters.ParamByName('@Rkdh').value:=edtRkdh.Text;
             ExecProc;
           end;
           myprocess.closeprocess;
           DBGrid1.SelectedRows.Clear;
           DM.qry_ProductIn.close;
           DM.qry_ProductIn.open;
           application.MessageBox('所选入库单已全部过帐成功!!','提示',mb_ok+mb_iconinformation);
         end ;//end for
       finally
         myprocess.Free;
       end;      //end try
     end;
  end;
  dm.qry_ProductIn.Close;
  dm.qry_ProductIn.Open;
end;

procedure TfrmProductIn.cbbKfExit(Sender: TObject);
var
//  s_kf:string;
  i:integer;
begin
  if cbbkf.text='' then begin
    cbbKw.items.Clear;
    cbbKw.Text:='';
    exit;
  end;
  if btnCancel.Focused then
  begin
    btnCancel.onclick(sender);
    exit;
  end;
  if btnClose.focused   then
  begin
     btnClose.OnClick(Sender);
     exit;
  end;
  //
  with ADOQuery_sql do
  begin
    close;
    sql.clear;
    sql.add('select * from Storeposition where Storeroom_zip='+quotedstr(copy(cbbkf.text,1,2)));
    sql.add('order by StorePlace_zip');
    open;
    setlength(listKw,recordcount);
    cbbKw.Items.clear;
    for i:=0 to recordcount - 1 do
    begin
      listKw[i]:=fieldbyname('Storeplace_zip').asstring;
      cbbKw.items.Add(listKw[i]+' '+fieldbyname('Storeplace_name').asstring);
      next;
    end;
  end;
end;

procedure TfrmProductIn.sbtncodeClick(Sender: TObject);
begin
  frmSelectCodeNameType:=TfrmSelectCodeNameType.create(self);
  frmSelectCodeNameType.show;
end;

procedure TfrmProductIn.DBGrid1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  if trim(dm.qry_ProductIn.FieldByName('In_Post').AsString)='N' then
  begin
    DBGrid1.Canvas.Font.Color:=clGreen;
    DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
  end;
  //以突出显示当前选中的行
  if ((state=[gdSelected]) or (State=[gdSelected,gdFocused])) then
  begin
    DBGrid1.Canvas.Brush.Color:=clSkyBlue;
    DBGrid1.Canvas.Pen.Mode:=pmmask;
    DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
  end;
end;

procedure TfrmProductIn.edtJhbhExit(Sender: TObject);
begin
  with qry_Jhbh do
  begin
    close;
    sql.Clear;
    sql.Add('select * from PlanNum where PlanNo='''+trim(edtJhbh.text)+''' ');
    Open;
  end;
  if qry_Jhbh.recordcount>0 then
  begin
    edtJhNum.text:=trim(qry_Jhbh.fieldByName('PlanNum').asstring);
    edtWlbm.text:=trim(qry_Jhbh.fieldByName('Mate_Code').asstring);
    edtTotalIn.text:=trim(qry_Jhbh.fieldByName('In_Sum').asstring);       //累计入库数
    with ADOQuery_sql do
    begin
      close;
      sql.Clear;
      sql.Add('select * from mate_basic where (mate_code='''+trim(edtWlbm.text)+''') and (mate_class like ''PPP'' ) ');
      Open;
    end;
    if ADOQuery_sql.recordcount>0 then
    begin
      edtWlmc.text:=trim(ADOQuery_sql.fieldByName('Mate_Name').asstring);
      edtType.text:=trim(ADOQuery_sql.fieldByName('Mate_Type').asstring);
      edtPrice.text:=trim(ADOQuery_sql.fieldByName('Mate_Price').asstring);
      edtStockNum.text:=trim(ADOQuery_sql.fieldByName('Stoc_Amount').asstring);
      edtStockZJ.text:=trim(ADOQuery_sql.fieldByName('Mate_TotalPrice').asstring);
    end;

  end else
  begin
    application.messagebox('       计划数量基础表中不存在该计划编号,      '#13#10'请重新输入!','提示',mb_ok+mb_iconwarning);
    edtJhbh.text:='';
    edtJhbh.setfocus;
    exit;
  end;

  edtTotalIn.color:=clInfoBk;
end;

end.

⌨️ 快捷键说明

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