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

📄 realtyb11.pas

📁 物业管理系统系统特点 一、 实现集中式管理 系统将集团公司、各分公司、各物业管理处连接到一起
💻 PAS
字号:
unit RealtyB11;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dbcgrids, Grids, DBGrids, DB, ADODB, StdCtrls, Buttons, ExtCtrls,
  StrUtils, ExtDlgs, ComCtrls, math, ToolWin, ImgList, Menus;

type
    Tf_RealtyB11 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    ListView1: TListView;
    ListView2: TListView;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    ComboBox1: TComboBox;
    Edit3: TEdit;
    Label4: TLabel;
    Edit4: TEdit;
    Label5: TLabel;
    Edit5: TEdit;
    Label6: TLabel;
    ComboBox2: TComboBox;
    Label7: TLabel;
    ComboBox3: TComboBox;
    Label8: TLabel;
    Label9: TLabel;
    Edit6: TEdit;
    Label10: TLabel;
    Edit7: TEdit;
    Label11: TLabel;
    Edit8: TEdit;
    Label12: TLabel;
    DateTimePicker1: TDateTimePicker;
    Label13: TLabel;
    Edit9: TEdit;
    Label14: TLabel;
    Edit10: TEdit;
    Label15: TLabel;
    Edit11: TEdit;
    Label16: TLabel;
    Edit12: TEdit;
    Label17: TLabel;
    Edit13: TEdit;
    Label18: TLabel;
    Edit14: TEdit;
    PopupMenu1: TPopupMenu;
    N53: TMenuItem;
    N4: TMenuItem;
    N6: TMenuItem;
    Button1: TButton;
    ToolButton1: TButton;
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ListView1CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ToolButton10Click(Sender: TObject);
    procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure N53Click(Sender: TObject);
    procedure ListView2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);

    procedure getID;
    procedure N4Click(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
     bMod:bool;
     sTable:string;
     cols:integer;
  end;

var
     f_RealtyB11: Tf_RealtyB11;
implementation

uses data, main,RealtyB111,RealtyB112,RealtyB22;
{$R *.dfm}

//初始化

procedure Tf_RealtyB11.getID;
Var
    query:TADOquery;
    s:string;
    i:integer;
begin
    query:=TADOQuery.Create(nil);
    query.Connection:=DataModuleADO.ADOConnection1;

    s := 'select top 1 * from 客户资料 ORDER BY  客户代码 DESC';

    Query.SQL.Add(s);
    Query.Open ;
    if query.recordcount > 0 then
    begin
        s:= Query.Fieldbyname('客户代码').AsString;
        s:= Copy(S, 1, 7);
        i:= strtoint(s)+1;
        if i<10 then edit1.text := '000000'+inttostr(i)
        else if (i > 9) and (i<100) then edit1.text := '00000'+inttostr(i)
        else if (i > 99) and (i<1000) then edit1.text := '0000'+inttostr(i)
        else if (i > 999) and (i<10000) then edit1.text := '000'+inttostr(i)
        else if (i > 9999) and (i<100000) then edit1.text := '00'+inttostr(i)
        else if (i > 99999) and (i<1000000) then edit1.text := '0'+inttostr(i)
        else if i>999999 then edit1.text := inttostr(i);
    end
    else  edit1.text := '0000001';

    query.Close;
    query.free;
end;
procedure Tf_RealtyB11.FormCreate(Sender: TObject);
begin
    pagecontrol1.ActivePageIndex:=0;
    datetimepicker1.Date:=date;

    combobox1.Items.Add('个人客户');
    combobox1.Items.Add('单位客户');

    combobox2.Items.Add('男');
    combobox2.Items.Add('女');

    combobox3.Items.Add('博士');
    combobox3.Items.add('研究生');
    combobox3.Items.Add('本科');
    combobox3.Items.Add('专科');
    combobox3.Items.Add('中专');
    combobox3.Items.Add('高中');
    combobox3.Items.Add('初中');
    combobox3.Items.add('小学');
    combobox3.Items.Add('其它'); 

    GetID;
end;



//Tab
procedure Tf_RealtyB11.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    if key=13 then
        Begin
            key:=0;
            perform(WM_NEXTDLGCTL,0,0);
        end
    else if key=VK_ESCAPE then close;
end;

procedure Tf_RealtyB11.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    Action := caFree;
end;


procedure Tf_RealtyB11.ListView1CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
    if   Item.Selected = true then
    begin
          Sender.Canvas.Brush.Color   :=   clMenuHighlight;
          (Sender   as   TListView).Canvas.Font.Color   :=  clWhite;
    end;
end;


procedure Tf_RealtyB11.ToolButton10Click(Sender: TObject);
begin
    close;
end;

procedure Tf_RealtyB11.ListView1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
    if button=mbRight then
    begin
        if edit1.Text='' then
         begin
             showmessage('请输入客户代码!');
             edit1.SetFocus;
             exit;
         end;
        PopupMenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);
    end;
