private void gridViewGiaLoaiPhong_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.RowHandle >= 0) { if (e.Column == colDeleteGiaLoaiPhong) { GiaLoaiPhong objGiaLoaiPhong = new GiaLoaiPhong(); objGiaLoaiPhong.IDGiaLoaiPhong = Convert.ToInt32(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, "IDGiaLoaiPhong")); if (Convert.ToBoolean(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, colDeleteGiaLoaiPhong)) == true) { //warnning if (MessageBox.Show(this, "Bạn có muốn xóa Giá loại phòng này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (new DataAccess().deleteGiaLoaiPhong(objGiaLoaiPhong) == true) { ((frmMain)(this.MdiParent)).setStatus("Xóa Loại phòng thành công"); gridViewGiaLoaiPhong.DeleteRow(e.RowHandle); } else { MessageBox.Show(this, "Xóa Giá loại phòng không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); ((frmMain)(this.MdiParent)).setStatus(""); } } else { //set the image to uncheck gridViewGiaLoaiPhong.SetRowCellValue(e.RowHandle, colDeleteGiaLoaiPhong, true); } } } } }
private void gridViewGiaLoaiPhong_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { DataRowView aRowView = (DataRowView)(e.Row); DataRow aRow = aRowView.Row; if (aRow.RowState == DataRowState.Added) { //insert command here GiaLoaiPhong objGiaLoaiPhong = new GiaLoaiPhong(); try { objGiaLoaiPhong.Gia = Convert.ToDecimal(aRow["Gia"]); if (objGiaLoaiPhong.Gia < 0) { MessageBox.Show(this, "Giá loại phòng không hợp lệ", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; return; } // check exist khung gio if (new DataAccess().IsGiaLoaiPhongKhungGioExisted(Convert.ToInt16(aRow["IDKhunggio"]), curIDLoaiPhong)) { MessageBox.Show(this, "Khung giờ đã có. Hãy chỉnh sửa thông tin của khung giờ muốn sửa đổi ở bên dưới.", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; return; } } catch { MessageBox.Show(this, "Giá loại phòng không hợp lệ", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; return; } try { objGiaLoaiPhong.IDLoaiPhong = curIDLoaiPhong; //objGiaLoaiPhong.IDKhunggio = new DataAccess().getIDKhunggiofromTenKhunggio(Convert.ToString(aRow["IDKhunggio"])); objGiaLoaiPhong.IDKhunggio = Convert.ToInt32(aRow["IDKhunggio"]); objGiaLoaiPhong.Ngay = Convert.ToDateTime(aRow["Ngay"]); } catch { gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; return; } if (new DataAccess().insertGiaLoaiPhong(objGiaLoaiPhong) >= 0) { gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; ((frmMain)(this.MdiParent)).setStatus("Thêm mới Giá loại phòng thành công"); } else { gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; MessageBox.Show(this, "Thêm mới Giá loại phòng không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void gridViewGiaLoaiPhong_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.RowHandle >= 0) { if (e.Column == colDeleteGiaLoaiPhong) { //do nothing } else { //update here GiaLoaiPhong objGiaLoaiPhong = new GiaLoaiPhong(); objGiaLoaiPhong.IDGiaLoaiPhong = Convert.ToInt32(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, "IDGiaLoaiPhong")); objGiaLoaiPhong.Gia = Convert.ToDecimal(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, "Gia")); if (Convert.ToString(objGiaLoaiPhong.Gia) == "") { MessageBox.Show(this, "Giá loại phòng không hợp lệ", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; return; } else if (objGiaLoaiPhong.Gia < 0) { MessageBox.Show(this, "Giá loại phòng không hợp lệ", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; return; } objGiaLoaiPhong.Ngay = Convert.ToDateTime(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, "Ngay")); // objGiaLoaiPhong.IDKhunggio = new DataAccess().getIDKhunggiofromTenKhunggio(Convert.ToString(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, "IDKhunggio"))); objGiaLoaiPhong.IDKhunggio = Convert.ToInt32(gridViewGiaLoaiPhong.GetRowCellValue(e.RowHandle, "IDKhunggio")); objGiaLoaiPhong.IDLoaiPhong = curIDLoaiPhong; if (new DataAccess().updateGiaLoaiPhong(objGiaLoaiPhong) == true) { gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; ((frmMain)(this.MdiParent)).setStatus("Cập nhật dữ liệu Loai phòng thành công"); } else { gridControlGiaLoaiPhong.DataSource = new DataAccess().getGiaLoaiPhongByIDLoaiPhong(curIDLoaiPhong).Tables[0]; MessageBox.Show(this, "Cập nhật dữ liệu Loai phòng không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public bool deleteGiaLoaiPhong(GiaLoaiPhong objGiaLoaiPhong) { return(new GiaLoaiPhongService().deleteGiaLoaiPhong(objGiaLoaiPhong)); }
public bool updateGiaLoaiPhong(GiaLoaiPhong objGiaLoaiPhong) { return(new GiaLoaiPhongService().updateGiaLoaiPhong(objGiaLoaiPhong)); }
public int insertGiaLoaiPhong(GiaLoaiPhong objGiaLoaiPhong) { return(new GiaLoaiPhongService().insertGiaLoaiPhong(objGiaLoaiPhong)); }