示例#1
0
        private void gridViewLPSPBD_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
                LoaiphongSPBandau objLoaiPhong = new LoaiphongSPBandau();
                objLoaiPhong.IDLoaiPhong = curIDLoaiPhong;
                objLoaiPhong.Soluong = Convert.ToInt32(aRow["Soluong"]);
                objLoaiPhong.Ghichu = Convert.ToString(aRow["Ghichu"]);
                DataSet dsSP = new DataAccess().getSanPhamByTenSP(Convert.ToString(aRow["TenSanPham"]));
                    try{
                        objLoaiPhong.IDSanPham = Convert.ToInt32(dsSP.Tables[0].Rows[0]["IDSanPham"]);
                    }
                    catch{
                        objLoaiPhong.IDSanPham = -1;
                    }
                    if ((objLoaiPhong.IDSanPham == -1) || (objLoaiPhong.Soluong <= 0))
                    {
                        getSPBandau(curIDLoaiPhong);
                        MessageBox.Show(this, "Thông tin sản phẩm không hợp lệ (không có sản phẩm cùng tên hoặc số lượng <= 0)", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                if (new DataAccess().insertLoaiphongSPBandau(objLoaiPhong) >= 0)
                {
                    getSPBandau(curIDLoaiPhong);
                    ((frmMain)(this.MdiParent)).setStatus("Thêm mới Loại phòng thành công");

                }
                else
                {
                    getSPBandau(curIDLoaiPhong);
                    MessageBox.Show(this, "Thêm mới Loại phòng không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
        }
示例#2
0
        private void gridViewLPSPBD_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteSPBD)
                {
                    LoaiphongSPBandau objLoaiPhong = new LoaiphongSPBandau();
                    objLoaiPhong.IDLPSP = Convert.ToInt32(gridViewLPSPBD.GetRowCellValue(e.RowHandle, "IDLPSP"));

                    if (Convert.ToBoolean(gridViewLPSPBD.GetRowCellValue(e.RowHandle, colDeleteSPBD)) == true)
                    {
                        //warnning
                        if (MessageBox.Show(this, "Bạn có muốn xóa Sản phẩm ban đầu này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            if (new DataAccess().deleteLoaiphongSPBandau(objLoaiPhong) == true)
                            {
                                ((frmMain)(this.MdiParent)).setStatus("Xóa Sản phẩm ban đầu thành công");
                                gridViewLPSPBD.DeleteRow(e.RowHandle);
                            }
                            else
                            {
                                MessageBox.Show(this, "Xóa Sản phẩm ban đầu 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
                            gridViewLPSPBD.SetRowCellValue(e.RowHandle, colDeleteSPBD, true);
                        }
                    }
                }
            }
        }
示例#3
0
        private void gridViewLPSPBD_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteSPBD)
                {
                    //do nothing
                }
                else
                {
                    //update here
                    LoaiphongSPBandau objLoaiPhong = new LoaiphongSPBandau();
                    objLoaiPhong.IDLPSP = Convert.ToInt32(gridViewLPSPBD.GetRowCellValue(e.RowHandle, "IDLPSP"));
                    objLoaiPhong.IDLoaiPhong = Convert.ToInt32(gridViewLPSPBD.GetRowCellValue(e.RowHandle, "IDLoaiPhong"));
                    objLoaiPhong.Soluong = Convert.ToInt32(gridViewLPSPBD.GetRowCellValue(e.RowHandle, "Soluong"));
                    objLoaiPhong.Ghichu = Convert.ToString(gridViewLPSPBD.GetRowCellValue(e.RowHandle, "Ghichu"));
                    DataSet dsSP = new DataAccess().getSanPhamByTenSP(Convert.ToString(gridViewLPSPBD.GetRowCellValue(e.RowHandle, "TenSanPham")));
                    try{
                        objLoaiPhong.IDSanPham = Convert.ToInt32(dsSP.Tables[0].Rows[0]["IDSanPham"]);
                    }
                    catch{
                        objLoaiPhong.IDSanPham = -1;
                    }

                    if ((objLoaiPhong.IDSanPham == -1)||(objLoaiPhong.Soluong <=0))
                    {
                        getSPBandau(curIDLoaiPhong);
                        MessageBox.Show(this, "Thông tin sản phẩm không hợp lệ (không có sản phẩm cùng tên hoặc số lượng <= 0)", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (new DataAccess().updateLoaiphongSPBandau(objLoaiPhong) == true)
                    {

                        getSPBandau(curIDLoaiPhong);
                        ((frmMain)(this.MdiParent)).setStatus("Cập nhật dữ liệu Loai phòng thành công");
                    }
                    else
                    {
                        getSPBandau(curIDLoaiPhong);
                        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);
                    }
                }
            }
        }
示例#4
0
 public bool deleteLoaiphongSPBandau(LoaiphongSPBandau objLoaiphongSPBandau)
 {
     return new LoaiphongSPBandauService().deleteLoaiphongSPBandau(objLoaiphongSPBandau);
 }
示例#5
0
 public bool updateLoaiphongSPBandau(LoaiphongSPBandau objLoaiphongSPBandau)
 {
     return new LoaiphongSPBandauService().updateLoaiphongSPBandau(objLoaiphongSPBandau);
 }
示例#6
0
 public int insertLoaiphongSPBandau(LoaiphongSPBandau objLoaiphongSPBandau)
 {
     return new LoaiphongSPBandauService().insertLoaiphongSPBandau(objLoaiphongSPBandau);
 }