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

📄 uform_use_dollor.~pas

📁 Delphi应用婚纱系统 Delphi应用婚纱系统
💻 ~PAS
字号:
unit Uform_use_dollor;
//消费登记窗口,用于记录每次消费情况
interface

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

type
  mytype=record
        id:integer;
        nname:string;
        alldollor:real;
        count:integer;
        dollor:real;
  end;
  Tform_use_dollor = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    Label2: TLabel;
    Label1: TLabel;
    Bevel1: TBevel;
    Image2: TImage;
    ImageList1: TImageList;
    recordset_temp: TADOQuery;
    Panel3: TPanel;
    GroupBox1: TGroupBox;
    Panel4: TPanel;
    Label9: TLabel;
    Label6: TLabel;
    Label5: TLabel;
    Label11: TLabel;
    Edit1: TEdit;
    Splitter1: TSplitter;
    GroupBox2: TGroupBox;
    ListView1: TListView;
    Panel5: TPanel;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn2: TBitBtn;
    button_add: TBitBtn;
    BitBtn4: TBitBtn;
    StaticText2: TStaticText;
    StaticText1: TStaticText;
    StaticText3: TStaticText;
    StaticText4: TStaticText;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label12: TLabel;
    StaticText5: TStaticText;
    StaticText6: TStaticText;
    StaticText7: TStaticText;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    DateTimePicker1: TDateTimePicker;
    Label3: TLabel;
    procedure BitBtn3Click(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure button_addClick(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    cid:integer;
  end;


var
  form_use_dollor: Tform_use_dollor;


implementation

uses Uform_use_select, Uform_fw_select, Uform_userfw_edit,
  Uform_dollor_list;

{$R *.dfm}

procedure Tform_use_dollor.BitBtn3Click(Sender: TObject);
//关闭窗口
begin
   close;
end;

procedure Tform_use_dollor.Edit1Change(Sender: TObject);
//根据客户号查询该客户的相关信息
var
   idc:integer;
begin
   //根据用户输入查询数据库
   recordset_temp.SQL.Clear ;
   recordset_temp.SQL.Add ('select * from [CUSTOM] where [CUSTOM_CODE]="' + trim(edit1.Text ) + '"');
   recordset_temp.Open ;
   //数据库中是否存在该客户
   if (recordset_temp.RecordCount <> 0) then
   begin
      //显示客户相关信息
      cid:=recordset_temp.Fields [0].AsInteger ;
      StaticText2.Caption := recordset_temp.Fields[2].AsString ;
      StaticText1.Caption := recordset_temp.Fields[3].AsString ;
      StaticText3.Caption := recordset_temp.Fields[9].AsString ;
      StaticText7.Caption := recordset_temp.Fields[8].AsString ;
      StaticText6.Caption := recordset_temp.Fields[4].AsString ;
      StaticText4.Caption := recordset_temp.Fields[6].AsString ;
      idc:=recordset_temp.Fields[5].AsInteger ;
      recordset_temp.Close;
      recordset_temp.SQL.Clear ;
      recordset_temp.SQL.Add('select * from [AREA] where [AREA_ID]=' + inttostr(IDC));
      recordset_temp.Open ;
      if( recordset_temp.RecordCount <>0) then
      begin
         statictext5.Caption :=recordset_temp.Fields[1].AsString;
      end;
   end
   else
   begin
      //窗口中的客户相关信息为空
      cid:=0;
      StaticText1.Caption := '';
      StaticText2.Caption := '';
      StaticText3.Caption := '';
      StaticText4.Caption := '';
      StaticText5.Caption := '';
      StaticText6.Caption := '';
      StaticText7.Caption := '';
   end;
   recordset_temp.close;
end;

procedure Tform_use_dollor.FormShow(Sender: TObject);
//初始化窗口
begin
   Edit1Change(nil);
   listview1.Clear ;
end;

procedure Tform_use_dollor.SpeedButton2Click(Sender: TObject);
//通过客户列表选择客户
begin
   //显示客户列表以供选择
   form_use_select.ShowModal ;
   //是否作出选择
   if form_use_select.yesno =true then
   begin
      //显示该用户
      edit1.Text :=form_use_select.usercode ;
      Edit1Change(nil);
   end;
end;

procedure Tform_use_dollor.BitBtn1Click(Sender: TObject);
//为用户增加消费项目
var
   ListItem: TListItem;
   p:^mytype;
begin
   //显示服务项目列表以供选择
   form_fw_select.ShowModal ;
   //是否作出选择
   if form_fw_select.yesno = true  then
   begin
      //添加到消费列表
      listitem:=listview1.Items.Add ;
      listitem.Caption :=form_fw_select.fwname ;
      listitem.ImageIndex :=0;
      listitem.SubItems.Add(format( '%8.2f¥',[form_fw_select.fwmoney]));
      listitem.SubItems.Add(inttostr(form_fw_select.fwcount));
      listitem.SubItems.Add(format( '%8.2f¥',[form_fw_select.fwcount * form_fw_select.fwmoney]));
      new(p);
      p^.id :=form_fw_select.fwid ;
      p^.nname :=form_fw_select.fwname ;
      p^.count:=form_fw_select.fwcount ;
      p^.dollor :=form_fw_select.fwmoney ;
      p^.alldollor  :=p^.dollor * p^.count ;
      listitem.Data :=p;
   end;
end;

procedure Tform_use_dollor.BitBtn2Click(Sender: TObject);
//删除用户的消费项目
var
   temp:pchar;
   p:^mytype;
begin
   //是否选中消费项目列表中的某个项目
   if listview1.Selected= nil then exit ;
   temp:=pchar('您是否确定要删除['+listview1.Selected.caption +  ']');
   p:=listview1.Selected.Data;
   //确认删除
   if messagebox(self.Handle, temp,
                  '警告',MB_yesno or MB_ICONQUESTION	)=IDyes then
   begin
      //删除消费项目
      Dispose(p);
      listview1.Selected.Delete ;
   end;
end;

procedure Tform_use_dollor.button_addClick(Sender: TObject);
//修改用户的消费价格
var
   p:^mytype;
begin
   //是否选中消费项目列表中的某个项目
   if listview1.selected=nil then exit;
   //初始化修改消费窗口
   p:=listview1.Selected.Data;
   form_userfw_edit.my.id:=p^.id;
   form_userfw_edit.my.nname :=p^.nname ;
   form_userfw_edit.my.alldollor :=p^.alldollor ;
   form_userfw_edit.my.count :=p^.count ;
   form_userfw_edit.my.dollor :=p^.dollor ;
   //显示修改消费窗口
   form_userfw_edit.ShowModal;
   //是否作出修改
   if form_userfw_edit.yesno =false then exit;
   //修改对应的消费项
   p^.count :=form_userfw_edit.my.count ;
   p^.alldollor :=form_userfw_edit.my.alldollor ;
   listview1.Selected.SubItems.Clear;
   listview1.Selected.SubItems.Add(format( '%8.2f¥',[p^.dollor]));
   listview1.Selected.SubItems.add(inttostr(p^.count ));
   listview1.Selected.subitems.Add(format('%8.2f¥',[p^.alldollor]));

end;

procedure Tform_use_dollor.BitBtn4Click(Sender: TObject);
//将消费项目作为客户的记录添加进数据库
var
   i:integer;
   p:^mytype;
begin
   //检验各项数据是否足够
   if (cid<>0) and (listview1.Items.Count <>0) then
   begin
      //将消费项目添加进数据库
      recordset_temp.SQL.Clear ;
      recordset_temp.SQL.Add('select * from [JY]');
      recordset_temp.Open ;
      for i :=1 to listview1.Items.Count do
      begin
         p:=listview1.Items[i-1].Data;
         recordset_temp.Insert;
         recordset_temp.Fields[1].AsInteger :=cid;
         recordset_temp.Fields[2].AsInteger :=p^.id;
         recordset_temp.Fields[3].AsFloat :=p^.dollor ;
         recordset_temp.Fields[4].AsInteger :=p^.count ;
         recordset_temp.Fields[5].AsFloat :=p^.alldollor;
         recordset_temp.Fields[6].AsString  := datetostr(DateTimePicker1.date);
         //执行添加指令
         recordset_temp.Post;
      end;
      showmessage('登记完成');
      close;
   end
   else
   begin
      //提示出错
      showmessage('你有信息没有填写完');
   end;
end;

procedure Tform_use_dollor.SpeedButton1Click(Sender: TObject);
//察看该用户的消费纪录
begin
   if cid<>0 then
   begin
      form_dollor_list.cid:=cid;
      //显示消费记录查询窗口
      form_dollor_list.ShowModal ;
   end;
end;

end.

⌨️ 快捷键说明

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