end;

procedure Tf_RealtyB11.N53Click(Sender: TObject);
begin
     if pagecontrol1.ActivePageIndex=0 then
     begin
         bMod:=true;
         f_RealtyB111:=Tf_RealtyB111.create(self);
         f_RealtyB111.showmodal;
     end;
     if pagecontrol1.ActivePageIndex=1 then
     begin
         bMod:=true;
         f_RealtyB112:=Tf_RealtyB112.create(self);
         f_RealtyB112.showmodal;
     end;

end;

procedure Tf_RealtyB11.ListView2MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
    if button=mbRight then
    begin
        if edit1.Text='' then
         begin
             showmessage('请输入客户代码!');
             edit1.SetFocus;
             exit;
         end;
        PopupMenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);
    end;
end;

procedure Tf_RealtyB11.N4Click(Sender: TObject);
begin
    if pagecontrol1.ActivePageIndex=0 then
     begin
         if listview1.SelCount=0 then exit;
         bMod:=false;
         f_RealtyB111:=Tf_RealtyB111.create(self);
         f_RealtyB111.showmodal;
     end;
     if pagecontrol1.ActivePageIndex=1 then
     begin
         if listview2.SelCount=0 then exit;
         bMod:=false;
         f_RealtyB112:=Tf_RealtyB112.create(self);
         f_RealtyB112.showmodal;
     end;
end;

procedure Tf_RealtyB11.N6Click(Sender: TObject);
begin
    if pagecontrol1.ActivePageIndex=0 then
     begin
         if listview1.SelCount=0 then exit;
         listview1.Selected.Delete;
     end;
     if pagecontrol1.ActivePageIndex=1 then
     begin
         if listview2.SelCount=0 then exit;
         listview2.Selected.Delete;
     end;
end;

procedure Tf_RealtyB11.Button1Click(Sender: TObject);
Var
    query:TADOQuery;
    s:string;
    i:integer;
