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

📄 untgoodcodeselstr.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      t_sql:='select  *  from  [Vgoodscodeprice] where type ='+''''+trim(cbtype.text)+'''' +' and brand =' +''''+trim(cbbrand.text)+'''';   //5-11修改 old:vselectgoods
      T_sql := t_sql + ' and breed = ' + ''''+trim(cbbreed.text)+'''';
      end else
      begin
      t_sql:='select top ' + trim(ComboBox1.Text) +' *  from  [Vgoodscodeprice] where type ='+''''+trim(cbtype.text)+'''' +' and brand =' +''''+trim(cbbrand.text)+'''';
      end;
      T_sql := t_sql + ' and breed = ' + ''''+trim(cbbreed.text)+'''';
    end;
    str1 := ' and  id > '+ inttostr(localcount);

    strend := T_sql + str1;

///getmore 必须判断LOCALCOUNT是否大于RECORDCOUNT,如果大于则不执行。 条件更改以后必须重新为0

  try
   ipubtemp.ty_query(strend,quedata);
    if not varisnull(quedata) then
    begin
      dmmain.dsquery.EnableControls;
     if dmmain.dsquery.Active then dmmain.dsquery.Close;
      dmmain.dsquery.Open;
      dmmain.dsquery.AppendData(quedata,true);
      quedata:=null;
      ///ydy add
       dmmain.dsquery.Last;
    //重新打开
      //得到此次查询的键值
      LocalCount := GetKeyFieldValue('id');   //传入具体字段
    edtRecNo.Text := '当前共有'+inttostr(dmmain.dsquery.recordcount) +'条';
    end else
    begin
       //不再有数据
        dmmain.dsquery.EnableControls;        //ydy  必须要
       btnpagedown.Enabled := false;
       screen.Cursor :=  crdefault;
      exit;
    end;
  except
    dmmain.dsquery.EnableControls;
    dbgrid1.Refresh;
  end;
  dbgrid1.Refresh;
  screen.Cursor :=  crdefault;

end;


procedure TfmgoodCodeSelStr.FormShow(Sender: TObject);
var
  t_sql:string;
begin
  inherited;
   ///////调类别
  t_sql:='select * from  [goods_type]';
  //  t_sql:='select distinct type  from  [goods_code]';
  GetDataToComBoX(cbtype,t_sql,'type');
  cbtype.ItemIndex := -1;
  combobox1.ItemIndex:=0;
  dmmain.dsquery.Close;
  dmmain.dsquery.Data:=null;
end;

procedure TfmgoodCodeSelStr.CBTypeChange(Sender: TObject);
var
  t_sql:string;
begin
  inherited;
  if dmmain.DSquery.Active then dmmain.DSquery.Close;
  //调品牌
  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 TfmgoodCodeSelStr.cbBrandChange(Sender: TObject);
var
  t_sql:string;
begin
  inherited;
  //调品种
  if dmmain.DSquery.Active then dmmain.DSquery.Close;
  if cbtype.Text = '' then exit;
  t_sql:='select distinct breed  from  [goods_code] where type ='+''''+trim(cbtype.text)+'''' +' and brand =' +''''+trim(cbbrand.text)+'''';
  GetDataToComBoX(cbBreed,t_sql,'breed');
  cbBreed.ItemIndex := -1;
  edtrecno.Clear;
end;

procedure TfmgoodCodeSelStr.CbBreedChange(Sender: TObject);
var
  t_sql:string;
  quedata:olevariant;
begin
  inherited;
////////////查询数据
    quedata:=null;
   if cbbrand.Text = '' then exit;

   screen.Cursor := crhourglass;
   //关掉与DBGRID 的互动
   dmmain.dsquery.DisableControls;
   IF strtoint(SHOW_MODE) IN [2..4,7,9,12,14] then
   begin
     t_sql:='select top 20 *  from  [vSelectGoods] where type ='+''''+trim(cbtype.text)+'''' +' and brand =' +''''+trim(cbbrand.text)+'''';
     T_sql := t_sql + ' and breed = ' + ''''+trim(cbbreed.text)+''''+' and storage_no='+''''+trim(shopid)+'''';
   end else
   begin
     t_sql:='select top 20 *  from  [Vgoodscodeprice] where type ='+''''+trim(cbtype.text)+'''' +' and brand =' +''''+trim(cbbrand.text)+'''';   //5-11修改  OLD  vSelectGoods
     T_sql := t_sql + ' and breed = ' + ''''+trim(cbbreed.text)+'''';
   end;
   try
  if dmmain.DSquery.Active then dmmain.dsquery.Close;
  dmmain.dsquery.Data:=null;
   ipubtemp.ty_query(t_sql,quedata);  //.qurrecords(t_sql,quedata);
   if not varisnull(quedata) then
    begin
      dmmain.dsquery.Data:=quedata;
      dmmain.dsquery.Open;
      quedata:=null;
      dmmain.dsquery.Last;
      edtRecNo.Text := '当前已下载: '+inttostr(dmmain.dsquery.recordcount)+'条';
      dmmain.dsquery.EnableControls;
      dbgrid1.Refresh;
      LocalCount := GetKeyFieldValue('id');   //传入具体字段
    end else
    begin
       //不再有数据
       dmmain.dsquery.EnableControls;        //ydy  必须要
       btnpagedown.Enabled := false;
       screen.Cursor :=  crdefault;
      exit;
    end;
  except
    dmmain.dsquery.EnableControls;
    dbgrid1.Refresh;
  end;
  dbgrid1.Refresh;   //ydy add 2004-4-13
  screen.Cursor :=  crdefault;
end;

procedure TfmgoodCodeSelStr.btnQueryClick(Sender: TObject);
var
   x,i,countmy:integer;
   BookmarkList: TBookmarkList;
   TempBookmark: TBookmark;
begin
if show_mode='1' then
begin
  DBGrid1DblClick(Sender);
  exit;   //零售暂时不支持多行选择
end;

if not dmmain.DSquery.Active then
  begin
    if dbgrid1.SelectedRows.Count < 1 then
    Application.MessageBox('请指定出售的商品',pchar(application.Title),mb_iconinformation);
    exit;
