Пример #1
0
        protected void GridViewListaKorisnika_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToString() == "DeleteKorisnik")
            {
                string         userName = e.CommandArgument.ToString();
                MembershipUser mUser    = Membership.GetUser(userName);
                if (mUser != null)
                {
                    try
                    {
                        Membership.DeleteUser(userName);
                        SqlConnection veza = new SqlConnection();
                        veza.ConnectionString = WebConfigurationManager.ConnectionStrings["VezaSaBazom"].ToString();
                        SqlCommand komanda = new SqlCommand();
                        komanda.Connection  = veza;
                        komanda.CommandType = CommandType.StoredProcedure;
                        komanda.CommandText = "DeleteKorisnikDodatno";

                        komanda.Parameters.AddWithValue("@idKorisnik", mUser.ProviderUserKey);

                        komanda.Connection.Open();
                        komanda.ExecuteNonQuery();
                        komanda.Connection.Close();

                        GridViewListaKorisnika.DataBind();
                    }
                    catch (Exception ex)
                    {
                        glavna mojMaster = (glavna)this.Master;
                        mojMaster.prikaziPoruku(ex.Message, "error");
                    }
                }
            }
        }
Пример #2
0
        protected void FormaUnesikorisnika_CreatedUser(object sender, EventArgs e)
        {
            try
            {
                TextBox         imePrezime    = (TextBox)FormaUnesikorisnika.CreateUserStep.ContentTemplateContainer.FindControl("TextBoxImePrezime");
                RadioButtonList pol           = (RadioButtonList)FormaUnesikorisnika.CreateUserStep.ContentTemplateContainer.FindControl("RadioButtonListPol");
                DropDownList    godina        = (DropDownList)FormaUnesikorisnika.CreateUserStep.ContentTemplateContainer.FindControl("DropDownListGodRodjenja");
                DropDownList    uloga         = (DropDownList)FormaUnesikorisnika.CreateUserStep.ContentTemplateContainer.FindControl("DropDownListUloge");
                TextBox         korisnickoIme = (TextBox)FormaUnesikorisnika.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
                if (imePrezime != null && pol != null && godina != null && uloga != null && korisnickoIme != null)
                {
                    MembershipUser regKorisnik = Membership.GetUser(korisnickoIme.Text);
                    if (regKorisnik != null)
                    {
                        SqlConnection veza = new SqlConnection();
                        veza.ConnectionString = WebConfigurationManager.ConnectionStrings["VezaSaBazom"].ToString();
                        SqlCommand komanda = new SqlCommand();
                        komanda.Connection  = veza;
                        komanda.CommandType = CommandType.StoredProcedure;
                        komanda.CommandText = "InsertKorisnikDodatno";

                        komanda.Parameters.AddWithValue("@idKorisnik", regKorisnik.ProviderUserKey);
                        komanda.Parameters.AddWithValue("@imePrezime", imePrezime.Text);
                        komanda.Parameters.AddWithValue("@pol", pol.SelectedItem.Value);
                        komanda.Parameters.AddWithValue("@godinaRodjenja", godina.SelectedValue);
                        komanda.Connection.Open();
                        komanda.ExecuteNonQuery();
                        komanda.Connection.Close();
                        Roles.AddUserToRole(korisnickoIme.Text, uloga.SelectedItem.Text);
                        GridViewListaKorisnika.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                glavna mojMaster = (glavna)this.Master;
                mojMaster.prikaziPoruku(ex.Message, "error");
            }
        }