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

📄 unitinoutdjqry.~pas

📁 仓储系统
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
    end;
    lbl_2.Caption:=inttostr(qry_2.RecordCount)+' 条';
  end else
  begin
    str:=copy(strtemp,1,length(strtemp)-4);

    with qry_2 do
    begin
      close;
      sql.clear;
      sql.add(str);
      open;
    end;
    lbl_2.Caption:=inttostr(qry_2.RecordCount)+' 条';
  end;
  //向采购入库添加内容--------------------------------
  clistbox2.clear;
  clistbox2.Items:=qry_2.FieldDefList;
  for i:=0 to clistbox2.items.Count - 1 do
  begin
    clistbox2.Checked[i]:=true;
  end;
  //------
  maxlength:=0;
  for i:=0 to clistbox2.items.count - 1 do
  begin
    if maxlength < length(clistbox2.Items.Strings[i]) then
    begin
      maxlength:=length(clistbox2.Items.Strings[i]);
      strmax:=clistbox2.Items.Strings[i];
    end;
  end;
  DC:=getDC(0);
  savefont:=selectobject(DC,font.handle);
  gettextextentpoint32(DC,pchar(strmax),maxlength,Textsize);
  MaxWidth:=Textsize.cx+getsystemmetrics(SM_CXBORDER)*4+50;
  selectobject(Dc,savefont);
  releaseDC(0,DC);
  SendMessage(cListBox2.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0);
end;

procedure TfrmInOutDjQry.meStart_2Exit(Sender: TObject);
var
  str:string;
begin
  str:=meStart_2.text;
  if str='' then exit;
  insert('-',str,5);
  insert('-',str,8);
  try
    strtodatetime(str);
  except
    application.MessageBox('日期输入错误!','警告',mb_ok+mb_iconwarning);
    meStart_2.Text:='';
    meStart_2.setfocus;
    exit;
  end;
end;

procedure TfrmInOutDjQry.BitBtnProductInClick(Sender: TObject);
var
  str,strTemp:string;
  str1,str2,str3,strStart,strEnd:string;

  i,j:integer;
  MaxWidth: integer;
  DC:HDC;
  savefont:Hfont;
  Textsize:Tsize;
  maxlength:integer;
  strmax:string;