end;
  DBGrid1.Datasource.Dataset.DisableControls;

  if   show_mode='2' then
  begin
    countmy :=fmScrap.sgorder.RowCount ;
    if fmScrap.sgorder. Cells[1,countmy-1] = '' then      ///最后一行为新增加的新行 2004-4-14 add
    countmy := countmy -1;
    with DBgrid1.SelectedRows do
      if Count > 0 then
          begin
            fmScrap.sgorder.RowCount := countmy  + count;     //modify ydy
            TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;

            for x:= 0 to Count - 1 do
            begin
                if IndexOf(Items[x]) > -1 then
            begin
            DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
            //得到选定的数据

            with  fmScrap do
            begin
              with sgorder do
              begin
                cells[0,countmy + x] := inttostr(countmy+ x);
                Cells[1,countmy + x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_NO').AsString);
                Cells[2,countmy + x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_Name').AsString);
                Cells[3,countmy + x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('singleprice').AsString);
                Cells[8,countmy + x]:=trim(DBGrid1.Datasource.Dataset.fieldbyname('baseprice').AsString);//成本假
                StockNum_List.Add(trim(DBGrid1.Datasource.Dataset.fieldbyname('Stock_amount').AsString));
              end;
            end;

            end;
            end;
            DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
            DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
            end else
            begin
              DBGrid1.Datasource.Dataset.EnableControls;
              Application.MessageBox('您没有选择商品,请选定商品!',pchar(application.Title),mb_iconinformation);
              exit;
            end;
end;

if   show_mode='3' then
begin
    countmy :=fmcheck.sgorder.RowCount;
    if fmcheck.sgorder. Cells[1,countmy-1] = '' then      ///最后一行为新增加的新行 2004-4-14 add
    countmy := countmy -1;
    with DBgrid1.SelectedRows do
      if Count > 0 then
          begin
            fmcheck.sgorder.RowCount := countmy + count;
            TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
            for x:= 0 to Count - 1 do
            begin
            if IndexOf(Items[x]) > -1 then
            begin
            DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
            //得到选定的数据

            with  fmcheck do
            begin
              with sgorder do
              begin
                cells[0,countmy+ x] := inttostr(countmy+ x);
                Cells[1,countmy +x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_NO').AsString);
                Cells[2,countmy +x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_Name').AsString);
                Cells[3,countmy+ x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('singleprice').AsString);
                cells[7,countmy+ x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('stock_amount').AsString);
              end;
            end;

            end;
            end;
            DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
            DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
            end else
            begin
              DBGrid1.Datasource.Dataset.EnableControls;
              Application.MessageBox('您没有选择商品,请选定商品!',pchar(application.Title),mb_iconinformation);
              exit;
            end;
end;

  if   show_mode='4' then
  begin
    countmy :=fmOverflow.sgorder.RowCount;
    if fmOverflow.sgorder.Cells[1,countmy-1] = '' then      ///最后一行为新增加的新行 2004-4-14 add
    countmy := countmy -1;
    with DBgrid1.SelectedRows do
      if Count > 0 then
          begin
            fmOverflow.sgorder.RowCount := countmy + count ;      ///2004-4-14 new ydy
            TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
            for x:= 0 to Count - 1 do
            begin
            if IndexOf(Items[x]) > -1 then
            begin
            DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
            //得到选定的数据

            with  fmOverflow do
            begin
              with sgorder do
              begin
                cells[0,countmy+ x] := inttostr(countmy+ x);
                Cells[1,countmy +x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_NO').AsString);
                Cells[2,countmy +x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_Name').AsString);
                Cells[3,countmy+ x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('singleprice').AsString);
                Cells[8,countmy + x]:=trim(DBGrid1.Datasource.Dataset.fieldbyname('baseprice').AsString);//成本假
              end;
            end;

            end;
            end;
            DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
            DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
            end else
            begin
              DBGrid1.Datasource.Dataset.EnableControls;
              Application.MessageBox('您没有选择商品,请选定商品!',pchar(application.Title),mb_iconinformation);
              exit;
            end;
  end;

  if   show_mode='5' then   //采购伙同
  begin
    countmy :=frm_stock_contract.stringgrid1.RowCount;
  if frm_stock_contract.stringgrid1.Cells[1,countmy-1] = '' then      ///最后一行为新增加的新行 2004-4-14 add
  countmy := countmy -1;
  with DBgrid1.SelectedRows do
  if Count > 0 then
  begin
    frm_stock_contract.stringgrid1.RowCount := countmy + count ;      ///2004-4-14 new ydy
    TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
    for x:= 0 to Count - 1 do
    begin
      if IndexOf(Items[x]) > -1 then
      begin
        DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
  //得到选定的数据
        with  frm_stock_contract do
        begin
          with stringgrid1 do
          begin
            cells[0,countmy+ x] := inttostr(countmy+ x);
            Cells[1,countmy +x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_NO').AsString);
            Cells[2,countmy +x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_Name').AsString);
            Cells[3,countmy +x]:='0';
            Cells[4,countmy +x]:='0';
            Cells[5,countmy +x]:='0';
            Cells[6,countmy+ x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('type').AsString);
            Cells[7,countmy+ x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('provider').AsString);
          end;
       end;
     end;
   end;
  DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
  DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
  end else
  begin
    DBGrid1.Datasource.Dataset.EnableControls;
    Application.MessageBox('您没有选择商品,请选定商品!',pchar(application.Title),mb_iconinformation);
    exit;
  end;
end;
/////////////////////////////////////////////////
  if   show_mode='6' then   //来货登记
  begin
    countmy :=frm_Goods_Write.stringgrid1.RowCount;
  if frm_Goods_Write.stringgrid1.Cells[1,countmy-1] = '' then      ///最后一行为新增加的新行 2004-4-14 add
    countmy := countmy -1;
  with DBgrid1.SelectedRows do
  if Count > 0 then
  begin
    frm_Goods_Write.stringgrid1.RowCount := countmy + count ;      ///2004-4-14 new ydy
    TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
    for x:= 0 to Count - 1 do
    begin
      if IndexOf(Items[x]) > -1 then
      begin
        DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
    //得到选定的数据
        with  frm_Goods_Write do

⌨️ 快捷键说明

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