Exemple #1
0
        private void gridViewNhomSP_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteNhomSP)
                {
                    ////delete here
                    NhomSP objNhomSP = new NhomSP();
                    objNhomSP.IDNhomSP = Convert.ToInt32(gridViewNhomSP.GetRowCellValue(e.RowHandle, "IDNhomSP"));

                    if (Convert.ToBoolean(gridViewNhomSP.GetRowCellValue(e.RowHandle, colDeleteNhomSP)) == true)
                    {
                        //warnning
                        if (MessageBox.Show(this, "Bạn có muốn xóa Nhóm sản phẩm này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            if (new DataAccess().deleteNhomSP(objNhomSP) == true)
                            {
                                ((frmMain)(this.MdiParent)).setStatus("Xóa Nhóm sản phẩm thành công");
                                gridViewNhomSP.DeleteRow(e.RowHandle);
                                NhomSPRowsCount--;
                            }
                            else
                            {
                                MessageBox.Show(this, "Xóa Nhóm sản phẩm không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            //set the image to uncheck
                            gridViewNhomSP.SetRowCellValue(e.RowHandle, colDeleteNhomSP, true);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void gridViewNhomSP_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
                NhomSP objNhomSP = new NhomSP();
                objNhomSP.TenNhomSP = Convert.ToString(aRow["TenNhomSP"]);
                objNhomSP.Ghichu    = Convert.ToString(aRow["Ghichu"]);

                if (NhomSPValidation(objNhomSP) == true)
                {
                    if (new DataAccess().insertNhomSP(objNhomSP) >= 0)
                    {
                        getAllNhomSP();
                        ((frmMain)(this.MdiParent)).setStatus("Thêm mới Nhóm sản phẩm thành công");
                    }
                    else
                    {
                        getAllNhomSP();
                        MessageBox.Show(this, "Thêm mới Nhóm sản phẩm không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    getAllNhomSP();
                    MessageBox.Show(this, "Chưa có dữ liệu cho Tên nhóm sản phẩm!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #3
0
 private bool NhomSPValidation(NhomSP objNhomSP)
 {
     if (objNhomSP.TenNhomSP != "")
     {
         return(true);
     }
     return(false);
 }
Exemple #4
0
        public void themLoaiSanPham(string tenloai)
        {
            NhomSP nhom = new NhomSP();

            nhom.TenNhomSP = tenloai;
            qlmypham.NhomSPs.InsertOnSubmit(nhom);
            qlmypham.SubmitChanges();
        }
        public ActionResult XLThemNhom(FormCollection c)
        {
            List <NhomSP> lst = db.NhomSPs.ToList();

            NhomSP newnhom = new NhomSP();

            newnhom.idNhom  = (lst.Count() + 1).ToString();
            newnhom.tenNhom = c["txtTen"];
            db.NhomSPs.InsertOnSubmit(newnhom);
            db.SubmitChanges();
            return(RedirectToAction("QuanLyNhom", "Admin"));
        }
        public ActionResult XoaNhom(string ma)
        {
            List <Loai> loai = db.Loais.Where(t => t.idNhom == ma).ToList();

            foreach (var item in loai)
            {
                List <SanPham> sanpham = db.SanPhams.Where(t => t.idLoai == item.idLoai).ToList();
                foreach (var i in sanpham)
                {
                    db.SanPhams.DeleteOnSubmit(i);
                }
                db.Loais.DeleteOnSubmit(item);
            }

            NhomSP nhom = db.NhomSPs.FirstOrDefault(t => t.idNhom == ma);

            db.NhomSPs.DeleteOnSubmit(nhom);
            db.SubmitChanges();
            return(RedirectToAction("QuanLyNhom"));
        }
Exemple #7
0
 public bool deleteNhomSP(NhomSP objNhomSP)
 {
     return(new NhomSPService().deleteNhomSP(objNhomSP));
 }
Exemple #8
0
 public bool updateNhomSP(NhomSP objNhomSP)
 {
     return(new NhomSPService().updateNhomSP(objNhomSP));
 }
Exemple #9
0
 public int insertNhomSP(NhomSP objNhomSP)
 {
     return(new NhomSPService().insertNhomSP(objNhomSP));
 }