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

📄 untwldwstaff.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 3 页
字号:

  t_sql:='select managerid from stock_manager where storageid='+''''+trim(shopid)+'''';
  datas:= null;
  ipubtemp.ty_query(t_sql,datas);
  if varisnull(datas) then
  begin
    ps:=true;
  end else
  begin
    ps:=false;
  end;
  ///////////////////////////
  if ps then
  begin
    t_sql:='select storage_no from  [storage] where storage_type<>'+''''+'门店仓库'+''''+' and storage_no<>'+''''+trim(shopid)+'''';
    cdspart.Close;
    cdspart.Data:=null;
    datas:=null;
    ipubtemp.ty_query(t_sql,datas);
    if not varisnull(datas) then
    begin
      cdspart.Data:=datas;
      cdspart.Open;
      datas:=null;
      while not cdspart.Eof do
      begin
        cmbmstorage.Items.Add('配送仓库'+trim(cdspart.fieldbyname('storage_no').AsString));
        cdspart.Next;
      end;
      cdspart.Close;
      cdspart.Data:=null;
    end;
  end;
  cmbmstorage.ItemIndex := 0;
  cmbmstorageChange(cmbmstorage);
  cmbmstorage.ItemIndex := -1;
  cmbbmstorage.Items:=cmbmstorage.Items;
end;

procedure TfmWldwStaff.N4Click(Sender: TObject);
var
  sql:widestring;
  datas:olevariant;
begin
  inherited;
  if not cdssoft.Active  then exit;
  if pagec1.ActivePageIndex =0 then
  begin
    if dbgrid1.DataSource =nil then exit;
    if dbgrid1.Visible then
    begin
      dbgrid1.Visible:=false;
      gridbase.Visible:=true;
      inistringgrid(gridbase,dbgrid1,true);
      //readdata(gridbase);
    end else
    begin
      dbgCur:=dbgrid1;
      gridbase.Visible:=true;
      dbgrid1.Visible:=false
    end;
  end;
  if pagec1.ActivePageIndex =1 then
  begin
    if dbgrid2.DataSource =nil then exit;
    if dbgrid2.Visible then
    begin
      dbgrid2.Visible:=false;
      gridBACK.Visible:=true;
      inistringgrid(gridBACK,dbgrid2,true);
      //readdata(gridBACK);
    end else
    begin
      dbgCur:=dbgrid2;
      gridBACK.Visible:=true;
      dbgrid2.Visible:=false
    end;
  end;
end;

procedure TfmWldwStaff.GridbaseDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  s:string;
  r:TRect;
begin
  inherited;
  with Sender as Tstringgrid do
  begin
  if gdSelected in State then
  Canvas.Brush.Color:= clTeal; //clyellow;//clRed;
  Canvas.TextRect(Rect,Rect.Left,Rect.Top,' '+Cells[ACol,ARow]);
  if gdFocused in State then
  Canvas.DrawFocusRect(Rect);
  end;
  with Sender as Tstringgrid do
  begin
    Canvas.FillRect(Rect);
    s:=Cells[ACol,ARow];
    r:=Rect;
    DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
  end;

end;

procedure TfmWldwStaff.DBGrid1TitleClick(Column: TColumn);
begin
  inherited;
  if (not dbgrid1.DataSource.DataSet.Active ) then exit;
  if trim(column.Field.AsString)='' then exit;
  sortgrid(column.Field.FieldName,cdssoft,dbgrid1,column);
end;

procedure TfmWldwStaff.DBGrid1DrawDataCell(Sender: TObject;
  const Rect: TRect; Field: TField; State: TGridDrawState);
begin
  inherited;
  setdbgrid(dbgrid1,2);
end;

procedure TfmWldwStaff.DBGrid1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  inherited;
  setdbgrid(dbgrid1,2);
end;

procedure TfmWldwStaff.BitBtn1Click(Sender: TObject);
var
  temp:widestring;
  datas:olevariant;
  str,str1:string;
  i,j:integer;
  zt:boolean;
begin
  inherited;
  iflag:='0';
  LocalCount:=0;
  vbegin:='';
  vend:='';
  tables:=' exec GridWldwBackStaff ';
  dbgCur:=dbgrid1;
    cdssoft.Close;
    cdssoft.Data:=null;
    cdssoft.IndexName:='';
    cdssoft.IndexDefs.Clear;
    tj:=' and 1=1 ';
    str1:='';
    zt:=false;
    if not ps then
    begin
      str1:=' (';
      for j:=0 to cmbstorages.Items.Count-2 do
      begin
        i:=pos('仓库', trim(cmbstorages.Items.Strings[j]));
        if i>0 then
        begin
          str1:=str1+''''+''''+copy(trim(cmbstorages.Items.Strings[j]),i+4,length(trim(cmbstorages.Items.Strings[j])))+''''+''''+',';
        end else
        begin
          str1:=str1+''''+''''+trim(cmbstorages.Items.Strings[j])+''''+''''+',';
        end;
      end;
      str1:=str1+''''+''''+trim(shopid)+''''+''''+',';
    end;
    if ckbtype.Checked then tj:=tj+' and c.type='+''''+''''+trim(cbtype.Text)+''''+'''';
    if ckbbrand.Checked then tj:=tj+' and c.brand='+''''+''''+trim(cbbrand.Text)+''''+'''';
    if ckbbreed.Checked then tj:=tj+' and c.breed='+''''+''''+trim(cbbreed.Text)+''''+'''';
    if cbwldw.Checked then tj:=tj+' and b.wldw='+''''+''''+trim(edtwldw.Text)+''''+'''';
    if cbinput.Checked then
    begin
      vbegin:=formatdatetime('yyyy-mm-dd',dtpinputb.Date);
      vend:=formatdatetime('yyyy-mm-dd',dtpinpute.Date);
    end;
    if cbmstorage.Checked then
    begin
      str1:=' (';
      i:=pos('仓库', trim(cmbmstorage.Text));
      if i>0 then
      begin
        str1:=str1+''''+''''+copy(trim(cmbmstorage.Text),i+4,length(trim(cmbmstorage.Text)))+''''+''''+',';
      end else
      begin
        str1:=str1+''''+''''+trim(cmbmstorage.Text)+''''+''''+',';
      end;
      zt:=true;
    end ;
    if cbstorages.Checked then
    begin
      if trim(cmbstorages.Text)<>'全部仓库' then
      begin
        if not zt then str1:=' (';
        str1:=str1+''''+''''+trim(cmbstorages.Text)+''''+''''+',';
      end else
      begin
        if not cbmstorage.Checked then str1:=' (';
        for j:=0 to cmbstorages.Items.Count-2 do
        begin
          i:=pos('仓库', trim(cmbstorages.Items.Strings[j]));
          if i>0 then
          begin
            str1:=str1+''''+''''+copy(trim(cmbstorages.Items.Strings[j]),i+4,length(trim(cmbstorages.Items.Strings[j])))+''''+''''+',';
          end else
          begin
            str1:=str1+''''+''''+trim(cmbstorages.Items.Strings[j])+''''+''''+',';
          end;
        end;
      end;
    end;
    if trim(str1)<>'' then
    begin
      str1:=copy(str1,1,length(str1)-1);
      str1:=str1+')';
      tj:=tj+' and a.storage_no in '+trim(str1);
    end;
    screen.Cursor :=  crHourGlass;
    temp:=tables+''''+vbegin+''''+','+''''+vend+''''+','+''''+tj+''''+','+iflag+','+inttostr(LocalCount);
    try
    datas:=adisp.GetRecord(temp);
    except
      application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
      screen.Cursor :=  crdefault;
      exit;
    end;
       ////////////////////////////////
      if  not varisnull(datas) then
      begin
      cdssoft.Data:=datas;
      cdssoft.Open;
      datas:=null;
      cdssoft.Last;
      LocalCount := GetKeyFieldValue('id',cdssoft);   //传入具体字段
      btnpagedown.Enabled:=true;
      with cdssoft.IndexDefs.AddIndexDef do
      begin
        Fields := 'goods_no';  //
        Options := [];
      end;
      cdssoft.IndexDefs.Update;
      cdssoft.Open;
      Gridbase.Visible:=false;
      dbgrid1.Visible:=true;
      /////////////
      dbgrid2.DataSource:=nil;
      dbgrid3.DataSource:=nil;
      dbgrid4.DataSource:=nil;
      dbgrid1.DataSource:=dsview;
      /////////////////////
      setdbgrid(dbgrid1,3);
      end;
      screen.Cursor :=  crdefault;

end;

procedure TfmWldwStaff.cbwldwClick(Sender: TObject);
begin
  inherited;
 ckbedit(cbwldw,edtwldw);
end;

procedure TfmWldwStaff.ckbtypeClick(Sender: TObject);
begin
  inherited;
  ckbcmb(ckbtype,cbtype);
    CBTypeChange(cbtype);
end;

procedure TfmWldwStaff.CBTypeChange(Sender: TObject);
var
  t_sql:string;
begin
  inherited;
  //调品牌
  t_sql:='select  distinct brand from  [goods_code] where type ='+''''+trim(cbtype.text)+'''';
  GetDataToComBoX(cbBrand,t_sql,'brand');
  cbBrand.ItemIndex := -1;
  cbbreed.Clear;

end;

procedure TfmWldwStaff.ckbbrandClick(Sender: TObject);
begin
  inherited;
     ckbcmb(ckbbrand,cbbrand);
   cbbrandchange(cbbrand);
end;

procedure TfmWldwStaff.cbBrandChange(Sender: TObject);
var
  t_sql:string;
begin
  inherited;  //调品种
  if cbtype.Text = '' then exit;
  t_sql:='select distinct breed  from  [goods_code] where brand ='+''''+trim(cbbrand.text)+''''+' and type =' +''''+trim(cbtype.text)+'''';
  GetDataToComBoX(cbBreed,t_sql,'breed');
  cbBreed.ItemIndex := -1;

end;

procedure TfmWldwStaff.ckbbreedClick(Sender: TObject);
begin
  inherited;
  ckbcmb(ckbbreed,cbbreed);
end;

procedure TfmWldwStaff.CbmstorageClick(Sender: TObject);
begin
  inherited;
  ckbcmb(cbmstorage,cmbmstorage);
end;

procedure TfmWldwStaff.cbstoragesClick(Sender: TObject);
begin
  inherited;
  ckbcmb(cbstorages,cmbstorages);
end;

procedure TfmWldwStaff.cmbmstorageChange(Sender: TObject);
var
  t_sql:string;
begin
  inherited;
  t_sql:='select storageid from stock_manager where managerid='+''''+trim(copy(trim(cmbmstorage.Text),pos('仓库',trim(cmbmstorage.Text))+4,length(trim(cmbmstorage.Text))))+'''';
  GetDataToComBoX(cmbstorages,t_sql,'storageid');
  cmbstorages.Items.Add('全部仓库');
  cmbstorages.ItemIndex:=-1;
end;

procedure TfmWldwStaff.btnpagedownClick(Sender: TObject);
var
  temp:widestring;
  datas:oleVariant;
begin
  inherited;
  if not cdssoft.Active then exit;
    screen.Cursor := crhourglass;
   cdssoft.DisableControls;
  try
  temp:=tables+''''+vbegin+''''+','+''''+vend+''''+','+''''+tj+''''+','+iflag+','+inttostr(LocalCount);
  try
  datas:=adisp.GetRecord(temp);
  except
    application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
    screen.Cursor :=  crdefault;
    exit;
  end;
  if not varisnull(datas) then
  begin
    cdssoft.Close;
    cdssoft.Open;
    cdssoft.AppendData(datas,true);
    cdssoft.Last;
    LocalCount := GetKeyFieldValue('id',cdssoft);   //传入具体字段
     ////////////////////////////////
    with cdssoft.IndexDefs.AddIndexDef do
    begin
      if pagec1.ActivePageIndex in [0,1] then
      begin
        Fields := 'goods_no';  //
      end ;
      if pagec1.ActivePageIndex=3 then
      begin
        Fields := 'supply_NO';  //
      end;
      Options := [];
    end;
    cdssoft.IndexDefs.Update;
    cdssoft.Open;
  //////////////////////////////////////       dmmain.cdsquery.Last;
    //重新打开
      cdssoft.EnableControls;
     setdbgrid(dbgrid1,3);
    end else
    begin
       //不再有数据
        cdssoft.EnableControls;        //ydy  必须要
       btnpagedown.Enabled := false;
       screen.Cursor :=  crdefault;
      exit;
    end;
  except
  end;
  if pagec1.ActivePageIndex =0 then
  begin
    dbgrid1.Visible:=true;
    gridbase.Visible:=false;
  end;
  if pagec1.ActivePageIndex =1 then
  begin
    dbgrid2.Visible:=true;
    gridback.Visible:=false;
  end;
  screen.Cursor :=  crdefault;

