/// <summary> /// 添加包厢 /// </summary> public void AddRoom() { Room room = new Room(); room.R_RoomId1 = Convert.ToInt32(this.txtRoomId.Text.Trim()); room.R_RoomState1 = 0; room.R_RoomType1 = this.cmbRoomType.Text.Trim(); bool result = roommanage.AddRoom(room); if (result) { MessageBox.Show("新增成功", "新增", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtRoomId.Text = ""; this.cmbRoomType.Text = ""; AddRomeBtn(); this.pnlAddRoom.Visible = false; return; } MessageBox.Show("新增失败", "新增", MessageBoxButtons.OK, MessageBoxIcon.Error); }
private void btnSave_Click(object sender, EventArgs e) { if (txtRoomNumberDown.Text.Trim() == "") { MessageBox.Show("请输入房间号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (cboTypeName.SelectedIndex == -1) { MessageBox.Show("请选择房型!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtGuestNumber.Text.Trim() == "") { MessageBox.Show("请输入入住人数!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtBedNumber.Text.Trim() == "") { MessageBox.Show("请输入床位数!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (cboState.SelectedIndex == -1) { MessageBox.Show("请选择状态!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtDescription.Text.Trim() == "") { MessageBox.Show("请输入描述内容!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string message = string.Empty; Room room = new Room(); for (int i = 0; i < txtRoomNumberDown.Text.Length; i++) { if (char.IsDigit(txtRoomNumberDown.Text[i]) == false) { MessageBox.Show("房间号输入不合法!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } room.Number = txtRoomNumberDown.Text.Trim(); try { room.BedNumber = Convert.ToInt32(txtBedNumber.Text.Trim()); room.GuestNumber = Convert.ToInt32(txtGuestNumber.Text.Trim()); } catch { MessageBox.Show("请输入数字!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } room.State = cboState.Text; room.Description = txtDescription.Text.Trim(); room.TypeID = rm.GetTypeIDByTypeName(cboTypeName.Text); room.RoomID = thisRoomID; string strAlert; if (thisRoomID > 0) { strAlert = "确定更新该项?"; } else { strAlert = "确定新增该项?"; } if (MessageBox.Show(strAlert, "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (thisRoomID > 0) { message = rm.UpdateRoom(room); } else { message = rm.AddRoom(room); } MessageBox.Show(message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); this.Dispose(); } }