begin

    if edit1.Text='' then
    begin
        showmessage('客户代码不能为空!');
        edit1.SetFocus;
        exit;
    end;

    if edit2.Text='' then
    begin
        showmessage('客户名称不能为空!');
        edit2.SetFocus;
        exit;
    end;

    if edit3.Text='' then edit3.Text:='-';
    if edit4.Text='' then edit4.Text:='-';
    if edit5.Text='' then edit5.Text:='-';
    if edit6.Text='' then edit6.Text:='-';
    if edit7.Text='' then edit7.Text:='-';
    if edit8.Text='' then edit8.Text:='-';
    if edit9.Text='' then edit9.Text:='-';
    if edit10.Text='' then edit10.Text:='-';
    if edit11.Text='' then edit11.Text:='-';
    if edit12.Text='' then edit12.Text:='-';
    if edit13.Text='' then edit13.Text:='-';
    if edit14.Text='' then edit14.Text:='-';


    query:=TADOQuery.Create(nil);
    query.Connection:=DataModuleADO.ADOConnection1;


    query.SQL.Add('select * from 客户资料 where 客户代码='''+edit1.Text+'''');
    query.Open;
    if query.RecordCount>0 then
    begin
        showmessage('客户代码重复, 请重新输入!');
        edit1.SetFocus;
        exit;
    end;
    
    query.SQL.Clear;
    query.SQL.Add('select * from 客户资料 where 客户名称='''+edit2.Text+'''');
    query.Open;
    if query.RecordCount>0 then
    begin
        showmessage('客户名称重复, 请重新输入!');
        edit2.SetFocus;
        exit;
    end;

    //-------------------保存主表

    s:='insert into 客户资料 (客户代码,客户名称,客户类型,工作单位,电话,';
    s:=s+'手机号,性别,文化程度,MSN,邮编,';
    s:=s+'出生日期,身份证号码,籍贯,传真,电子邮件,';
    s:=s+'备注,地址,联系人)';
    s:=s+'values (:s1,:s2,:s3,:s4,:s5,';
    s:=s+':s6,:s7,:s8,:s9,:s10,';
    s:=s+':s11,:s12,:s13,:s14,:s15,';
    s:=s+':s16,:s17,:s18)';

    query.SQL.Clear;
    query.SQL.Add(s);
    query.Parameters.ParamByName('s1').Value:=edit1.Text;
    query.Parameters.ParamByName('s2').Value:=edit2.Text;
    query.Parameters.ParamByName('s3').Value:=ComboBox1.Text;
    query.Parameters.ParamByName('s4').Value:=edit3.Text;
    query.Parameters.ParamByName('s5').Value:=edit4.Text;

    query.Parameters.ParamByName('s6').Value:=edit5.Text;
    query.Parameters.ParamByName('s7').Value:=ComboBox2.Text;
    query.Parameters.ParamByName('s8').Value:=ComboBox3.Text;
    query.Parameters.ParamByName('s9').Value:=edit6.Text;
    query.Parameters.ParamByName('s10').Value:=edit7.Text;

    query.Parameters.ParamByName('s11').Value:=datetostr(datetimepicker1.Date);
    query.Parameters.ParamByName('s12').Value:=edit8.Text;
    query.Parameters.ParamByName('s13').Value:=edit9.Text;
    query.Parameters.ParamByName('s14').Value:=edit10.Text;
    query.Parameters.ParamByName('s15').Value:=edit11.Text;

    query.Parameters.ParamByName('s16').Value:=edit12.Text;
    query.Parameters.ParamByName('s17').Value:=edit13.Text;
    query.Parameters.ParamByName('s18').Value:=edit14.Text;

    DataModuleADO.ADOConnection1.BeginTrans;
    query.ExecSQL;
    DataModuleADO.ADOConnection1.CommitTrans;


    //-----------------保存从表

    for i:=0 to listview1.Items.Count-1 do
    begin
        if listview1.Items.Item[i].Caption='' then listview1.Items.Item[i].Caption:='-';
        if listview1.Items.Item[i].SubItems[0]='' then listview1.Items.Item[i].SubItems[0]:='-';
        if listview1.Items.Item[i].SubItems[1]='' then listview1.Items.Item[i].SubItems[1]:='-';
        if listview1.Items.Item[i].SubItems[2]='' then listview1.Items.Item[i].SubItems[2]:='-';
        if listview1.Items.Item[i].SubItems[3]='' then listview1.Items.Item[i].SubItems[3]:='-';
        if listview1.Items.Item[i].SubItems[4]='' then listview1.Items.Item[i].SubItems[4]:='-';
        if listview1.Items.Item[i].SubItems[5]='' then listview1.Items.Item[i].SubItems[5]:='-';

        s:='insert into 客户资料账号 (客户代码,开户名称,开户银行,银行账号,账号类型,';
        s:=s+'开户银行地址,是否主账号,备注)';
        s:=s+' values (:s1,:s2,:s3,:s4,:s5,';
        s:=s+':s6,:s7,:s8)';

        query.SQL.Clear;
        query.SQL.Add(s);
        query.Parameters.ParamByName('s1').Value:=edit1.Text;
        query.Parameters.ParamByName('s2').Value:=listview1.Items.Item[i].Caption;
        query.Parameters.ParamByName('s3').Value:=listview1.Items.Item[i].SubItems[0];
        query.Parameters.ParamByName('s4').Value:=listview1.Items.Item[i].SubItems[1];
        query.Parameters.ParamByName('s5').Value:=listview1.Items.Item[i].SubItems[2];
        query.Parameters.ParamByName('s6').Value:=listview1.Items.Item[i].SubItems[3];
        query.Parameters.ParamByName('s7').Value:=listview1.Items.Item[i].SubItems[4];
        query.Parameters.ParamByName('s8').Value:=listview1.Items.Item[i].SubItems[5];

        DataModuleADO.ADOConnection1.BeginTrans;
        query.ExecSQL;
        DataModuleADO.ADOConnection1.CommitTrans;

    end;

    for i:=0 to listview2.Items.Count-1 do
    begin
        if listview2.Items.Item[i].Caption='' then listview2.Items.Item[i].Caption:='-';
        if listview2.Items.Item[i].SubItems[0]='' then listview2.Items.Item[i].SubItems[0]:='-';
        if listview2.Items.Item[i].SubItems[1]='' then listview2.Items.Item[i].SubItems[1]:='-';
        if listview2.Items.Item[i].SubItems[2]='' then listview2.Items.Item[i].SubItems[2]:='-';
        if listview2.Items.Item[i].SubItems[3]='' then listview2.Items.Item[i].SubItems[3]:='-';
        if listview2.Items.Item[i].SubItems[4]='' then listview2.Items.Item[i].SubItems[4]:='-';

        s:='insert into 客户资料家庭成员 (客户代码,与客户关系,名称,电话,手机,';
        s:=s+'性别,说明)';
        s:=s+' values (:s1,:s2,:s3,:s4,:s5,';
        s:=s+':s6,:s7)';

        query.SQL.Clear;
        query.SQL.Add(s);
        query.Parameters.ParamByName('s1').Value:=edit1.Text;
        query.Parameters.ParamByName('s2').Value:=listview2.Items.Item[i].Caption;
        query.Parameters.ParamByName('s3').Value:=listview2.Items.Item[i].SubItems[0];
        query.Parameters.ParamByName('s4').Value:=listview2.Items.Item[i].SubItems[1];
        query.Parameters.ParamByName('s5').Value:=listview2.Items.Item[i].SubItems[2];
        query.Parameters.ParamByName('s6').Value:=listview2.Items.Item[i].SubItems[3];
        query.Parameters.ParamByName('s7').Value:=listview2.Items.Item[i].SubItems[4];

        DataModuleADO.ADOConnection1.BeginTrans;
        query.ExecSQL;
        DataModuleADO.ADOConnection1.CommitTrans;

    end;

    query.Close;
    query.free;
    
    showmessage('保存成功!');

    getID;
    edit2.Text:='';
    edit3.Text:='';
    edit4.Text:='';
    edit5.Text:='';
    edit6.Text:='';
    edit7.Text:='';
    edit8.Text:='';
    edit9.Text:='';
    edit10.Text:='';
    edit11.Text:='';
    edit12.Text:='';
    edit13.Text:='';
    edit14.Text:='';

    combobox1.ItemIndex:=Combobox1.Items.IndexOf('');
    combobox2.ItemIndex:=Combobox2.Items.IndexOf('');
    combobox3.ItemIndex:=Combobox3.Items.IndexOf('');

    datetimepicker1.Date:=date;

    listview1.Items.Clear;
    listview2.Items.Clear;

end;

procedure Tf_RealtyB11.ToolButton1Click(Sender: TObject);
begin
    close;
end;

end.

⌨️ 快捷键说明

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