📄 competitorproductorinfo.pas
字号:
unit competitorproductorinfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TF_competitorproductorinfo = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Label5: TLabel;
Edit5: TEdit;
Label6: TLabel;
Edit6: TEdit;
Label7: TLabel;
Edit7: TEdit;
btn_Search: TBitBtn;
btn_Update: TBitBtn;
btn_Add: TBitBtn;
btn_Delete: TBitBtn;
btn_Clear: TBitBtn;
btn_Out: TBitBtn;
ComboBox1: TComboBox;
procedure btn_SearchClick(Sender: TObject);
procedure btn_UpdateClick(Sender: TObject);
procedure btn_AddClick(Sender: TObject);
procedure btn_DeleteClick(Sender: TObject);
procedure btn_ClearClick(Sender: TObject);
procedure btn_OutClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_competitorproductorinfo: TF_competitorproductorinfo;
strSQL:String;
implementation
uses datamodule;
{$R *.dfm}
procedure TF_competitorproductorinfo.btn_SearchClick(Sender: TObject);
begin
with DM_datamodule do
begin
if crmDB.Connected then
begin
with qry_CompetitorProductorInfo do
begin
create(nil);
sql.Add('select * from CompetitorProductorInfo where 编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
prepare;
open;
if Recordcount<>0 then
begin
edit2.Text:=fieldbyname('产品名称').AsString;
edit3.Text:=fieldbyname('发布日期').AsString;
edit4.Text:=fieldbyname('价格').AsString;
edit5.Text:=fieldbyname('市场份额').AsString;
edit6.Text:=fieldbyname('市场反映').AsString;
edit7.Text:=fieldbyname('市场前景').AsString;
Close;
end
else
begin
messagedlg('不存在该竞争对手产品!查找失败!',mtinformation,[mbok],0);
close;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_competitorproductorinfo.btn_UpdateClick(Sender: TObject);
begin
strSQL:='update CompetitorProductorInfo set 产品名称=:f2,发布日期=:f3,价格=:f4,市场份额=:f5,市场反映=:f6,市场前景=:f7 where 编号=:f1';
with DM_datamodule do
begin
if crmDB.Connected then
begin
with qry_CompetitorProductorInfo do
begin
create(nil);
sql.Add('select * from CompetitorProductorInfo where 编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
open;
if Recordcount<>0 then
begin
sql.Add(strSQL);
Parambyname('f2').AsString:=edit2.Text;
Parambyname('f3').AsDateTime:=strtodatetime(edit3.Text);
Parambyname('f4').AsFloat:=strtofloat(edit4.Text);
Parambyname('f5').AsFloat:=strtofloat(edit5.Text);
Parambyname('f6').AsString:=edit6.Text;
Parambyname('f7').AsString:=edit7.Text;
ExecSQL;
Close;
messagedlg('修改成功!',mtinformation,[mbok],0);
edit2.Clear;
edit3.Text:=datetostr(now);
edit4.Text:='0.0';
edit5.Text:='0.0';
edit6.Clear;
edit7.Clear;
end
else
begin
messagedlg('不存在该竞争对手产品!修改失败!',mtinformation,[mbok],0);
close;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_competitorproductorinfo.btn_AddClick(Sender: TObject);
begin
strSQL:='insert into CompetitorProductorInfo values(:f1,:f2,:f3,:f4,:f5,:f6,:f7)';
with DM_datamodule do
begin
if crmDB.Connected then
begin
with qry_CompetitorProductorInfo do
begin
create(nil);
sql.Add('select * from CompetitorProductorInfo where 编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
open;
if Recordcount=0 then
begin
sql.Add(strSQL);
Parambyname('f2').AsString:=edit2.Text;
Parambyname('f3').AsDateTime:=strtodatetime(edit3.Text);
Parambyname('f4').AsFloat:=strtofloat(edit4.Text);
Parambyname('f5').AsFloat:=strtofloat(edit5.Text);
Parambyname('f6').AsString:=edit6.Text;
Parambyname('f7').AsString:=edit7.Text;
ExecSQL;
Close;
messagedlg('新增成功!',mtinformation,[mbok],0);
end
else
begin
messagedlg('已经存在该竞争对手编号!新增失败!',mtinformation,[mbok],0);
close;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_competitorproductorinfo.btn_DeleteClick(Sender: TObject);
begin
strSQL:='delete from CompetitorProductorInfo where 编号=:f1';
with DM_datamodule do
begin
if crmDB.Connected then
begin
if messagedlg('确定要删除吗?',mtinformation,[mbyes,mbno],0)=mrYes then
begin
with qry_CompetitorProductorInfo do
begin
create(nil);
sql.Add('select * from CompetitorProductorInfo where 编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
open;
if Recordcount<>0 then
begin
sql.Add(strSQL);
ExecSQL;
Close;
messagedlg('删除成功!',mtinformation,[mbok],0);
edit2.Clear;
edit3.Text:=datetostr(now);
edit4.Text:='0.0';
edit5.Text:='0.0';
edit6.Clear;
edit7.Clear;
end
else
begin
messagedlg('不存在该竞争对手!删除失败!',mtinformation,[mbok],0);
close;
end;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_competitorproductorinfo.btn_ClearClick(Sender: TObject);
begin
edit2.Clear;
edit3.Text:=datetostr(now);
edit4.Text:='0.0';
edit5.Text:='0.0';
edit6.Clear;
edit7.Clear;
end;
procedure TF_competitorproductorinfo.btn_OutClick(Sender: TObject);
begin
combobox1.Clear;
edit2.Clear;
edit3.Text:=datetostr(now);
edit4.Text:='0.0';
edit5.Text:='0.0';
edit6.Clear;
edit7.Clear;
close;
end;
procedure TF_competitorproductorinfo.FormShow(Sender: TObject);
begin
with DM_datamodule.qry_CompetitorInfo do
begin
close;
sql.Clear;
sql.Add('select 编号 from CompetitorInfo');
try
prepare;
execsql;
open;
first;
while not eof do
begin
combobox1.Items.Add(fieldbyname('编号').AsString);
next;
end;
finally
close;
end;
end;
combobox1.Text:=combobox1.Items.Text;
combobox1.ItemIndex:=0;
edit3.Text:=datetostr(now);
edit4.Text:='0.0';
edit5.Text:='0.0';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -