示例#1
0
 /// <summary>
 /// 检查输入是否合法
 /// </summary>
 /// <returns></returns>
 public bool CheckIsNull()
 {
     if (this.txtIdentityID.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入身份证号!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtIdentityID.Focus();
         return(false);
     }
     if (this.txtGuestName.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入顾客姓名!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtGuestName.Focus();
         return(false);
     }
     if (this.txtDeposit.Text.Trim().Length == 0)
     {
         MessageBox.Show("请输入押金数额!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtDeposit.Focus();
         return(false);
     }
     if (Convert.ToInt32(this.cboRooms.SelectedValue) <= 0)
     {
         this.cboRooms.DroppedDown = true;//使下拉框展开
         return(false);
     }
     if (this.txtIdentityID.Text.Trim().Length != 18)
     {
         MessageBox.Show("身份证号必须为18位!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtIdentityID.Focus();
         return(false);
     }
     if (!CheckNum.CheckStringIsNum(this.txtDeposit.Text.Trim()))
     {
         MessageBox.Show("您的输入有误,押金必须为数字类型!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtDeposit.Clear();
         this.txtDeposit.Focus();
         return(false);
     }
     if (!CheckNum.CheckIdCard(this.txtIdentityID.Text.Trim()))
     {
         MessageBox.Show("请输入合法的身份证号!必须是数字类型或者以“X”结尾", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtIdentityID.Focus();
         return(false);
     }
     if (Convert.ToDecimal(this.txtDeposit.Text.Trim()) <= 50)
     {
         MessageBox.Show("押金必须大于50元!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtDeposit.Focus();
         return(false);
     }
     return(true);
 }
示例#2
0
 //输入页码,跳到相应页面
 private void txtPage_TextChanged(object sender, EventArgs e)
 {
     if (this.txtPage.Text.Trim().Length == 0)
     {
         return;
     }
     if (!CheckNum.CheckStringIsNum(this.txtPage.Text.Trim()) || this.txtPage.Text.Contains("."))
     {
         MessageBox.Show("您的输入有误!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtPage.Clear();
         return;
     }
     if (Convert.ToInt32(this.txtPage.Text.Trim()) > this.MaxPages)
     {
         return;
     }
     if (Convert.ToInt32(this.txtPage.Text.Trim()) <= 0)
     {
         return;
     }
     this.Pages = Convert.ToInt32(this.txtPage.Text.Trim());
     SeachGuests();
 }
示例#3
0
 //保存
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     if (this.txtTypeName.Text.Trim().Length == 0)
     {
         MessageBox.Show("房间类型名称不能为空!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtTypeName.Focus();
         return;
     }
     if (this.txtTypePrice.Text.Trim().Length == 0)
     {
         MessageBox.Show("房间价格不能为空!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtTypePrice.Focus();
         return;
     }
     if (!CheckNum.CheckStringIsNum(this.txtTypePrice.Text.Trim()))
     {
         MessageBox.Show("您的输入有误,房间价格必须为数字类型!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtTypePrice.Clear();
         this.txtTypePrice.Focus();
         return;
     }
     if (Convert.ToDecimal(this.txtTypePrice.Text.Trim()) <= 0)
     {
         MessageBox.Show("房间价格必须大于0!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtTypePrice.Clear();
         this.txtTypePrice.Focus();
         return;
     }
     //根据新增或修改分开操作
     //修改
     if (this.FormType == "修改")
     {
         if (!Checkdgv())
         {
             return;
         }
         if (this.dgvRoomTypes.CurrentRow.DataBoundItem == null)
         {
             return;
         }
         int      typeId = (this.dgvRoomTypes.CurrentRow.DataBoundItem as RoomType).TypeID;
         RoomType rt     = new RoomType(
             typeId, this.txtTypeName.Text.Trim(), Convert.ToDecimal(this.txtTypePrice.Text.Trim())
             );
         try
         {
             RoomTypeBLL.UpdateRoomType(rt);
             ShowRoomTypes();
             ExeuceTextReanOnly();
             this.tsmiSave.Enabled = false;
             this.tsmiAdd.Enabled  = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show("修改房间类型出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     //新增
     else if (this.FormType == "新建")
     {
         RoomType rt = new RoomType(
             this.txtTypeName.Text.Trim(),
             Convert.ToDecimal(this.txtTypePrice.Text.Trim())
             );
         try
         {
             RoomTypeBLL.AddRoomType(rt);
             ShowRoomTypes();
             ExeuceTextReanOnly();
             this.tsmiSave.Enabled   = false;
             this.tsmiUpdate.Enabled = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show("新增房间类型出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
示例#4
0
 //保存
 private void tsmiSave_Click(object sender, EventArgs e)
 {
     if (this.txtRoomName.Text.Trim().Length == 0)
     {
         MessageBox.Show("房号不能为空!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtRoomName.Focus();
         return;
     }
     if (this.txtBedNum.Text.Trim().Length == 0)
     {
         MessageBox.Show("床位数不能为空!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtBedNum.Focus();
         return;
     }
     if (this.txtDescription.Text.Trim().Length == 0)
     {
         MessageBox.Show("房间描述不能为空!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtDescription.Focus();
         return;
     }
     if (!CheckNum.CheckStringIsNum(this.txtBedNum.Text.Trim()) || this.txtBedNum.Text.Contains("."))
     {
         MessageBox.Show("您的输入有误,床位数必须为数字类型,不能包含其他字符!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtBedNum.Clear();
         this.txtBedNum.Focus();
         return;
     }
     if (Convert.ToInt32(this.txtBedNum.Text.Trim()) <= 0)
     {
         MessageBox.Show("床位数必须大于0!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.txtBedNum.Clear();
         this.txtBedNum.Focus();
         return;
     }
     //根据新增或修改分开操作
     //修改
     if (this.FormType == "修改")
     {
         if (!Checkdgv())
         {
             return;
         }
         if (this.dgvRooms.CurrentRow.DataBoundItem == null)
         {
             return;
         }
         //判断是否有这个房间号
         try
         {
             if (this.txtRoomName.Text.Trim() != (this.dgvRooms.CurrentRow.DataBoundItem as Room).RoomName)
             {
                 if (RoomBLL.CheckRoomNameByEditRoom(this.txtRoomName.Text.Trim()))
                 {
                     MessageBox.Show("对不起,已经有这个房间号了!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.txtRoomName.Clear();
                     this.txtRoomName.Focus();
                     return;
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("判断是否有这个房间号出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         int  roomId = (this.dgvRooms.CurrentRow.DataBoundItem as Room).RoomId;
         Room room   = new Room(
             roomId,
             this.txtRoomName.Text.Trim(),
             Convert.ToInt32(this.txtBedNum.Text.Trim()),
             this.txtDescription.Text.Trim(),
             this.cboRoomType.SelectedItem as RoomType//下拉框当前房间类型对象
             );
         try
         {
             if (RoomBLL.UpdateRoom(room))
             {
                 ShowRoom();
                 ExeuceTextReanOnly();
                 this.tsmiSave.Enabled = false;
                 this.tsmiAdd.Enabled  = true;
             }
             else
             {
                 MessageBox.Show("您的操作有误,修改房间失败!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("修改房间出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     //新增
     else if (this.FormType == "新建")
     {
         if (RoomBLL.CheckRoomNameByEditRoom(this.txtRoomName.Text.Trim()))
         {
             MessageBox.Show("对不起,已经有这个房间号了!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.txtRoomName.Clear();
             this.txtRoomName.Focus();
             return;
         }
         Room room = new Room(
             0,
             this.txtRoomName.Text.Trim(),
             Convert.ToInt32(this.txtBedNum.Text.Trim()),
             this.txtDescription.Text.Trim(),
             this.cboRoomType.SelectedItem as RoomType//下拉框当前房间类型对象
             );
         try
         {
             if (RoomBLL.AddRoom(room))
             {
                 ShowRoom();
                 ExeuceTextReanOnly();
                 this.tsmiSave.Enabled   = false;
                 this.tsmiUpdate.Enabled = true;
             }
             else
             {
                 MessageBox.Show("您的操作有误,新增房间失败!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("新增房间出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }