?? uform_custom_edit.pas
字號:
unit Uform_custom_edit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, DB, ADODB, ComCtrls, StdCtrls, Buttons, ExtCtrls,
ToolWin;
type
Tform_custom_edit = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label2: TLabel;
Label4: TLabel;
Label3: TLabel;
Label1: TLabel;
Bevel1: TBevel;
Image2: TImage;
recordset_temp: TADOQuery;
ImageList1: TImageList;
Apart_list: TListView;
Panel2: TPanel;
button_add: TBitBtn;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure button_addClick(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
intCount:integer;
end;
var
form_custom_edit: Tform_custom_edit;
implementation
uses Uform_custom_input, Uform_main, Uform_use_dollor;
{$R *.dfm}
procedure Tform_custom_edit.BitBtn3Click(Sender: TObject);
begin
close;
end;
procedure Tform_custom_edit.BitBtn1Click(Sender: TObject);
var
ListItem: TListItem;
p:^integer;
temp:string;
begin
repeat
form_custom_input.Caption :='客戶管理';
form_custom_input.Label1.Caption :='客戶管理';
form_custom_input.Label2.Caption :='客戶管理';
form_custom_input.string_custom_id :='';
form_custom_input.string_mname :='';
form_custom_input.string_fname :='';
form_custom_input.string_tel :='';
form_custom_input.string_address :='';
form_custom_input.string_postcode :='';
form_custom_input.int_area :=0;
form_custom_input.int_from :=0;
form_custom_input.ShowModal ;
if form_custom_input.bYesno =false then exit;
temp:='insert into [CUSTOM]' +
'([CUSTOM_CODE],[CUSTOM_MNAME],[CUSTOM_FNAME],[CUSTOM_TEL],[CUSTOM_AREA],[CUSTOM_ADD],[CUSTOM_FROM],[CUSTOM_POST],[CUSTOM_DATE])' +
' values(''' + form_custom_input.string_custom_id +''',''' + form_custom_input.string_mname + ' '',''' +
form_custom_input.string_fname + ' '','''+
form_custom_input.string_tel + ' '','+
inttostr(form_custom_input.int_area )+ ','''+
form_custom_input.string_address + ' '',' +
inttostr(form_custom_input.int_from)+ ','''+
form_custom_input.string_postcode + ''',#' +
datetimetostr(now)+ '#)';
form_main.Dconnect.Execute (temp);
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add ('select [CUSTOM_ID],[CUSTOM_CODE],[CUSTOM_MNAME],[CUSTOM_FNAME],[CUSTOM_TEL],[AREA_NAME],[CUSTOM_ADD],[FROM_NAME],[CUSTOM_POST],[CUSTOM_DATE] ' +
'from [CUSTOM],[AREA],[FROM] '+
'where [CUSTOM_AREA]=[AREA_ID] and [CUSTOM_FROM]=[FROM_ID]');
recordset_temp.Open ;
recordset_temp.Last ;
listitem:=apart_LIST.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.ImageIndex :=0;
listitem.SubItems.Add(recordset_temp.Fields[2].asstring);
listitem.SubItems.Add(recordset_temp.Fields[3].asstring);
listitem.SubItems.Add(recordset_temp.Fields[4].asstring);
listitem.SubItems.Add(recordset_temp.Fields[5].asstring);
listitem.SubItems.Add(recordset_temp.Fields[6].asstring);
listitem.SubItems.Add(recordset_temp.Fields[7].asstring);
listitem.SubItems.Add(recordset_temp.Fields[8].asstring);
listitem.SubItems.Add(DateTimeToStr(recordset_temp.Fields[9].AsDateTime));
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
intCount := intCount+1;
Label4.Caption :=inttostr(intCount) + '名';
until messagebox(self.Handle ,'您是否還要登記新的客戶?','提示',MB_YESNO or MB_ICONASTERISK)<> IDYES;
end;
procedure Tform_custom_edit.FormShow(Sender: TObject);
var
i:integer;
ListItem: TListItem;
p:^integer;
begin
apart_list.Items.Clear ;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add (
'select [CUSTOM_ID],[CUSTOM_CODE],[CUSTOM_MNAME],[CUSTOM_FNAME],[CUSTOM_TEL],[AREA_NAME],[CUSTOM_ADD],[FROM_NAME],[CUSTOM_POST],[CUSTOM_DATE] ' +
'from [CUSTOM],[AREA],[FROM] '+
'where [CUSTOM_AREA]=[AREA_ID] and [CUSTOM_FROM]=[FROM_ID]');
recordset_temp.Open ;
intCount:=recordset_temp.RecordCount ;
Label4.Caption :=inttostr(intCount) + '名';
for i:=1 to recordset_temp.RecordCount do
begin
listitem:=apart_LIST.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.ImageIndex :=0;
listitem.SubItems.Add(recordset_temp.Fields[2].asstring);
listitem.SubItems.Add(recordset_temp.Fields[3].asstring);
listitem.SubItems.Add(recordset_temp.Fields[4].asstring);
listitem.SubItems.Add(recordset_temp.Fields[5].asstring);
listitem.SubItems.Add(recordset_temp.Fields[6].asstring);
listitem.SubItems.Add(recordset_temp.Fields[7].asstring);
listitem.SubItems.Add(recordset_temp.Fields[8].asstring);
listitem.SubItems.Add(DateTimeToStr(recordset_temp.Fields[9].AsDateTime));
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
recordset_temp.Next;
end;
end;
procedure Tform_custom_edit.BitBtn2Click(Sender: TObject);
var
temp:pchar;
p:^integer;
count1:integer;
count2:integer;
begin
if apart_list.Selected =nil then exit ;
p:=apart_list.Selected.Data ;
recordset_temp.SQL.Clear;
recordset_temp.sql.Add('seleCt count([JY_ID]) from [JY] where [JY_CUSTOMID] =' + inttostr(p^));
recordset_temp.Open ;
count1:=recordset_temp.Fields[0].asinteger;
recordset_temp.Close ;
recordset_temp.SQL.Clear;
recordset_temp.sql.Add('seleCt count([PJ_ID]) from [PJ] where [PJ_CU_ID] =' + inttostr(p^));
recordset_temp.Open ;
count2:=recordset_temp.Fields[0].asinteger;
recordset_temp.Close ;
temp:=pchar('您是否確定要刪除['+apart_list.Selected.caption + ']' + #13 + #13 +
'您將關(guān)聯(lián)刪除' + inttostr(count1) + '條交易紀(jì)錄' + #13 +
'您將關(guān)聯(lián)刪除' + inttostr(count2) + '條評價紀(jì)錄' );
p:=Apart_list.Selected.Data;
if messagebox(self.Handle, temp,
'警告',MB_yesno or MB_ICONQUESTION )=IDyes then
begin
form_main.Dconnect.Execute('delete * from [JY] where [JY_CUSTOMID]=' + inttostr(p^));
form_main.Dconnect.Execute('delete * from [PJ] where [PJ_CU_ID]=' + inttostr(p^));
form_main.Dconnect.Execute('delete * from [CUSTOM] where [CUSTOM_ID]=' + inttostr(p^));
Dispose(p);
apart_list.Selected.Delete ;
intCount := intCount-1;
Label4.Caption :=inttostr(intCount) + '名';
end;
apart_list.SetFocus ;
end;
procedure Tform_custom_edit.button_addClick(Sender: TObject);
var
p:^integer;
begin
if apart_list.Selected =nil then exit ;
recordset_temp.SQL.Clear ;
p:=Apart_list.Selected.Data;
recordset_temp.SQL.Add ('select * from [CUSTOM] where [CUSTOM_ID]=' + inttostr(p^));
recordset_temp.Open ;
if recordset_temp.RecordCount <>0 then
begin
form_custom_input.string_custom_id :=recordset_temp.Fields[1].AsString ;
form_custom_input.string_mname:=recordset_temp.Fields[2].AsString ;
form_custom_input.string_fname :=recordset_temp.Fields[3].AsString ;
form_custom_input.string_tel :=recordset_temp.Fields[4].AsString ;
form_custom_input.int_area :=recordset_temp.Fields[5].AsInteger ;
form_custom_input.string_address :=recordset_temp.Fields[6].AsString ;
form_custom_input.int_from :=recordset_temp.Fields[7].AsInteger ;
form_custom_input.string_postcode :=recordset_temp.Fields[8].AsString ;
form_custom_input.ShowModal ;
if form_custom_input.bYesno =true then
begin
recordset_temp.Edit;
recordset_temp.Fields[1].AsString :=form_custom_input.string_custom_id ;
recordset_temp.Fields[2].AsString :=form_custom_input.string_mname + ' ';
recordset_temp.Fields[3].AsString :=form_custom_input.string_fname + ' ' ;
recordset_temp.Fields[4].AsString :=form_custom_input.string_tel + ' ' ;
recordset_temp.Fields[5].AsInteger :=form_custom_input.int_area ;
recordset_temp.Fields[6].AsString :=form_custom_input.string_address + ' ' ;
recordset_temp.Fields[7].AsInteger :=form_custom_input.int_from ;
recordset_temp.Fields[8].AsString :=form_custom_input.string_postcode ;
recordset_temp.Post ;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add (
'select [CUSTOM_ID],[CUSTOM_CODE],[CUSTOM_MNAME],[CUSTOM_FNAME],[CUSTOM_TEL],[AREA_NAME],[CUSTOM_ADD],[FROM_NAME],[CUSTOM_POST],[CUSTOM_DATE] ' +
'from [CUSTOM],[AREA],[FROM] '+
'where [CUSTOM_AREA]=[AREA_ID] and [CUSTOM_FROM]=[FROM_ID] and [CUSTOM_ID]=' + inttostr(p^));
recordset_temp.Open ;
apart_list.Selected.Caption :=form_custom_input.string_custom_id ;
apart_list.Selected.SubItems.Clear ;
apart_list.Selected.SubItems.Add(recordset_temp.Fields[2].asstring);
apart_list.Selected.SubItems.Add(recordset_temp.Fields[3].asstring);
apart_list.Selected.SubItems.Add(recordset_temp.Fields[4].asstring);
apart_list.Selected.SubItems.Add(recordset_temp.Fields[5].asstring);
apart_list.Selected.SubItems.Add(recordset_temp.Fields[6].asstring);
apart_list.Selected.SubItems.Add(recordset_temp.Fields[7].asstring);
apart_list.Selected.SubItems.Add(recordset_temp.Fields[8].asstring);
apart_list.Selected.SubItems.Add(DateTimeToStr(recordset_temp.Fields[9].AsDateTime));
end;
end;
end;
procedure Tform_custom_edit.BitBtn4Click(Sender: TObject);
var
p:^integer;
begin
if apart_list.Selected =nil then exit ;
p:=Apart_list.Selected.Data;
form_use_dollor.Edit1.Text :=apart_list.Selected.Caption ;
form_use_dollor.cid := p^;
form_use_dollor.ShowModal ;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -