📄 uform_custom_pj.~pas
字号:
unit Uform_custom_pj;
//客户评价登记窗口
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Buttons, ImgList, DB, ADODB, ExtCtrls;
type
mytype=record
pjid:integer;
apartid:integer;
cuid:integer;
good:integer;
pjdd:tdatetime;
theytext:string;
pjbool:bool;
end;
Tform_custom_pj = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label2: TLabel;
Label1: TLabel;
Bevel1: TBevel;
Image2: TImage;
recordset_temp: TADOQuery;
ImageList1: TImageList;
Panel2: TPanel;
GroupBox1: TGroupBox;
Panel4: TPanel;
Label9: TLabel;
Label6: TLabel;
Label5: TLabel;
Label11: TLabel;
Label7: TLabel;
Label8: TLabel;
Label10: TLabel;
Label12: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Edit1: TEdit;
StaticText2: TStaticText;
StaticText1: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
ListView1: TListView;
Panel5: TPanel;
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
BitBtn2: TBitBtn;
button_add: TBitBtn;
recordset_temp1: TADOQuery;
procedure Edit1Change(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
cid:integer;
end;
var
form_custom_pj: Tform_custom_pj;
implementation
uses Uform_use_select, Uform_apart_yj, Uform_dollor_list;
{$R *.dfm}
procedure Tform_custom_pj.Edit1Change(Sender: TObject);
//通过用户输入的客户号在数据库中查询相应客户,并显示在窗口上
var
i:integer;
idc:integer;
ListItem: TListItem;
p:^mytype;
begin
//查询客户详细信息
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add ('select * from [CUSTOM] where [CUSTOM_CODE]="' + trim(edit1.Text ) + '"');
recordset_temp.Open ;
//判断是否存在该客户
if (recordset_temp.RecordCount <> 0) then
begin
//在窗口显示详细信息
cid:=recordset_temp.Fields [0].AsInteger ;
StaticText2.Caption := recordset_temp.Fields[2].AsString ;
StaticText1.Caption := recordset_temp.Fields[3].AsString ;
StaticText3.Caption := recordset_temp.Fields[9].AsString ;
StaticText7.Caption := recordset_temp.Fields[8].AsString ;
StaticText6.Caption := recordset_temp.Fields[4].AsString ;
StaticText4.Caption := recordset_temp.Fields[6].AsString ;
idc:=recordset_temp.Fields[5].AsInteger ;
recordset_temp.Close;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add('select * from [AREA] where [AREA_ID]=' + inttostr(IDC));
recordset_temp.Open ;
if( recordset_temp.RecordCount <>0) then
begin
statictext5.Caption :=recordset_temp.Fields[1].AsString;
end;
//在评价列表中显示所有部门
listview1.Clear ;
recordset_temp.Close;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add('select * from [APART]');
recordset_temp.Open ;
for i:=1 to recordset_temp.RecordCount do
begin
new(p);
p^.cuid :=cid;
p^.apartid :=recordset_temp.Fields[0].AsInteger ;
//查询曾经客户对相应部门的评价
recordset_temp1.SQL.Clear ;
recordset_temp1.SQL.Add('select * from [PJ] where [PJ_APART_ID]=' + inttostr(recordset_temp.Fields[0].asinteger) + ' and [PJ_CU_ID]=' + inttostr(cid));
recordset_temp1.Open ;
listitem:=listview1.Items.Add;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.ImageIndex :=0;
if recordset_temp1.recordcount<>0 then
begin
p^.pjbool :=true;
p^.pjid :=recordset_temp1.Fields[0].AsInteger ;
p^.pjdd :=recordset_temp1.Fields[4].AsDateTime ;
P^.theytext :=recordset_temp1.Fields[5].AsString ;
if recordset_temp1.Fields[3].AsInteger =0 then
begin
p^.good :=0;
listitem.SubItems.Add('优秀');
listitem.SubItems.Add(datetimetostr(recordset_temp1.Fields[4].asdatetime));
end;
if recordset_temp1.Fields[3].AsInteger =1 then
begin
listitem.SubItems.Add('一般');
p^.good :=1;
listitem.SubItems.Add(datetimetostr(recordset_temp1.Fields[4].asdatetime));
end;
if recordset_temp1.Fields[3].AsInteger =2 then
begin
listitem.SubItems.Add('不好');
listitem.SubItems.Add(datetimetostr(recordset_temp1.Fields[4].asdatetime));
p^.good :=2;
end;
end
else
begin
p^.pjbool :=false;
listitem.SubItems.Add('没有评价');
end;
listitem.Data:=p;
recordset_temp1.Close;
recordset_temp.Next;
end;
end
else
begin
//清空窗口中的所有信息
cid:=0;
StaticText1.Caption := '';
StaticText2.Caption := '';
StaticText3.Caption := '';
StaticText4.Caption := '';
StaticText5.Caption := '';
StaticText6.Caption := '';
StaticText7.Caption := '';
end;
recordset_temp.close;
end;
procedure Tform_custom_pj.SpeedButton2Click(Sender: TObject);
//通过客户列表选择客户
begin
//显示客户列表以供选择
form_use_select.ShowModal ;
if form_use_select.yesno =true then
begin
edit1.Text :=form_use_select.usercode ;//显示对应客户的详细信息
end;
end;
procedure Tform_custom_pj.BitBtn3Click(Sender: TObject);
//关闭窗口
begin
close;
end;
procedure Tform_custom_pj.BitBtn1Click(Sender: TObject);
//输入客户对某个部门的评价,并存入数据库
var
p:^mytype;
temp:pchar;
begin
temp:=pchar('对此部门这个用户已经评价过了,是否覆盖原评价');
//是否选中某个部门
if listview1.Selected = nil then exit ;
p:=listview1.Selected.Data ;
//是否对选中部门已经有过评价
if p^.pjbool =true then
begin
//确认操作
if messagebox(self.Handle, temp,
'警告',MB_yesno or MB_ICONQUESTION )<>IDyes then
begin
exit;
end;
//删除原有评价
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add('select * from [PJ] where [PJ_ID]=' + inttostr(p^.pjid ));
recordset_temp.Open ;
if recordset_temp.RecordCount >0 then
begin
recordset_temp.Delete ;
end;
recordset_temp.Close ;
end;
//显示部门评价窗口以输入评语
form_apart_yj.ShowModal ;
//是否确认评语输入
if form_apart_yj.yesno =false then exit;
//存入数据库
if TBitBtn(sender)=BitBtn1 then p^.good :=0;
if TBitBtn(sender)=BitBtn2 then p^.good :=1;
if TBitBtn(sender)=button_add then p^.good :=2;
p^.pjbool :=true;
p^.theytext :=form_apart_yj.tt ;
p^.pjdd :=now;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add('select * from [PJ]');
recordset_temp.Open ;
recordset_temp.Insert;
recordset_temp.Fields[1].AsInteger :=p^.apartid;
recordset_temp.Fields[2].AsInteger :=p^.cuid;
recordset_temp.Fields[3].AsInteger :=p^.good;
recordset_temp.Fields[4].AsDateTime :=p^.pjdd;
recordset_temp.Fields[5].AsString :=p^.theytext + ' ';
recordset_temp.UpdateBatch ;
//更新显示
recordset_temp.Last ;
p^.pjid:=recordset_temp.Fields[0].AsInteger ;
recordset_temp.close;
listview1.Selected.SubItems.Clear ;
if TBitBtn(sender)=BitBtn1 then listview1.Selected.SubItems.Add('优秀');
if TBitBtn(sender)=BitBtn2 then listview1.Selected.SubItems.Add('一般');
if TBitBtn(sender)=button_add then listview1.Selected.SubItems.Add('不好');
listview1.Selected.SubItems.add(datetimetostr(p^.pjdd ));
end;
procedure Tform_custom_pj.SpeedButton1Click(Sender: TObject);
//查看该用户的消费纪录
begin
if cid<>0 then
begin
form_dollor_list.cid:=cid;
form_dollor_list.ShowModal ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -