public IsDuplicateRoleName ( string roleName, int compnayId ) : bool | ||
roleName | string | |
compnayId | int | |
Résultat | bool |
protected bool SaveData() { bool result = false; DbConnection connection = null; DbTransaction transaction = null; try { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); connection = db.CreateConnection(); connection.Open(); transaction = connection.BeginTransaction(); UserMan.Roles RolesObj = new UserMan.Roles(); RolesObj.RoleName = txtRoleName.Text.Trim(); if (!RolesObj.IsDuplicateRoleName(RolesObj.RoleName, Master.CurrentCompany.CompanyId)) { RolesObj.RoleDescription = txtRoleDescription.Text.Trim(); RolesObj.CompanyId = Master.CurrentCompany.CompanyId; RolesObj.CreatedUser = Master.LoggedUser.UsersId; RolesObj.UpdatedUser = Master.LoggedUser.UsersId; 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; 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; }
protected bool SaveData() { bool result = false; DbConnection connection = null; DbTransaction transaction = null; try { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); connection = db.CreateConnection(); connection.Open(); transaction = connection.BeginTransaction(); UserMan.Roles RolesObj = new UserMan.Roles(); RolesObj.RoleName = txtRoleName.Text.Trim(); if (!RolesObj.IsDuplicateRoleName(RolesObj.RoleName, Master.CurrentCompany.CompanyId)) { RolesObj.RoleDescription = txtRoleDescription.Text.Trim(); RolesObj.CompanyId = Master.CurrentCompany.CompanyId; RolesObj.CreatedUser = Master.LoggedUser.UsersId; RolesObj.UpdatedUser = Master.LoggedUser.UsersId; 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; 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); }