Save() public method

public Save ( Microsoft.Practices.EnterpriseLibrary.Data.Database db, DbTransaction transaction ) : bool
db Microsoft.Practices.EnterpriseLibrary.Data.Database
transaction System.Data.Common.DbTransaction
return bool
        protected bool UpdateData()
        {
            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.RolesId         = Convert.ToInt32(this.hdnRoleId.Value);
                RolesObj.RoleName        = txtRoleName.Text.Trim();
                RolesObj.RoleDescription = txtRoleDescription.Text.Trim();
                RolesObj.CompanyId       = Master.CurrentCompany.CompanyId;
                RolesObj.UpdatedUser     = Master.LoggedUser.UsersId;

                if (RolesObj.Save(db, transaction))
                {
                    //Delete exiting role rights
                    RolesObj.DeleteByRolesId(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);
        }
        protected bool UpdateData()
        {
            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.RolesId = Convert.ToInt32(this.hdnRoleId.Value);
                RolesObj.RoleName = txtRoleName.Text.Trim();
                RolesObj.RoleDescription = txtRoleDescription.Text.Trim();
                RolesObj.CompanyId = Master.CurrentCompany.CompanyId;
                RolesObj.UpdatedUser = Master.LoggedUser.UsersId;

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

                    //Delete exiting role rights
                    RolesObj.DeleteByRolesId(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;
        }