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

📄 unittuiliao.~pas

📁 仓储系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
    btnErase.enabled:=true;
    btnMod.enabled:=true;
    btnSave.enabled:=false;
    btnCancel.enabled:=false;
  end;
  DM.qry_TuiLiao.EnableControls;

  DM.qry_TuiLiao.close;
  DM.qry_TuiLiao.open;
end;

procedure TfrmTuiLiao.FormCreate(Sender: TObject);
var
  i:integer;
begin
  with ADOQuery_sql do
  begin
    //添加部门代码
    close;
    sql.Clear;
    sql.add('select * from Department order by Dept_id');
    open;
    setlength(listDept,recordcount);
    cbbDept.Items.clear;
    for i:=0 to recordcount - 1 do
    begin
      listDept[i]:=fieldbyname('Dept_id').asstring;
      cbbDept.items.Add(listDept[i]+' '+fieldbyname('Dept_name').asstring);
      next;
    end;
    //添加库房代码
    close;
    sql.Clear;
    sql.add('select * from StoreRoom order by Storeroom_zip');
    open;
    setlength(listKf,recordcount);
    cbbKf.Items.clear;
    for i:=0 to recordcount - 1 do
    begin
      listKf[i]:=fieldbyname('Storeroom_zip').asstring;
      cbbKf.items.Add(listKf[i]+' '+fieldbyname('Storeroom_name').asstring);
      next;
    end;
  end;
end;

procedure TfrmTuiLiao.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)+''' ');
    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;
  end;
end;

procedure TfrmTuiLiao.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 TfrmTuiLiao.dsTuiLiaoDataChange(Sender: TObject; Field: TField);
var
  str:string;
  i:integer;
begin
//----------Gys -----------Dept_id
  edtRkdh.text:=dm.qry_TuiLiao.fieldbyname('TL_Bill').asstring;
  edtJhbh.text:=dm.qry_TuiLiao.fieldbyname('Plan_id').asstring;

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

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

  edtNum.text:=dm.qry_TuiLiao.fieldbyname('TL_Amount').asstring;
  edtPrice.text:=dm.qry_TuiLiao.fieldbyname('TL_Price').asstring;
  edtTotalPrice.text:=dm.qry_TuiLiao.fieldbyname('TL_Zj').asstring;

  edtJsr.text:=dm.qry_TuiLiao.fieldbyname('TL_man').asstring;
  edtJyr.text:=dm.qry_TuiLiao.fieldbyname('Exam_man').asstring;
  edtZdr.text:=dm.qry_TuiLiao.fieldbyname('Oper_id').asstring;
  edtBz.text:=dm.qry_TuiLiao.fieldbyname('TL_memo').asstring;
  //---------部门-----------------------
  cbbDept.itemindex:=-1;
  str:=DM.qry_TuiLiao.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_TuiLiao.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;
  cbbKf.OnExit(sender);
  //---------库位-----------------------
  //这个地方还要修改,就是库房失去焦点时,库位的值不能正常显示
  cbbKw.itemindex:=-1;
  str:=DM.qry_TuiLiao.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 TfrmTuiLiao.edtRkdhKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
    key:=#0;
    perform(cm_dialogkey,vk_tab,0);
  end;
end;

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

procedure TfrmTuiLiao.FormShow(Sender: TObject);
var
  str:string;
begin
  str:=' select a.Xh,a.TL_Bill,a.Plan_id,                                       '+
       '    a.Mate_Code,b.Mate_Name,b.Mate_Type,                                '+
       '    a.Dept_id,a.TL_Date,                                                '+
       '    a.KfNo,a.KwNo,a.TL_Type,a.TL_Amount,a.TL_Price,a.TL_Zj,a.TL_Post,   '+
       '    b.Stoc_Amount,b.Mate_TotalPrice                                     '+
       '    a.TL_man,a.Audit_man,a.Exam_man,a.Oper_id,a.TL_memo                 '+
       '       from TuiLiao_Rk a                                                '+
       '   left outer join Mate_Basic b on a.Mate_Code=b.Mate_Code order by a.Xh ';
  with dm.qry_TuiLiao do
  begin
    close;
    sql.clear;
    sql.add(str);
    open;
  end;
end;

procedure TfrmTuiLiao.btnGzClick(Sender: TObject);
var
  seltotal,i:integer;
  myprocess:Tfrmprocess;
  //strdjh:string;
begin
  //根据入库单号、入库标志可直接判断出该单据是否已经过帐
  with dm.qry_TuiLiaoGz do
  begin
    close;
    sql.Clear;
    sql.Add('select * from TuiLiao_Rk where (TL_bill='''+trim(edtRkdh.text)+''')  and (TL_post=''Y'') ');
    open;
  end;
  if dm.qry_TuiLiaoGz.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_TuiLiao.Bookmark:=DBGrid1.SelectedRows.Items[i];
           //-------------------过帐--------------------------
           with dm.sp_TuiLiaoGz do
           begin
             dm.sp_TuiLiaoGz.ProcedureName:='TL_RkGz;1';
             Parameters.Refresh;
             Parameters.ParamByName('@Rkdh').value:=edtRkdh.Text;
             ExecProc;
           end;
           myprocess.closeprocess;
           DBGrid1.SelectedRows.Clear;
           DM.qry_TuiLiao.close;
           DM.qry_TuiLiao.open;
           application.MessageBox('所选入库单已全部过帐成功!!','提示',mb_ok+mb_iconinformation);
         end ;//end for
       finally
         myprocess.Free;
       end;      //end try
     end;
  end;
  dm.qry_TuiLiao.Close;
  dm.qry_TuiLiao.Open;
end;

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

procedure TfrmTuiLiao.edtNumExit(Sender: TObject);
begin
  edtTotalPrice.text:=FloatToStr(StrToFloat(edtNum.text)*StrToFloat(edtPrice.text));
  edtTotalPrice.enabled:=false;
  edtTotalPrice.color:=clInfoBk;
end;

procedure TfrmTuiLiao.DBGrid1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  if trim(dm.qry_TuiLiao.FieldByName('TL_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;

end.

⌨️ 快捷键说明

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