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

📄 uform_from_edit.pas

📁 这是在SQL数据库下编写的一个源代码
💻 PAS
字号:
unit Uform_from_edit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, ImgList, ComCtrls, StdCtrls, Buttons, ExtCtrls;

type
  Tform_from_edit = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    Label2: TLabel;
    Label4: TLabel;
    Label3: TLabel;
    Label1: TLabel;
    Bevel1: TBevel;
    Image2: TImage;
    Panel2: TPanel;
    button_add: TBitBtn;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    Apart_list: TListView;
    ImageList1: TImageList;
    recordset_temp: TADOQuery;
    procedure FormShow(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure button_addClick(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    intCount:integer;
  end;

var
  form_from_edit: Tform_from_edit;

implementation

uses UForm_apart_input, Uform_main;

{$R *.dfm}

procedure Tform_from_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 * from [FROM]');
   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;

      new(p);
      p^ := recordset_temp.Fields[0].AsInteger ;
      listitem.Data :=p;
      recordset_temp.Next;
   end;
end;

procedure Tform_from_edit.BitBtn1Click(Sender: TObject);
var
   ListItem: TListItem;
   p:^integer;
begin
   repeat
      form_apart_input.Caption :='新建来源方式';
      form_apart_input.Edit1.Text :='';
      form_apart_input.Label1.Caption :='新建来源';
      form_apart_input.Label2.Caption :='新建来源';
      form_apart_input.Label3.caption:='    请在下面输入欲添加的来源方式的名称:';

      form_apart_input.Image2.Picture :=form_from_edit.Image2.Picture ;
      form_apart_input.ShowModal ;

      if form_apart_input.bYesno =false then exit;

      form_main.Dconnect.Execute ('insert into [FROM]([FROM_NAME]) values(''' + form_apart_input.stringApartname +''')');

      recordset_temp.SQL.Clear ;
      recordset_temp.SQL.Add ('select * from [FROM]');
      recordset_temp.Open ;
      recordset_temp.Last ;
      new(p);
      p^:=recordset_temp.Fields[0].AsInteger ;

      listitem:=apart_LIST.Items.Add ;
      listitem.Caption :=form_apart_input.stringApartname ;
      listitem.ImageIndex :=0 ;
      listitem.Data:=p;


      intCount := intCount+1;
      Label4.Caption :=inttostr(intCount) + '个';
   until messagebox(self.Handle ,'您是否还要添加新的来源方式?','提示',MB_YESNO or MB_ICONASTERISK)<> IDYES;


end;

procedure Tform_from_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 [FROM] where [FROM_ID]=' + inttostr(p^));

   recordset_temp.Open ;
   if recordset_temp.RecordCount <>0 then
   begin
      form_apart_input.Edit1.Text :=recordset_temp.Fields[1].AsString ;
      form_apart_input.Caption :='修改来源方式';
      form_apart_input.Label1.Caption :='修改来源';
      form_apart_input.Label2.Caption :='修改来源';
      form_apart_input.Label3.caption:='    请在下面修改来源方式的名称:';
      form_apart_input.Image2.Picture :=form_from_edit.Image2.Picture ;
      form_apart_input.ShowModal ;

      if form_apart_input.bYesno =true then
      begin
         form_main.Dconnect.Execute('update [FROM] set [FROM_NAME]=''' + form_apart_input.stringApartname + ''' where [FROM_ID]=' + inttostr(P^));
         apart_list.Selected.Caption :=form_apart_input.stringApartname ;
      end;

   end;
end;

procedure Tform_from_edit.BitBtn2Click(Sender: TObject);
var
   temp:pchar;
   p:^integer;
   count1:integer;
   count2:integer;
   count3:integer;
begin
   if apart_list.Selected =nil then exit ;

   p:=Apart_list.Selected.Data;

   recordset_temp.SQL.Clear;
   recordset_temp.SQL.Add('select count([CUSTOM_ID]) from [CUSTOM] where [CUSTOM_FROM]=' + 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] in ( select [CUSTOM_ID] from [CUSTOM] where [CUSTOM_FROM]=' + inttostr(p^) +')');
   recordset_temp.Open ;
   count2:=recordset_temp.Fields[0].AsInteger ;
   recordset_temp.Close ;

   recordset_temp.SQL.Clear ;
   recordset_temp.SQL.Add('select count([JY_ID]) from [JY] where [JY_CUSTOMID] in ( select [CUSTOM_ID] from [CUSTOM] where [CUSTOM_FROM]=' + inttostr(p^) +')');
   recordset_temp.Open;
   count3:=recordset_temp.Fields[0].AsInteger ;
   recordset_temp.Close ;

   temp:=pchar('您是否确定要删除['+apart_list.Selected.caption +  ']' + #13 +   #13 +
               '您将关联删除' + inttostr(count1) + '名客户纪录' + #13 +
               '您将关联删除' + inttostr(count2) + '条部门评价纪录' + #13 +
               '您将关联删除' + inttostr(count3) + '条交易纪录');
   p:=Apart_list.Selected.Data;
   if messagebox(self.Handle, temp,
                  '警告',MB_yesno or MB_ICONQUESTION	)=IDyes then
   begin
      
      form_main.Dconnect.Execute('delete * from [PJ] where [PJ_CU_ID] in ( select [CUSTOM_ID] from [CUSTOM] where [CUSTOM_FROM]=' + inttostr(p^) +')');
      form_main.Dconnect.Execute('delete * from [JY] where [JY_CUSTOMID] in ( select [CUSTOM_ID] from [CUSTOM] where [CUSTOM_FROM]=' + inttostr(p^) + ')');
      form_main.Dconnect.Execute('delete * from [CUSTOM] where [CUSTOM_FROM]=' + inttostr(p^));
      form_main.Dconnect.Execute('delete * from [FROM] where [FROM_ID]=' + inttostr(p^));
      Dispose(p);
      apart_list.Selected.Delete ;
      intCount := intCount-1;
      Label4.Caption :=inttostr(intCount) + '个';
   end;
   apart_list.SetFocus ;
end;

procedure Tform_from_edit.BitBtn3Click(Sender: TObject);
begin
   close;
end;

end.

⌨️ 快捷键说明

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