资源预览内容
第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
亲,该文档总共6页全部预览完了,如果喜欢就下载吧!
资源描述
版权归作者所有窗体Delphi 代码unit proj;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, Grids, DBGrids, ComCtrls, DB, ADODB;版权归作者所有typeTForm1 = class(TForm)GroupBox1: TGroupBox;Label1: TLabel;Label2: TLabel;Label3: TLabel;Label4: TLabel;Label5: TLabel;Label6: TLabel;Label7: TLabel;Label8: TLabel;Label9: TLabel;Label10: TLabel;Label11: TLabel;Label12: TLabel;Edit1: TEdit;Edit2: TEdit;Edit3: TEdit;Edit4: TEdit;DateTimePicker1: TDateTimePicker;DateTimePicker2: TDateTimePicker;DateTimePicker3: TDateTimePicker;Edit5: TEdit;Edit6: TEdit;Edit7: TEdit;Edit8: TEdit;GroupBox2: TGroupBox;DBGrid1: TDBGrid;Button1: TButton;Button2: TButton;Button3: TButton;ADOConnection1: TADOConnection;ADOQuery1: TADOQuery;Edit9: TEdit;ADOQuery2: TADOQuery;DataSource1: TDataSource;Button4: TButton;Button5: TButton;Edit10: TEdit;StatusBar1: TStatusBar;ClientDataSet1: TClientDataSet;cxDBTextEdit1: TcxDBTextEdit;procedure FormShow(Sender: TObject);procedure Button1Click(Sender: TObject);版权归作者所有procedure Button3Click(Sender: TObject);procedure Button2Click(Sender: TObject);procedure FormCreate(Sender: TObject);procedure DBGrid1CellClick(Column: TColumn);procedure Button4Click(Sender: TObject);procedure Button5Click(Sender: TObject);private Private declarations public Public declarations end;varForm1: TForm1;Projname:string;implementation$R *.dfmprocedure TForm1.FormShow(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;edit4.Clear;edit5.Clear;edit6.Clear;edit7.Clear;edit8.Clear;edit9.Clear;edit10.Clear;end;procedure TForm1.Button1Click(Sender: TObject); /增加beginADOQuery1.SQL.Add(insert into proj(公司代号,项目代码,项目名称,项目总价,开工日期,预定完工日期,完工结案日期,完工率,项目成本材料,项目成本人工,项目成本费用,是否结案) values (+edit1.Text+, +edit2.Text+,+edit3.Text+,+edit4.Text+,+datetostr(DateTimePicker1.Date)+,+datetostr(DateTimePicker2.Date)+,+datetostr(DateTimePicker3.Date)+,+edit5.Text+,+edit6.Text+,+edit7.Text+,+edit8.Text+,+edit9.Text+);ADOQuery1.ExecSQL;版权归作者所有ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add(select *from proj );ADOQuery1.Open;end;procedure TForm1.Button3Click(Sender: TObject); /修改beginwith ADOQuery2 dobeginclose;sql.Clear;sql.Add(update proj set 公司代号=+trim(edit1.Text)+,项目代码=+trim(edit2.Text)+,项目名称=+trim(edit3.Text)+,项目总价=+trim(edit4.Text)+,开工日期=+trim(datetostr(DateTimePicker1.Date)+,预定完工日期=+trim(datetostr(DateTimePicker2.Date)+,完工结案日期=+trim(datetostr(DateTimePicker3.Date)+,完工率=+trim(edit5.Text)+,项目成本材料=+trim(edit6.Text)+,项目成本人工=+trim(edit7.Text)+,项目成本费用=+trim(edit8.Text)+,是否结案=+trim(edit9.Text)+ where 项目名称=+trim(Projname)+);execsql;end;FormShow(Sender);end;procedure TForm1.Button2Click(Sender: TObject); /删除beginif ADOQuery1.RecordCount = 0 thenshowMessage(记录为空不能删除)elsebeginif MessageDlg(确定要删除吗? ,mtInformation,mbOK,mbCancel,0) = mrOK thenadoquery1.Delete;end;end;procedure TForm1.FormCreate(Sender: TObject);beginadoQuery1.SQL.Clear;adoQuery1.SQL.Add(select * from proj);adoQuery1.open;end;procedure TForm1.DBGrid1CellClick(Column: TColumn);begin版权归作者所有edit1.Text:=inttostr(ADOQuery1.fieldbyname(公司代号).AsInteger);edit2.Text:=ADOQuery1.fieldbyname(项目代码).AsString;edit3.Text:=ADOQuery1.fieldbyname(项目名称).AsString;edit4.Text:=ADOQuery1.fieldbyname(项目总价).AsString;DateTimePicker1.Date:=ADOQuery1.fieldbyname(开工日期).AsDateTime;DateTimePicker2.Date:=ADOQuery1.fieldbyname(预定完工日期).AsDateTime;DateTimePicker3.Date:=ADOQuery1.fieldbyname(完工结案日期).AsDateTime;edit5.Text:=ADOQuery1.fieldbyname(完工率).AsString;edit6.Text:=ADOQuery1.fieldbyname(项目成本材料).AsString;edit7.Text:=ADOQuery1.fieldbyname(项目成本人工).AsString;edit8.Text:=ADOQuery1.fieldbyname(项目成本费用).AsString;edit9.Text:=ADOQuery1.fieldbyname(是否结案).AsString;ProjName:=edit3.Text;end;procedure TForm1.Button4Click(Sender: TObject);beginclose;end;procedure TForm1.Button5Click(Sender: TObject); /查询beginadoquery1.Close;adoquery1.SQL.Clear;adoquery1.SQL.Add(select *from proj where 项目代码=+edit10.Text+);adoquery1.Open;end;end.数据库设计(sql2000)create table proj(公司名称 varchar(18) not null,项目代码 varchar(20) not null,项目名称 varchar(80) null,项目总价 numeric(28,8) null,开工日期 smalldatetime null,预定完工日期 smalldatetime null,完工结案日期 smalldatetime null,完工率 numeric(28,8) null,项目成本材料 numeric(28,8) null,项目成本人工 numeric(28,8) null,版权归作者所有项目成本费用 numeric(28,8) null,是否结案 bit null,constraint PK_PROJ primary key (公司名称, 项目代码)
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号