/// <summary> /// 窗体载入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GuestManageForm_Load(object sender, EventArgs e) { this.pnlContent.Visible = false;//隐藏编辑区 this.dgvGuest.AutoGenerateColumns = false; if (string.IsNullOrEmpty(this.txtGuestName.Text.Trim())) { this.dgvGuest.DataSource = GuestManager.GetAllGuests(); } else { this.dgvGuest.DataSource = GuestManager.GetGuestByGuestName(this.txtGuestName.Text.Trim()); } }
/// <summary> /// 保存功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 保存ToolStripMenuItem_Click(object sender, EventArgs e) { Guest guest = new Guest(); guest.Name = this.txtName.Text.Trim(); guest.LeaveTime = Convert.ToDateTime(this.txtLeaveTime.Text); guest.ArriveTime = Convert.ToDateTime(this.txtArriveTime.Text); guest.CategoryId = 1; guest.Mobile = this.txtPhone.Text.Trim(); guest.Sex = this.txtSex.Text.Trim(); guest.RoomId = Convert.ToInt32(this.txtRoomID.Text.Trim()); GuestManager.AddGuest(guest); MessageBox.Show("保存成功"); this.dgvGuest.DataSource = GuestManager.GetAllGuests(); }
/// <summary> /// 删除功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { if (id == 0) { MessageBox.Show("没有删除的信息"); return; } else { DialogResult result = MessageBox.Show("确认要删除该信息吗?", "消息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.OK) { GuestManager.DeleteGuestById(id); MessageBox.Show("删除成功"); this.dgvGuest.DataSource = GuestManager.GetAllGuests(); } } }