begin
  if PageControl2.ActivePage=TabSheetProductIn then
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=true;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
  end;

  strTemp:=' select a.In_Bill as 入库单号,a.Plan_id as 计划编号,            '+
           '     a.Mate_Code as 物料编码,b.Mate_Name as 物料名称,           '+
           '     b.Mate_Type as 规格型号,b.Mate_Class as 物料类别,          '+
           '     a.Dept_id as 部门,a.KfNo as 库房代码,a.KwNo as 库位代码,   '+
           '     a.In_Date as 入库日期 ,a.In_Type as 入库类别,              '+
           '     a.In_Price as 入库单价,a.In_Amount as 入库数量,            '+
           '     a.In_Zj as 总价,a.In_Post as 过帐标志,                     '+
           '     a.In_man as 经手人,a.Exam_man as 检验人,                   '+
           '     a.Oper_id as 制单人,a.Rk_memo as 备注                      '+
           '  from Product_Rk a                                             '+
           '  left outer join Mate_Basic b on a.Mate_Code=b.Mate_Code where';

  //入库单号
  if edtRkdh_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.In_Bill='''+trim(edtRkdh_3.text)+''') and ';
  end;
  //计划编号
  if edtJhbh_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.Plan_id='''+trim(edtJhbh_3.text)+''') and ';
  end;
  //入库数量
  if edtNum_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.In_Amount='''+trim(edtNum_3.text)+''') and';
  end;
  //入库单价
  if edtPrice_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.In_Price='''+trim(edtPrice_3.text)+''') and';
  end;
  //入库总价
  if edtTotalPrice_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.In_Zj='''+trim(edtTotalPrice_3.text)+''') and';
  end;
  //物料编码
  if edtWlbm_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.Mate_Code='''+trim(edtWlbm_3.text)+''') and';
  end;
  //物料名称
  if edtWlmc_3.text<>'' then
  begin
    strTemp:=strTemp+'(b.Mate_Name='''+trim(edtWlmc_3.text)+''') and';
  end;
  //规格型号
  if edtType_3.text<>'' then
  begin
    strTemp:=strTemp+'(b.Mate_Type='''+trim(edtType_3.text)+''') and';
  end;
  //经手人
  if edtJsr_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.In_Man='''+trim(edtJsr_3.text)+''') and';
  end;
  //检验人
  if edtJyr_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.Exam_Man='''+trim(edtJyr_3.text)+''') and';
  end;
  //制单人
  if edtZdr_3.text<>'' then
  begin
    strTemp:=strTemp+'(a.Oper_id='''+trim(edtZdr_3.text)+''') and';
  end;
  //物料类别
  if cbbLb_3.text<>'' then
  begin
    i:=cbbLb_3.Items.IndexOf(cbbLb_3.text);
    if i=-1 then
    begin
      for j:=0 to high(listLb) do
      if listLb[j]=cbbLb_4.text then
      begin
         i:=j;
        break;
      end;
    end;
    if i<>-1 then
    begin
      strtemp:=strtemp+' (b.Mate_Class='''+listLb[i]+''') and';
    end;
  end;
  //起始日期
  str1:=copy(meStart_3.text,1,4);                       //2003
  str2:=copy(meStart_3.text,5,2);                       //07
  str3:=copy(meStart_3.text,7,2);                       //28
  strStart:=trim(str1)+trim(str2)+trim(str3);           //2003年07月28日
  //截止日期
  str1:=copy(meEnd_3.text,1,4);                         //2003
  str2:=copy(meEnd_3.text,5,2);                         //07
  str3:=copy(meEnd_3.text,7,2);                         //28
  strEnd:=trim(str1)+trim(str2)+trim(str3);             //2003年07月28日

  if (meStart_3.text<>'') and (meEnd_3.text<>'') then   //
  begin
    insert('-',strStart,5);
    insert('-',strStart,8);
    insert('-',strEnd,5);
    insert('-',strEnd,8);
    //strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)='''+strStart+''' and';
    strtemp:=strtemp+' (convert(varchar(10),a.In_Date,21)>='''+strStart+
                     ''' and convert(varchar(10),a.In_Date,21)<='''+strEnd+''') and '
  end
  else if meStart_3.text<>'' then
  begin
    insert('-',strStart,5);
    insert('-',strStart,8);
    strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)>='''+strStart+''' and';
  end
  else if meEnd_3.text<>''   then
  begin
    insert('-',strEnd,5);
    insert('-',strEnd,8);
    strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)<='''+strEnd+''' and'
  end;
  //
  if (edtRkdh_3.text='') and (edtJhbh_3.text='') and (edtNum_3.text='')
     and (edtPrice_3.text='') and (edtTotalPrice_3.text='')
     and (edtWlbm_3.text='') and (edtWlmc_3.text='') and (edtType_3.text='')
     and (edtJsr_3.text='') and (edtJyr_3.text='') and (cbbLb_3.text='') 
     and (meStart_3.text='') and (meEnd_3.text='')  then
  begin
    //application.messagebox('请至少输入一个查询条件','提示',mb_ok+mb_iconwarning);
    //edtRkdh_3.setfocus;
    strTemp:=copy(strtemp,1,length(strtemp)-6);

    with qry_3 do
    begin
      close;
      sql.clear;
      sql.add(strTemp);
      open;
    end;
    lbl_3.Caption:=inttostr(qry_3.RecordCount)+' 条';
  end else
  begin
    str:=copy(strtemp,1,length(strtemp)-4);

    with qry_3 do
    begin
      close;
      sql.clear;
      sql.add(str);
      open;
    end;
    lbl_3.Caption:=inttostr(qry_3.RecordCount)+' 条';
  end;
  //向成品入库添加内容--------------------------------
  clistbox3.clear;
  clistbox3.Items:=qry_3.FieldDefList;
  for i:=0 to clistbox3.items.Count - 1 do
  begin
    clistbox3.Checked[i]:=true;
  end;
  //------
  maxlength:=0;
  for i:=0 to clistbox3.items.count - 1 do
  begin
    if maxlength < length(clistbox3.Items.Strings[i]) then
    begin
      maxlength:=length(clistbox3.Items.Strings[i]);
      strmax:=clistbox3.Items.Strings[i];
    end;
  end;
  DC:=getDC(0);
  savefont:=selectobject(DC,font.handle);
  gettextextentpoint32(DC,pchar(strmax),maxlength,Textsize);
  MaxWidth:=Textsize.cx+getsystemmetrics(SM_CXBORDER)*4+50;
  selectobject(Dc,savefont);
  releaseDC(0,DC);
  SendMessage(cListBox2.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0);
end;

procedure TfrmInOutDjQry.meStart_3Exit(Sender: TObject);
var
  str:string;
begin
  str:=meStart_3.text;
  if str='' then exit;
  insert('-',str,5);
  insert('-',str,8);
  try
    strtodatetime(str);
  except
    application.MessageBox('日期输入错误!','警告',mb_ok+mb_iconwarning);
    meStart_3.Text:='';
    meStart_3.setfocus;
    exit;
  end;
end;

procedure TfrmInOutDjQry.PageControl2Change(Sender: TObject);
begin
  if PageControl2.ActivePage=TabSheetCg then                //采购入库
  begin
    TabSheetCg_1.TabVisible:=true;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
    edtRkdh.setfocus;
  end;
  if PageControl2.ActivePage=TabSheetZz then                //自制入库
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=true;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
    edtRkdh_2.setfocus;
  end;
  if PageControl2.ActivePage=TabSheetProductIn then         //成品入库
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=true;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
    edtRkdh_3.setfocus;
  end;
  if PageControl2.ActivePage=TabSheetTL then                //退料入库
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=true;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
    edtRkdh_4.setfocus;
  end;
  if PageControl2.ActivePage=TabSheetProductOut then        //成品出库
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=true;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
    edtCkdh_5.setfocus;
  end;
  if PageControl2.ActivePage=TabSheetLy then                //领用出库
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=true;
    TabSheetBf_1.TabVisible:=false;
    edtCkdh_6.setfocus;
  end;
  if PageControl2.ActivePage=TabSheetBf then                //报废出库
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=false;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=true;
    edtCkdh_7.setfocus;
  end;
end;

procedure TfrmInOutDjQry.BitBtnTLClick(Sender: TObject);
var
  str,strTemp:string;
  str1,str2,str3,strStart,strEnd:string;

  i,j:integer;
  MaxWidth: integer;
  DC:HDC;
  savefont:Hfont;
  Textsize:Tsize;
  maxlength:integer;
  strmax:string;
begin
  if PageControl2.ActivePage=TabSheetTL then
  begin
    TabSheetCg_1.TabVisible:=false;
    TabSheetZz_1.TabVisible:=false;
    TabSheetProductIn_1.TabVisible:=false;
    TabSheetTL_1.TabVisible:=true;
    TabSheetProductOut_1.TabVisible:=false;
    TabSheetLy_1.TabVisible:=false;
    TabSheetBf_1.TabVisible:=false;
  end;

  strTemp:=' select a.TL_Bill as 退料单号,a.Plan_id as 计划编号,                                '+
       '         a.Mate_Code as 物料编码,b.Mate_Name as 物料名称,b.Mate_Type as 规格型号,   '+
       '         a.Dept_id as 部门,a.KfNo as 库房,a.KwNo as 库位,                           '+
       '         a.TL_Date as 退料日期,a.TL_Type as 入库类别,                               '+
       '         a.TL_Amount as 退料数量,a.TL_Price as 单价,                                '+
       '         a.TL_Zj as 总价,a.TL_Post as 过帐标志,                                     '+
       '         a.TL_man as 经手人,a.Audit_man as 审批人,a.Exam_man as 检验人,             '+
       '         a.Oper_id as 制单人,a.TL_memo as 备注                                      '+
       '  from TuiLiao_Rk a                                                                 '+
       '  left outer join Mate_Basic b on a.Mate_Code=b.Mate_Code where';

  //入库单号
  if edtRkdh_4.text<>'' then
  begin
    strTemp:=strTemp+'(a.TL_Bill='''+trim(edtRkdh_4.text)+''') and ';
  end;
  //计划编号
  if edtJhbh_4.text<>'' then
  begin
    strTemp:=strTemp+'(a.Plan_id='''+trim(edtJhbh_4.text)+''') and ';
  end;
  //入库数量
  if edtNum_4.text<>'' then
  begin
    strTemp:=strTemp+'(a.TL_Amount='''+trim(edtNum_4.text)+''') and';
  end;
  //入库单价
  if edtPrice_4.text<>'' then
  begin
    strTemp:=strTemp+'(a.TL_Price='''+trim(edtPrice_4.text)+''') and';
  end;
  //入库总价
  if edtTotalPrice_4.text<>'' then
  begin
    strTemp:=strTemp+'(a.TL_Zj='''+trim(edtTotalPrice_4.text)+''') and';
  end;
  //物料编码
  if edtWlbm_4.text<>'' then
  begin
    strTemp:=strTemp+'(a.Mate_Code='''+trim(edtWlbm_4.text)+''') and';
  end;

⌨️ 快捷键说明

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