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

📄 uform_fw_edit.~pas

📁 Delphi应用婚纱系统 Delphi应用婚纱系统
💻 ~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 ;
   //读取FW表中所有的来源,显示在窗口中
   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 + -