private void btnSave_Click(object sender, EventArgs e) { if (!checkData()) { return; } else { String roomTypeName = Utils.standardNamePerson(txtRoomTypeName.Text); roomTypeObject = new DTORoomType("LP0000000", roomTypeName); if (roomTypeBUS.InsertRoomType(roomTypeObject)) { XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1); btnAdd.Enabled = true; btnCancelAdd.Enabled = false; btnCancelAdd.Visible = false; btnSave.Enabled = false; } else { XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4); } } }
/// <summary> /// Phương thức cập nhật một RoomType xuống csdl theo id /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateRoomType(DTORoomType RoomType) { try { return(roomTypeDAO.UpdateRoomType(RoomType)); } catch (SqlException) { throw; } }
/// <summary> /// Phương thức thêm mới một RoomType vào csdl /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool InsertRoomType(DTORoomType RoomType) { try { return(roomTypeDAO.InsertRoomType(RoomType)); } catch (SqlException) { throw; } }
/// <summary> /// Phương thức cập nhật một RoomType xuống csdl theo id /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateRoomType(DTORoomType RoomType) { try { DataExecute.Instance.createSqlCmd("sp_EditRoomTypeUpdate" /*Truyen vao storeprocedure*/, new object[3] { RoomType.RoomTypeID, RoomType.RoomTypeName, RoomType.Price }); return(DataExecute.Instance.updateData(DataConnection.Instance.m_cmd) > 0); } catch (SqlException) { throw; } }
private void SaveDataToDatabase() { if (!checkData()) { return; } try { if (m_IsAdd) { String roomTypeName = Utils.standardNamePerson(txtRoomTypeName.Text); decimal roomTypePrices = Math.Round(spPrices.Value); roomTypeObject = new DTORoomType("LP00000000", roomTypeName, roomTypePrices); if (roomTypeBUS.InsertRoomType(roomTypeObject)) { XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1); } else { XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4); } } else { String roomTypeName = Utils.standardNamePerson(txtRoomTypeName.Text); decimal roomTypePrices = Math.Round(spPrices.Value); roomTypeObject = new DTORoomType(txtRoomTypeId.Text, roomTypeName, roomTypePrices); if (roomTypeBUS.UpdateRoomType(roomTypeObject)) { XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1); } else { XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4); } } } catch (System.Exception ex) { XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3); } finally { updateEnableButtonAndResetValueOfControl(ref btnSave); } }
private void btnDelete_Click(object sender, EventArgs e) { if (roomTypeMulitiSelect.Selection.Count == 0) { XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Thông báo", true, 1); return; } try { System.Collections.ArrayList _listroomTypeObjectInDelibility = new System.Collections.ArrayList(); foreach (object _rowObjectItem in roomTypeMulitiSelect.Selection) { grdvListRoomType.FocusedRowHandle -= 1; DataRowView _rowObjectDetail = _rowObjectItem as DataRowView; roomTypeObject = new DTORoomType(_rowObjectDetail.Row["RoomTypeID"].ToString(), _rowObjectDetail.Row["RoomTypeName"].ToString()); if (!roomTypeBUS.DeleteRoomType(roomTypeObject.RoomTypeID)) { _listroomTypeObjectInDelibility.Add(_rowObjectDetail.Row["RoomTypeID"]); } } String _erroContent = "Không thể xóa thông tin các thế loại sách có mã số: \n"; if (_listroomTypeObjectInDelibility.Count != 0) { foreach (var item in _listroomTypeObjectInDelibility) { _erroContent += item.ToString() + "\n"; } XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4); } else { XtraCustomMessageBox.Show("Xóa dữ liệu thành công", "Thông báo", true, 1); } } catch (System.Exception) { XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4); } finally { updateEnableButtonAndResetValueOfControl(ref btnDelete); } }
private void btnDelete_Click(object sender, EventArgs e) { if (roomTypeMulitiSelect.Selection.Count == 0) { XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Thông báo", true, 1); return; } try { System.Collections.ArrayList _listroomTypeObjectInDelibility = new System.Collections.ArrayList(); foreach (object _rowObjectItem in roomTypeMulitiSelect.Selection) { grdvListRoomType.FocusedRowHandle -= 1; DataRowView _rowObjectDetail = _rowObjectItem as DataRowView; roomTypeObject = new DTORoomType(_rowObjectDetail.Row["RoomTypeID"].ToString(), _rowObjectDetail.Row["RoomTypeName"].ToString()); if (!roomTypeBUS.DeleteRoomType(roomTypeObject.RoomTypeID)) { _listroomTypeObjectInDelibility.Add(_rowObjectDetail.Row["RoomTypeID"]); } } String _erroContent = "Không thể xóa thông tin các thế loại sách có mã số: \n"; if (_listroomTypeObjectInDelibility.Count != 0) { foreach (var item in _listroomTypeObjectInDelibility) { _erroContent += item.ToString() + "\n"; } XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4); } else XtraCustomMessageBox.Show("Xóa dữ liệu thành công", "Thông báo", true, 1); } catch (System.Exception) { XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4); } finally { updateEnableButtonAndResetValueOfControl(ref btnDelete); } }
/// <summary> /// Phương thức thêm mới một RoomType vào csdl /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool InsertRoomType(DTORoomType RoomType) { try { return roomTypeDAO.InsertRoomType(RoomType); } catch (SqlException) { throw; } }
/// <summary> /// Phương thức cập nhật một RoomType xuống csdl theo id /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateRoomType(DTORoomType RoomType) { try { return roomTypeDAO.UpdateRoomType(RoomType); } catch (SqlException) { throw; } }