예제 #1
1
 public bool DeleteRoleRightsByRoleId(Role roles, Database db, DbTransaction transaction)
 {
     DbCommand dbCommand = db.GetStoredProcCommand("usp_RoleRightDelete");
     db.AddInParameter(dbCommand, "RoleId", DbType.Guid, roles.RoleId);
     db.ExecuteNonQuery(dbCommand, transaction);
     return true;
 }
예제 #2
1
        public bool InsertRoleRights(Role roles, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_RoleRightInsert");

            db.AddInParameter(command, "@RoleId", DbType.Guid, roles.RoleId);
            db.AddInParameter(command, "@RightId", DbType.Int32, roles.RightId);
            db.AddInParameter(command, "@CreatedBy", DbType.Guid, roles.CreatedBy);

            db.ExecuteNonQuery(command, transaction);

            return true;
        }
예제 #3
1
        public bool Insert(Role roles, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_RoleInsert");

            roles.RoleId = Guid.NewGuid();
            db.AddInParameter(command, "@RoleName", DbType.String, roles.RoleName);
            db.AddInParameter(command, "@RoleDescription", DbType.String, roles.RoleDescription);
            db.AddInParameter(command, "@CreatedBy", DbType.Guid, roles.CreatedBy);
            db.AddInParameter(command, "@RoleId", DbType.Guid, roles.RoleId);

            db.ExecuteNonQuery(command, transaction);

            return true;
        }
예제 #4
0
        public bool Delete(Role roles)
        {
            Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
            DbCommand command = db.GetStoredProcCommand("usp_RoleDelete");
            db.AddInParameter(command, "@RoleId", DbType.String, roles.RoleId);
            db.AddInParameter(command, "@UpdatedBy", DbType.Guid, roles.UpdatedBy);

            return true;
        }
예제 #5
0
        protected void gvRoles_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            int i = gvRoles.FindVisibleIndexByKeyValue(e.Keys[gvRoles.KeyFieldName]);
            e.Cancel = true;

            Role roles = new Role();

            roles.RoleId = new Guid(e.Keys[gvRoles.KeyFieldName].ToString());

            if (roles.Delete())
            {
                this.LoadRoles();
            }
        }
예제 #6
0
        protected void DisplayData()
        {
            try
            {

                Guid currentRoleId = new Guid(this.hdnRoleId.Value);
                Role RolesObj = new Role();
                RolesObj.RoleId = currentRoleId;
                RolesObj = RolesObj.Select();
                this.txtRoleName.Text = RolesObj.RoleName;
                this.txtRoleDescription.Text = RolesObj.RoleDescription;

                Right RightsObj = new Right();
                RightsObj.RoleId = RolesObj.RoleId.Value;
                gvRights.DataSource = RightsObj.SelectByRolesId();
                gvRights.DataBind();

            }
            catch (System.Exception)
            {

            }
        }
예제 #7
0
        public bool Update(Role roles, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_RoleUpdate");

            db.AddInParameter(command, "@RoleId", DbType.Guid, roles.RoleId);
            db.AddInParameter(command, "@RoleName", DbType.String, roles.RoleName);
            db.AddInParameter(command, "@RoleDescription", DbType.String, roles.RoleDescription);
            db.AddInParameter(command, "@UpdatedBy", DbType.Guid, roles.UpdatedBy);

            db.ExecuteNonQuery(command);

            return true;
        }
예제 #8
0
 public DataSet SelectAll(Role roles)
 {
     Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
     DbCommand dbCommand = db.GetStoredProcCommand("usp_RoleSelectAll");
     return db.ExecuteDataSet(dbCommand);
 }
예제 #9
0
        protected bool UpdateData()
        {
            bool result = false;

            DbConnection connection = null;
            DbTransaction transaction = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
                connection = db.CreateConnection();
                connection.Open();
                transaction = connection.BeginTransaction();

                Role RolesObj = new Role();
                RolesObj.RoleId = new Guid(this.hdnRoleId.Value);
                RolesObj.RoleName = txtRoleName.Text.Trim();
                RolesObj.RoleDescription = txtRoleDescription.Text.Trim();
                RolesObj.UpdatedBy = Master.LoggedUser.UserId.Value;

                if (RolesObj.Save(db, transaction))
                {

                    //Delete exiting role rights
                    RolesObj.DeleteByRoleId(db, transaction);

                    List<object> myList = gvRights.GetSelectedFieldValues("RightId");

                    if (myList.Count > 0)
                    {
                        for (int i = 0; i <= myList.Count - 1; i++)
                        {
                            RolesObj.RightId = Convert.ToInt32(myList[i].ToString());
                            RolesObj.SaveRoleRights(db, transaction);
                        }
                    }
                }

                transaction.Commit();
                result = true;

                this.DisplayData();

                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);

            }
            catch (System.Exception)
            {

            }

            return result;
        }
예제 #10
0
        protected bool SaveData()
        {
            bool result = false;

            DbConnection connection = null;
            DbTransaction transaction = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
                connection = db.CreateConnection();
                connection.Open();
                transaction = connection.BeginTransaction();

                Role RolesObj = new Role();

                RolesObj.RoleName = txtRoleName.Text.Trim();

                if (!RolesObj.IsDuplicateRoleName(RolesObj.RoleName))
                {

                    RolesObj.RoleDescription = txtRoleDescription.Text.Trim();
                    RolesObj.CreatedBy = Master.LoggedUser.UserId.Value;
                    RolesObj.UpdatedBy = Master.LoggedUser.UserId.Value;

                    if (RolesObj.Save(db, transaction))
                    {
                        List<object> myList = gvRights.GetSelectedFieldValues("RightId");

                        if (myList.Count > 0)
                        {
                            for (int i = 0; i <= myList.Count - 1; i++)
                            {
                                RolesObj.RightId = Convert.ToInt32(myList[i].ToString());
                                RolesObj.SaveRoleRights(db, transaction);
                            }
                        }
                        else
                        {
                            System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Select_Role + "')", true);
                            transaction.Rollback();

                        }
                    }

                    transaction.Commit();
                    result = true;
                    hdnRoleId.Value = RolesObj.RoleId.HasValue ? RolesObj.RoleId.Value.ToString() : string.Empty;
                    this.DisplayData();

                    System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);
                }
                else
                {
                    System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Rolename + "')", true);

                }

            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }

            return result;
        }
예제 #11
0
 private void LoadRoles()
 {
     Role roles = new Role();
     gvRoles.DataSource = roles.SelectAllDataset();
     gvRoles.DataBind();
 }