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

📄 unit4.~pas

📁 中鼎百货进销存系统
💻 ~PAS
字号:
unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, DB, ADODB, Grids, DBGrids,unit10;

type
  TForm4 = class(TForm)
    Label1: TLabel;
    DateTimePicker1: TDateTimePicker;
    Label2: TLabel;
    DateTimePicker2: TDateTimePicker;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Button1: TButton;
    ADOQuery1: TADOQuery;
    qur_conn: TADOConnection;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    ADOQuery2: TADOQuery;
    Button2: TButton;
    CheckBox4: TCheckBox;
    ComboBox4: TComboBox;
    Button3: TButton;
    function  ConnectDataBase():boolean;
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure ComboBox4Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}
function TForm4.ConnectDataBase():boolean;
var
 Constr:string;
begin
qur_conn.Close;
 try
  Constr:='Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=admin;';
  Constr:=Constr+'Data Source='+ExtractFilePath(Application.ExeName)+'database\ZD.mdb;Mode=ReadWrite';
 qur_conn.ConnectionString := Constr;
 qur_conn.Connected:=true;
 result:=true;
 except
 result:=false;
 application.MessageBox('连接数据库失败','提示',1);
 end;
end;

procedure TForm4.FormCreate(Sender: TObject);
var
S_manufactory:string;
begin
 ConnectDataBase;
 
 DateTimePicker1.Date:=now-30;
 DateTimePicker2.Date:=now;
 DateTimePicker1.DateFormat:=dfshort;
 DateTimePicker2.DateFormat:=dfshort;

 ADOQuery1.Close;
 ADOQuery1.SQL.Clear;
 ADOQuery1.sql.Add('select distinct ManuFactory from shopName');
 ADOQuery1.Open;

 Combobox4.Clear;
 while not ADOQuery1.Eof do
 begin
  S_manufactory:=ADOQuery1.FieldByName('ManuFactory').AsString;
  Combobox4.Items.Add(S_manufactory);
  ADOQuery1.Next;
 end;

end;

procedure TForm4.ComboBox1Click(Sender: TObject);
var
 sql,S_Ware,S_Size:string;