end;

procedure TfmWldwStaff.BitBtn4Click(Sender: TObject);
var
  temp:widestring;
  datas:olevariant;
  str,str1:string;
  i,j:integer;
  zt:boolean;
begin
  inherited;
  iflag:='1';
  LocalCount:=0;
  vbegin:='';
  vend:='';
  tables:=' exec GridWldwBackStaff  ';
   dbgCur:=dbgrid2;
   cdssoft.Close;
   cdssoft.Data:=null;
   cdssoft.IndexName:='';
    cdssoft.IndexDefs.Clear;
   tj:=' and 1=1 ';
   str1:='';
   zt:=false;
   if not ps then
    begin
      str1:=' (';
      for j:=0 to cmbbstorage.Items.Count-2 do
      begin
        i:=pos('仓库', trim(cmbbstorage.Items.Strings[j]));
        if i>0 then
        begin
          str1:=str1+''''+''''+copy(trim(cmbbstorage.Items.Strings[j]),i+4,length(trim(cmbstorages.Items.Strings[j])))+''''+''''+',';
        end else
        begin
          str1:=str1+''''+''''+trim(cmbbstorage.Items.Strings[j])+''''+''''+',';
        end;
      end;
      str1:=str1+''''+''''+trim(shopid)+''''+''''+',';
    end;
    if chbtype.Checked then tj:=tj+' and c.type='+''''+''''+trim(cmbtype.Text)+''''+'''';
    if chbbrand.Checked then tj:=tj+' and c.brand='+''''+''''+trim(cmbbrand.Text)+''''+'''';
    if chbbreed.Checked then tj:=tj+' and c.breed='+''''+''''+trim(cmbbreed.Text)+''''+'''';
    if chbwldw.Checked then tj:=tj+' and b.wldw='+''''+''''+trim(edtgeher.Text)+''''+'''';
    if cbcancel.Checked then
    begin
      vbegin:=formatdatetime('yyyy-mm-dd',dtpcancelb.Date);
      vend:=formatdatetime('yyyy-mm-dd',dtpcancele.Date);
    end;
    if chbmstorage.Checked then
    begin
      str1:=' (';
      i:=pos('仓库', trim(cmbbmstorage.Text));
      if i>0 then
      begin
        str1:=str1+''''+''''+copy(trim(cmbbmstorage.Text),i+4,length(trim(cmbbmstorage.Text)))+''''+''''+',';
      end else
      begin
        str1:=str1+''''+''''+trim(cmbbmstorage.Text)+''''+''''+',';
      end;
      zt:=true;
    end ;
    if cbstorages.Checked then
    begin
      if trim(cmbbstorage.Text)<>'全部仓库' then
      begin
        if not zt then str1:=' (';
        str1:=str1+''''+''''+trim(cmbbstorage.Text)+''''+''''+',';
      end else
      begin
        if not chbmstorage.Checked then str1:=' (';
        for j:=0 to cmbbstorage.Items.Count-2 do
        begin
          i:=pos('仓库', trim(cmbbstorage.Items.Strings[j]));
          if i>0 then
          begin
            str1:=str1+''''+''''+copy(trim(cmbbstorage.Items.Strings[j]),i+4,length(trim(cmbbstorage.Items.Strings[j])))+''''+''''+',';
          end else
          begin
            str1:=str1+''''+''''+trim(cmbbstorage.Items.Strings[j])+''''+''''+',';
          end;
        end;
      end;
    end;
    if trim(str1)<>'' then
    begin
      str1:=copy(str1,1,length(str1)-1);

⌨️ 快捷键说明

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