コード例 #1
0
        /// <summary>
        /// 顾客入住
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!CheckIsNull())
            {
                return;
            }
            //创建顾客对象
            GuestInsert guest = new GuestInsert(
                this.txtIdentityID.Text.Trim(),
                this.txtGuestName.Text.Trim(),
                Convert.ToInt32(this.cboRooms.SelectedValue),
                this.dtpReside.Value,
                Convert.ToDecimal(this.txtDeposit.Text.Trim())
                );

            //登记
            try
            {
                if (GuestRecordBLL.AddGuest(guest))
                {
                    MessageBox.Show("登记成功!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Recovery();
                    this.txtIdentityID.Focus();
                }
                else
                {
                    MessageBox.Show("登记失败。", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("顾客登记出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        //退房(事件)
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (this.dgvRecordInfo.SelectedRows.Count < 1)
            {
                return;
            }
            GuestSeach guest = this.dgvRecordInfo.CurrentRow.DataBoundItem as GuestSeach;

            guest.TotalMoney = Convert.ToDecimal(this.txtAmount.Text);
            guest.LeaveDate  = DateTime.Now;
            try
            {
                //用存储过程退房
                //if (GuestRecordBLL.CheckOutRoomByPROC(guest))
                //{
                //    MessageBox.Show("退房成功!应退回押金" + guest.Deposit + "元", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    SeachGuests();
                // }
                //else
                //{
                //    MessageBox.Show("对不起,您的操作有误,退房失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}

                //用Sql语句退房
                if (GuestRecordBLL.CheckOutRoomBySql(guest))
                {
                    MessageBox.Show("退房成功!应退回押金" + guest.Deposit + "元", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SeachGuests();
                }
                else
                {
                    MessageBox.Show("对不起,您的操作有误,退房失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("退房出现异常,请联系管理员!\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        //获取尾页的方法
        public void GetMaxPages()
        {
            int      resideId   = Convert.ToInt32(this.cboResideState.SelectedValue);
            DateTime resideDate = this.dtpBeginTime.Value;
            DateTime leaveDate  = this.dtpEndTime.Value;

            //按时间段查
            if (this.cboxDate.Checked && resideId == -1)
            {
                try
                {
                    this.AllCounts = GuestRecordBLL.GetGuestCount(resideDate, leaveDate);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("按时间段查询客户表记录总数量出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //按状态查
            else if (!this.cboxDate.Checked && resideId != -1)
            {
                try
                {
                    this.AllCounts = GuestRecordBLL.GetGuestCount(null, null, resideId);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("按入住状态查询客户表记录总数量出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //按时间段和状态查
            else if (this.cboxDate.Checked && resideId != -1)
            {
                try
                {
                    this.AllCounts = GuestRecordBLL.GetGuestCount(resideDate, leaveDate, resideId);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("按时间段以及入住状态查询客户表记录总数量出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //查全部
            else if (!this.cboxDate.Checked && resideId == -1)
            {
                try
                {
                    this.AllCounts = GuestRecordBLL.GetGuestCount();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("查询全部客户表记录总数量出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //计算尾页
            this.MaxPages = this.AllCounts / 21;
            if (this.AllCounts % 21 != 0 || this.AllCounts == 0)
            {
                this.MaxPages++;
            }

            //分别要显示的标签
            if (this.AllCounts > 21)
            {
                this.lblShowManagers.Text = "共" + this.AllCounts + "条记录,每页21条,共" + this.MaxPages + "页";
            }
            else if (this.AllCounts <= 21 && this.AllCounts > 0)
            {
                this.lblShowManagers.Text = "共" + this.AllCounts + "条记录,共" + this.MaxPages + "页";
            }
            else
            {
                this.lblShowManagers.Text  = "没有符合条件的记录";
                this.btnConfirm.Enabled    = false;
                this.lblTotalMoney.Enabled = false;
            }
        }
コード例 #4
0
        //查询酒店入住信息
        public void SeachGuests()
        {
            this.dgvRecordInfo.AutoGenerateColumns = false;
            int      resideId   = Convert.ToInt32(this.cboResideState.SelectedValue);
            DateTime resideDate = this.dtpBeginTime.Value;
            DateTime leaveDate  = this.dtpEndTime.Value;

            //按时间段查
            if (this.cboxDate.Checked && resideId == -1)
            {
                try
                {
                    this.dgvRecordInfo.DataSource = new BindingList <GuestSeach>(GuestRecordBLL.GetGuests(this.Pages, resideDate, leaveDate));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("按时间段查询顾客信息出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //按状态查
            else if (!this.cboxDate.Checked && resideId != -1)
            {
                try
                {
                    this.dgvRecordInfo.DataSource = new BindingList <GuestSeach>(GuestRecordBLL.GetGuests(this.Pages, null, null, resideId));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("按入住状态查询顾客信息出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //按时间段和状态查
            else if (this.cboxDate.Checked && resideId != -1)
            {
                try
                {
                    this.dgvRecordInfo.DataSource = new BindingList <GuestSeach>(GuestRecordBLL.GetGuests(this.Pages, resideDate, leaveDate, resideId));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("按时间段以及入住状态查询顾客信息出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //查全部
            else if (!this.cboxDate.Checked && resideId == -1)
            {
                try
                {
                    this.dgvRecordInfo.DataSource = new BindingList <GuestSeach>(GuestRecordBLL.GetGuests(this.Pages));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("查询全部顾客信息出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            ShowTotalMoney();
            //刷新尾页及总行数
            GetMaxPages();

            if (this.dgvRecordInfo.RowCount < 1)
            {
                return;
            }
            //判断是否结账来显示不同的颜色
            foreach (DataGridViewRow row in this.dgvRecordInfo.Rows)
            {
                if (row.Cells["colResideState"].Value.ToString() == "未结账")
                {
                    row.DefaultCellStyle.ForeColor = Color.Red;//DataGridViewRow的字体风格、颜色
                }
                else
                {
                    row.DefaultCellStyle.ForeColor = Color.Blue;
                }
            }
        }