begin
   combobox2.Clear;
   sql:='Select distinct Shop_size from ShopName where Quality='''+combobox1.Text+''' and ManuFactory='''+combobox4.Text+'''';
   ADOQuery1.Close;
   ADOQuery1.SQL.Clear;
   ADOQuery1.SQL.Add(sql);
   ADOQuery1.Open;
   While not ADOQuery1.Eof do
   begin
     S_Size:=ADOQuery1.FieldByName('Shop_size').AsString;
     combobox2.Items.Add(S_Size);
     ADOQuery1.Next;
   end;
end;

procedure TForm4.Button1Click(Sender: TObject);
var
sql,sql1,sql2,sql3,sql4:string;
startdate,Enddate:TDatetime;
begin
startdate:=DateTimePicker1.Date;
Enddate:=DateTimePicker2.Date;
sql1:='Select ID as 编号, ManuFactory as 生产厂家,Quality as 品质,ware as 类别,Pzsize as 型号,packagenum as 包装数,cellnum as 数量,price as 进货价,Jiner as 金额,Pzuser as 经手人,inputdate as 进货日期 from InputCell where inputdate>=:s_date and inputdate<=:e_date';
if checkbox4.Checked then
sql2:=' and ManuFactory=:s_manu';
if (checkbox4.Checked) and (checkbox1.Checked) then
sql2:=' and ManuFactory=:s_manu and Quality=:s_quality';
if (checkbox4.Checked) and (checkbox1.Checked) and (checkbox2.Checked) then
sql2:=' and ManuFactory=:s_manu and Quality=:s_quality and Pzsize=:s_pzsize';


ADOQuery2.Close;
ADOQuery2.SQL.Clear;
if sql2='' then
ADOQuery2.SQL.Add(sql1)
else
ADOQuery2.SQL.Add(sql1+sql2);
sql:=sql1+sql2;
ADOQuery2.Parameters.ParamByName('s_date').Value:=startdate;
ADOQuery2.Parameters.ParamByName('e_date').Value:=Enddate;
if checkbox4.Checked then
ADOQuery2.Parameters.ParamByName('s_manu').Value:=combobox4.Text;
if (checkbox4.Checked) and (checkbox1.Checked) then
begin
ADOQuery2.Parameters.ParamByName('s_manu').Value:=combobox4.Text;
ADOQuery2.Parameters.ParamByName('s_quality').Value:=combobox1.Text;
end;
if (checkbox4.Checked) and (checkbox1.Checked) and (checkbox2.Checked) then
begin
ADOQuery2.Parameters.ParamByName('s_manu').Value:=combobox4.Text;
ADOQuery2.Parameters.ParamByName('s_quality').Value:=combobox1.Text;
ADOQuery2.Parameters.ParamByName('s_pzsize').Value:=combobox2.Text;
end;

ADOQuery2.Open;
end;

procedure TForm4.Button2Click(Sender: TObject);
begin
close;
end;

procedure TForm4.ComboBox4Click(Sender: TObject);
var
 sql,S_Quality:string;
begin
   combobox1.Clear;
   sql:='Select distinct Quality from ShopName where manufactory='''+combobox4.Text+'''';
   ADOQuery1.Close;
   ADOQuery1.SQL.Clear;
   ADOQuery1.SQL.Add(sql);
   ADOQuery1.Open;
   While not ADOQuery1.Eof do
   begin
     S_Quality:=ADOQuery1.FieldByName('Quality').AsString;
     combobox1.Items.Add(S_Quality);
     ADOQuery1.Next;
   end;
 end;

procedure TForm4.Button3Click(Sender: TObject);
var
sql,sql1,sql2,sql3,sql4:string;
startdate,Enddate:TDatetime;
begin
startdate:=DateTimePicker1.Date;
Enddate:=DateTimePicker2.Date;
sql1:='Select * from InputCell where inputdate>=:s_date and inputdate<=:e_date';
if checkbox4.Checked then
sql2:=' and ManuFactory=:s_manu';
if (checkbox4.Checked) and (checkbox1.Checked) then
sql2:=' and ManuFactory=:s_manu and Quality=:s_quality';
if (checkbox4.Checked) and (checkbox1.Checked) and (checkbox2.Checked) then
sql2:=' and ManuFactory=:s_manu and Quality=:s_quality and Pzsize=:s_pzsize';


form10.ADOQuery1.Close;
form10.ADOQuery1.SQL.Clear;
if sql2='' then
form10.ADOQuery1.SQL.Add(sql1)
else
form10.ADOQuery1.SQL.Add(sql1+sql2);
sql:=sql1+sql2;
form10.ADOQuery1.Parameters.ParamByName('s_date').Value:=startdate;
form10.ADOQuery1.Parameters.ParamByName('e_date').Value:=Enddate;
if checkbox4.Checked then
form10.ADOQuery1.Parameters.ParamByName('s_manu').Value:=combobox4.Text;
if (checkbox4.Checked) and (checkbox1.Checked) then
begin
form10.ADOQuery1.Parameters.ParamByName('s_manu').Value:=combobox4.Text;
form10.ADOQuery1.Parameters.ParamByName('s_quality').Value:=combobox1.Text;
end;
if (checkbox4.Checked) and (checkbox1.Checked) and (checkbox2.Checked) then
begin
form10.ADOQuery1.Parameters.ParamByName('s_manu').Value:=combobox4.Text;
form10.ADOQuery1.Parameters.ParamByName('s_quality').Value:=combobox1.Text;
form10.ADOQuery1.Parameters.ParamByName('s_pzsize').Value:=combobox2.Text;
end;

form10.ADOQuery1.Open;
form10.QuickRep1.Preview;
end;

end.

⌨️ 快捷键说明

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