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

📄 unitxiangpin.pas

📁 这是一个很好的超市管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
var
  i: integer;
begin
  DBcombobox1.Clear;
  with DM.ADOQTEMP2 do
  begin
    if active then
      active := false;
    SQL.Clear;
    SQL.Add('SELECT distinct prod_sort FROM prod');
    if (not prepared) then
      prepared := true;
    active := true;
    if recordcount > 0 then
      first;
     for i := 0 to recordcount - 1 do
     begin
       DBCombobox1.Items.Add(fieldbyname('prod_sort').asstring);
       next;
     end;
  end;
end;

procedure TFrmXiangPin.own(Sender: TObject);
var
  i: integer;
begin
  DBCombobox3.Clear;
  with DM.ADOQTEMP2 do
  begin
    if active then
      active := false;
    SQL.clear;
    SQL.Add('SELECT prod_name FROM prod');
    if (not prepared) then
      prepared:= true;
    active := true;
    if (recordcount > 0) then
      first;
    for i := 0 to recordcount - 1 do
    begin
      DBCombobox3.Items.Add(fieldbyname('prod_name').AsString);
      next;
    end;
  end;
end;

procedure TFrmXiangPin.DBComboBox2DropDown(Sender: TObject);
var
  i: integer;
begin
  DBCombobox2.Clear;
  with DM.ADOQTEMP2 do
  begin
    if active then
      active := true;
    SQL.clear;
    SQL.Add('select distinct prod_unit from prod');
    if (not prepared) then
      prepared := true;
    active := true;
    if (recordcount > 0) then
      first;
    for i := 0 to recordcount - 1 do
    begin
      DBCombobox2.Items.Add(fieldbyname('prod_unit').AsString);
      next;
    end;
  end;
end;

procedure TFrmXiangPin.ComboBox1DropDown(Sender: TObject);
var
  i: integer;
begin
  Combobox1.Clear;
  Combobox1.Items.Add('全部');
  with DM.ADOQTEMP2 do
  begin
    if active then
      active := false;
    SQL.clear;
    SQL.Add('select distinct prod_sort from prod');
    if (not prepared) then
      prepared := true;
    active := true;
    if (recordcount > 0) then
      first;
    for i := 0 to recordcount - 1 do
    begin
      Combobox1.Items.Add(fieldbyname('prod_sort').AsString);
      next;
    end;
  end;
end;


procedure TFrmXiangPin.ComboBox1Change(Sender: TObject);
var
  i: integer;
begin
  Combobox2.Clear;
  if combobox1.Text <> '全部' then
  begin
    with DM.ADOQTEMP2 do
    begin
      if active then
        active := false;
      SQL.clear;
      SQL.Add('SELECT distinct prod_name, prod_id FROM prod WHERE prod_sort = :sort');
      parameters.ParamByName('sort').Value := Combobox1.Text;
      if (not prepared) then
        prepared := true;
      active := true;
      if recordcount > 0 then
        first;
      for i := 0 to recordcount - 1 do
      begin
        Combobox2.Items.Add(fieldbyname('prod_name').AsString);
        next;
      end;
      close;
      SQL.Clear;
      SQL.Add('SELECT distinct prod_id FROM prod where prod_sort = :sort');
      parameters.ParamByName('sort').Value := trim(Combobox1.Text);
      if (not prepared) then
        prepared := true;
      active := true;
      if recordcount > 0 then
        first;
      for i := 0 to recordcount - 1 do
      begin
        Combobox3.Items.Add(fieldbyname('prod_id').AsString);
        next;
      end;
    end;
  end
  else
  begin
    with DM.ADOQTEMP2 do
    begin
      if active then
        active := false;
      SQL.Clear;
      SQL.Add('select distinct prod_name from prod');
      if (not prepared) then
        prepared := true;
      active := true;
      if recordcount > 0 then
        first;
      for i := 0 to recordcount - 1 do
      begin
        combobox2.Items.Add(fieldbyname('prod_name').AsString);
        next;
      end;
      if active then
        active := false;
      SQL.Clear;
      SQL.Add('select distinct prod_id from prod');
      if (not prepared) then
        prepared := true;
      active := true;
      if recordcount > 0 then
        first;
      for i := 0 to recordcount - 1 do
      begin
        combobox3.Items.Add(fieldbyname('prod_id').AsString);
        next;
      end;
    end;
  end;
  Combobox1.Enabled := false;
  Combobox1.Color := clLtGray;
end;

procedure TFrmXiangPin.BitBtn1Click(Sender: TObject);
var
  str1, str2, str3: string;
