protected void Add_Click(object sender, EventArgs e)
        {
            var userStore = new UserStore <IdentityUser>();
            var manager   = new UserManager <IdentityUser>(userStore);

            string email = Email.Text;
            string pass  = RandomString(12);

            var user = new IdentityUser()
            {
                UserName = email, Email = email
            };

            IdentityResult result = manager.Create(user, pass);

            //send to email with new pass
            if (result.Succeeded)
            {
                string HtmlBody = GeneralFunctions.CreateEmailBody(repo.SuccessRegisterEmailBodyPath, email, pass);
                GeneralFunctions.SendEmail(repo.EmailFrom, email, repo.EmailFrom, repo.EmailSubject, repo.EmailHost, repo.EmailPort, repo.SMTPUserName, repo.SMTPPassword, HtmlBody);

                UsersGV.DataSource = usersBLL.getAllUsers();
                UsersGV.DataBind();
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblModal.Text = result.Errors.FirstOrDefault();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (User.Identity.IsAuthenticated && User.IsInRole("Superusers"))
                {
                }
                else
                {
                    Response.Redirect("/UI/Login.aspx");
                }

                UsersGV.DataSource = settingsBLL.getAllSettings();
                UsersGV.DataBind();
            }
        }
        protected void Delete_Click(object sender, EventArgs e)
        {
            //Get the button that raised the event
            Button btn = (Button)sender;

            //Get the row that contains this button
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;

            string id = gvr.Cells[0].Text;

            var userStore   = new UserStore <IdentityUser>();
            var userManager = new UserManager <IdentityUser>(userStore);
            var user        = userManager.FindById(id);

            if (user != null)
            {
                var oldSettings = settingsBLL.getSettingsByUserId(id);

                if (oldSettings != null)
                {
                    oldSettings.UserId = null;
                    var oldResult = settingsBLL.update(oldSettings);

                    if (oldResult == null)
                    {
                        lblModal.Text = "Failed to update";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                        return;
                    }
                }

                userStore.DeleteAsync(user);

                UsersGV.DataSource = usersBLL.getAllUsers();
                UsersGV.DataBind();
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblModal.Text = "Failed to delete account";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
            }
        }
Esempio n. 4
0
        private void DeleteBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            _dbMan.SqlStatement = "delete from tbl_User2 " +
                                  " where userid = '" + UsersGV.GetFocusedDataRow()["USERID"].ToString() + "' ";
            _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbMan.ExecuteInstruction();

            MWDataManager.clsDataAccess _dbMan2 = new MWDataManager.clsDataAccess();
            _dbMan2.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            _dbMan2.SqlStatement = "delete from tbl_Users " +
                                   " where userid = '" + UsersGV.GetFocusedDataRow()["USERID"].ToString() + "' ";
            _dbMan2.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbMan2.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbMan2.ExecuteInstruction();

            LoadUsers();
        }
Esempio n. 5
0
        private void EditBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            PropFrm UsersFrm = new PropFrm();

            UsersFrm._theConnection = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            UsersFrm.Edit.Text      = "Y";

            UsersFrm.UserIDTxt.Text       = UsersGV.GetFocusedDataRow()["USERID"].ToString();
            UsersFrm.UserNameTxt.Text     = UsersGV.GetFocusedDataRow()["USERNAME"].ToString();
            UsersFrm.PracticeTxt.Text     = UsersGV.GetFocusedDataRow()["PracticeNo"].ToString();
            UsersFrm.PasswordTxt.Text     = UsersGV.GetFocusedDataRow()["Password"].ToString();
            UsersFrm.PasswordConfTxt.Text = UsersGV.GetFocusedDataRow()["Password"].ToString();
            UsersFrm.AccessCodeTxt.Text   = UsersGV.GetFocusedDataRow()["AccessCode"].ToString();

            //UsersFrm.UserNameTxt.Text = SysGrid.CurrentRow.Cells[1].Value.ToString();
            //UsersFrm.PasswordTxt.Text = SysGrid.CurrentRow.Cells[2].Value.ToString();
            //UsersFrm.PasswordConfTxt.Text = SysGrid.CurrentRow.Cells[3].Value.ToString();
            //UsersFrm.PracticeTxt.Text = SysGrid.CurrentRow.Cells[4].Value.ToString();
            //UsersFrm.AccessCodeTxt.Text = SysGrid.CurrentRow.Cells[5].Value.ToString();
            // UsersFrm.ConnectionString = ConnectionString;
            UsersFrm.ShowDialog();

            LoadUsers();
        }
Esempio n. 6
0
 protected void UsersGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     UsersGV.PageIndex = e.NewPageIndex;
     UsersGV.DataBind();
 }
Esempio n. 7
0
        private void UsersGV_RowCellClick_1(object sender, RowCellClickEventArgs e)
        {
            UserRightsPnl.Width = panel1.Width / 4;
            //layoutControl10.Visible = true;
            ///Load Users Rights
            ///
            layoutControlGroup12.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            _dbMan.SqlStatement = " " +
                                  " select a.Activity,  " +
                                  " case when rights is null then 'N' else 'Y' end as Rights  " +
                                  " from(" +
                                  "  select distinct(Activity) Activity from tbl_User_Access)a " +
                                  "  left outer join (" +
                                  " select Rights, Activity from tbl_User_Access where userid = '" + UsersGV.GetFocusedDataRow()["USERID"].ToString() + "')b " +
                                  " on a.Activity = b.Activity  order by a.Activity ";
            _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbMan.ExecuteInstruction();

            DataTable dt = _dbMan.ResultsDataTable;
            DataSet   ds = new DataSet();

            if (ds.Tables.Count > 0)
            {
                ds.Tables.Clear();
            }
            ds.Tables.Add(dt);
            //Grd3Mnth.Visible = true;
            gridControl1.DataSource = ds.Tables[0];
            gridColumn1.FieldName   = "Activity";
            gridColumn2.FieldName   = "Rights";
        }