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

📄 uform_fw_edit.pas

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

interface

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

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

var
  form_fw_edit: Tform_fw_edit;

implementation

uses Uform_fw_input, Uform_main;

{$R *.dfm}

procedure Tform_fw_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 [FW]');
   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(format( '%8.2f¥',[recordset_temp.Fields[2].asfloat]));
      new(p);
      p^ := recordset_temp.Fields[0].AsInteger ;
      listitem.Data :=p;
      recordset_temp.Next;
   end;
end;

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

procedure Tform_fw_edit.BitBtn1Click(Sender: TObject);
var
   ListItem: TListItem;
   p:^integer;
begin
   repeat
      form_fw_input.Caption :='新建服务项目';
      form_fw_input.Edit1.Text :='';
      form_fw_input.Label1.Caption :='新建服务';
      form_fw_input.Label2.Caption :='新建服务';
      form_fw_input.Label3.caption:='服务项目的名称:';
      form_fw_input.label4.Caption :='服务项目的价格:';
      form_fw_input.ShowModal ;

      if form_fw_input.bYesno =false then exit;

      form_main.Dconnect.Execute ('insert into [FW]([FW_NAME],[FW_DOLLOR]) values(''' + form_fw_input.stringApartname + ''',' + floattostr(form_fw_input.floatDollor )+')');

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

      listitem:=apart_LIST.Items.Add ;
      listitem.Caption :=form_fw_input.stringApartname ;
      listitem.ImageIndex :=0 ;
      listitem.Data:=p;
      listitem.SubItems.Add(format( '%8.2f¥',[recordset_temp.Fields[2].asfloat]));
      

      intCount := intCount+1;
      Label4.Caption :=inttostr(intCount) + '种';
   until messagebox(self.Handle ,'您是否还要添加新的服务项目?','提示',MB_YESNO or MB_ICONASTERISK)<> IDYES;


end;

procedure Tform_fw_edit.BitBtn2Click(Sender: TObject);
var
   temp:pchar;
   p:^integer;
   countt: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_FWID]=' + inttostr(p^));
   recordset_temp.Open ;
   countt:=recordset_temp.Fields[0].AsInteger ;
   recordset_temp.Close ;

   temp:=pchar('您是否确定要删除['+apart_list.Selected.caption +  ']' + #13 + #13 +
               '您将关联删除' + inttostr(countt) + '条交易纪录');

   if messagebox(self.Handle, temp,
                  '警告',MB_yesno or MB_ICONQUESTION	)=IDyes then
   begin
      form_main.Dconnect.Execute('delete * from [JY] where [JY_FWID]=' + inttostr(p^));
      form_main.Dconnect.Execute('delete * from [FW] where [FW_ID]=' + inttostr(p^));
      Dispose(p);
      apart_list.Selected.Delete ;
      intCount := intCount-1;
      Label4.Caption :=inttostr(intCount) + '个';
   end;
   apart_list.SetFocus ;
end;

procedure Tform_fw_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 [FW] where [FW_ID]=' + inttostr(p^));

   recordset_temp.Open ;
   if recordset_temp.RecordCount <>0 then
   begin
      form_fw_input.Edit1.Text :=recordset_temp.Fields[1].AsString ;
      form_fw_input.Edit2.Text :=trim(format( '%8.2f',[recordset_temp.Fields[2].asfloat]));
      form_fw_input.Caption :='修改服务项目';
      form_fw_input.Label1.Caption :='修改服务';
      form_fw_input.Label2.Caption :='修改服务';
      form_fw_input.Label3.caption:='服务项目的名称:';
      form_fw_input.label4.Caption :='服务项目的价格:';
      form_fw_input.ShowModal ;

      if form_fw_input.bYesno =true then
      begin
         form_main.Dconnect.Execute('update [FW] set [FW_NAME]=''' + form_fw_input.stringApartname + ''',[FW_DOLLOR]=' +floattostr(form_fw_input.floatDollor )+ ' where [FW_ID]=' + inttostr(P^));
         apart_list.Selected.Caption :=form_fw_input.stringApartname ;
         apart_list.Selected.SubItems.Clear ;
         apart_list.selected.SubItems.Add(format( '%8.2f¥',[form_fw_input.floatDollor]));
      end;

   end;
end;

end.

⌨️ 快捷键说明

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