begin
  combobox2.Enabled := true;
  combobox2.Color := clwindow;
  combobox3.Enabled := true;
  combobox3.Color := clwindow;
  str1 := 'select prod_sort, prod_id, prod_name, prod_price, prod_unit, in_id, in_number, in_price, in_time '
    + ' from prod, stock where in_prod_id = prod_id and prod_name = :name ';
  str2 := 'select prod_sort, prod_id, prod_name, prod_price, prod_unit, in_id, in_number, in_price, in_time '
    + ' from prod, stock where in_prod_id = prod_id and prod_sort = :sort ';
  str3 := 'select prod_sort, prod_id, prod_name, prod_price, prod_unit, in_id, in_number, in_price, in_time '
    + ' from prod, stock where in_prod_id = prod_id and prod_id = :id ';
  if (combobox1.Text <> '') and (combobox2.Text <> '') and (combobox3.Text = '') then
  begin
    with DM.ADOQXPXX1 do
    begin
      if active then
        active := true;
      SQL.Clear;
      SQL.Add(str1);
      parameters.ParamByName('name').Value := trim(combobox2.Text);
      if (not prepared) then
        prepared := true;
      active := true;
    end;
  end
  {if (combobox1.Text <> '') and (combobox2.Text = '') then
  begin
    with DM.ADOQTEMP2 do
    begin
      if active then
        active := true;
      SQL.Clear;
      SQL.Add(str2);
      parameters.ParamByName('sort').Value := trim(combobox1.Text);
      if (not prepared) then
        prepared := true;
      active := true;
      DBGrid1.DataSource := DM.dsADOQTEMP2;
    end;
  end }
  else
    if (combobox2.Text = '') and (combobox1.Text = '全部') and (combobox3.Text = '') then
    begin
    with DM.ADOQXPXX1 do
    begin
      if active then
        active := true;
      SQL.Clear;
      SQL.Text := 'select prod_sort, prod_id, prod_name, prod_price, prod_unit, in_id, in_number, in_price, in_time '
        + ' from prod, stock where in_prod_id = prod_id ';
      if (not prepared) then
        prepared := true;
      active := true;
    end;
  end
  else
    if (combobox2.Text = '') and (combobox1.Text <> '') and (combobox3.Text = '') then
    begin
      with DM.ADOQXPXX1 do
      begin
        if active then
        active := true;
        SQL.Clear;
        SQL.Add(str2);
        parameters.ParamByName('sort').Value := trim(combobox1.Text);
        if (not prepared) then
          prepared := true;
        active := true;
      end;
    end
  else
    if (Combobox1.Text <> '') and (combobox2.Text = '') and (combobox3.Text <> '') then
    begin
    with DM.ADOQXPXX1 do
    begin
      if active then
        active := true;
      SQL.Clear;
      SQL.Add(str3);
      parameters.ParamByName('id').Value := trim(combobox3.Text);
      if (not prepared) then
        prepared := true;
      active := true;
    end;
    end;
    combobox1.Clear;
    Combobox2.Clear;
    combobox3.Clear;
    DM.ADOQXPXX1.Close;
    DM.ADOQXPXX1.Open;
    Combobox1.Enabled := true;
    Combobox1.Color := clWindow;
end;

procedure TFrmXiangPin.ComboBox3Change(Sender: TObject);
begin
  Combobox2.Enabled := false;
  Combobox2.Color := clLtGray;
  if (combobox2.Text = '') then
  begin
    Combobox2.Enabled := true;
    Combobox2.Color := clWindow;
  end;
end;

procedure TFrmXiangPin.ComboBox2Change(Sender: TObject);
begin
  Combobox3.Enabled := false;
  Combobox3.Color := clLtGray;
  if (combobox2.Text = '') then
  begin
    Combobox3.Enabled := true;
    Combobox3.Color := clWindow;
  end;
end;

procedure TFrmXiangPin.DBComboBox4Change(Sender: TObject);
begin
 with DM.ADOQTEMP2 do
  begin
    if active then
      active := false;
    SQL.clear;
    SQL.Add('select * from prod where prod_id LIKE :id');
    parameters.ParamByName('id').Value := trim(DBcombobox4.Text);
    if (not prepared) then
      prepared := true;
    try
      active := true;
    except
      ExecSQL;
    end;
    if recordcount <> 0 then
    begin
      DBCombobox1.Text := fieldbyname('prod_sort').AsString;
      DBComboBox2.Text := fieldbyname('prod_unit').AsString;
      DBEdit1.Text := fieldbyname('prod_price').AsString;
      DBCombobox3.Text := fieldbyname('prod_name').AsString;
    end
    else
      begin
        exit;
      end;
  end;
end;

procedure TFrmXiangPin.DBComboBox1Change(Sender: TObject);
var
  str1, cha: string;
  i: integer;
begin
  DBCombobox4.Clear;
  cha := trim(DBcombobox1.Text);
  str1 := 'select distinct prod_id from prod where prod_sort LIKE :sort';
  with DM.ADOQTEMP2 do
  begin
    close;
    SQL.Clear;
    SQL.Add(str1);
    parameters.ParamByName('sort').Value := cha;
    if (not prepared) then
      prepared := true;
    try
      open;
    except
      ExecSQL;
    end;
    if (recordcount > 0 ) then
    begin
      first;
      for i := 0 to recordcount -1 do
      begin
        DBcombobox4.Items.Add(fieldbyname('prod_id').AsString);
        next;
      end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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