Exemple #1
0
        public bool deleteNhomSP(BKIT.Entities.NhomSP objNhomSP)
        {
            Database  db         = DatabaseFactory.CreateDatabase();
            string    sqlCommand = "DELETE FROM NhomSP WHERE IDNhomSP = @idnhomsp";
            DbCommand dbCommand  = db.GetSqlStringCommand(sqlCommand);

            try
            {
                db.AddInParameter(dbCommand, "idnhomsp", DbType.Int32, objNhomSP.IDNhomSP);
                db.ExecuteNonQuery(dbCommand);
                dbCommand.Connection.Close();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #2
0
        public bool updateNhomSP(BKIT.Entities.NhomSP objNhomSP)
        {
            Database db         = DatabaseFactory.CreateDatabase();
            string   sqlCommand = "UPDATE NhomSP SET TenNhomSP = @tennhomsp, Ghichu = @ghichu " +
                                  "WHERE IDNhomSP = @idnhomsp";
            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            try
            {
                db.AddInParameter(dbCommand, "tennhomsp", DbType.String, objNhomSP.TenNhomSP);
                db.AddInParameter(dbCommand, "ghichu", DbType.String, objNhomSP.Ghichu);
                db.AddInParameter(dbCommand, "idnhomsp", DbType.Int32, objNhomSP.IDNhomSP);
                db.ExecuteNonQuery(dbCommand);
                dbCommand.Connection.Close();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #3
0
        public int insertNhomSP(BKIT.Entities.NhomSP objNhomSP)
        {
            Database db         = DatabaseFactory.CreateDatabase();
            string   sqlCommand = "INSERT INTO NhomSP(IDNhomSP,TenNhomSP,Ghichu) " +
                                  "VALUES (@idnhomsp,@tennhomsp,@ghichu)";
            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            try
            {
                int ID = GetNextAVailableID();
                objNhomSP.IDNhomSP = ID;
                db.AddInParameter(dbCommand, "idnhomsp", DbType.Int32, objNhomSP.IDNhomSP);
                db.AddInParameter(dbCommand, "tennhomsp", DbType.String, objNhomSP.TenNhomSP);
                db.AddInParameter(dbCommand, "ghichu", DbType.String, objNhomSP.Ghichu);
                db.ExecuteNonQuery(dbCommand);
                dbCommand.Connection.Close();
                return(ID);
            }
            catch
            {
                dbCommand.Connection.Close();
                return(-1);
            }
        }
Exemple #4
0
 private bool NhomSPValidation(NhomSP objNhomSP)
 {
     if (objNhomSP.TenNhomSP != "")
     {
         return true;
     }
     return false;
 }
Exemple #5
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 #6
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 #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);
 }