Пример #1
0
    protected void shrani_Click(object sender, EventArgs e)
    {
        try
        {
            username.Text = username.Text.Trim();
            password.Text = password.Text.Trim();
            email.Text    = email.Text.Trim();
            ime.Text      = ime.Text.Trim();
            priimek.Text  = priimek.Text.Trim();
            if (string.IsNullOrWhiteSpace(username.Text))
            {
                throw new Exception("Polje Uporabniško ime ne sme biti prazno");
            }
            if ((!string.IsNullOrWhiteSpace(password.Text) || _id == 0) && password.Text.Length < 4)
            {
                throw new Exception("Polje Geslo ne sme biti krajše od 4 znakov");
            }
            if (ViewState["vrstice"] != null)
            {
                vrstice = JsonConvert.DeserializeObject <List <string> >(ViewState["vrstice"].ToString());
            }


            //List<int> l_davcne = new List<int>();
            //int i_davcna = Convert.ToInt32(davcna.Text);
            //l_davcne.Add(i_davcna);
            //foreach (var item in davcne.Text.Split(','))
            //{
            //    i_davcna = Convert.ToInt32(item);
            //    if (!l_davcne.Contains(i_davcna)) l_davcne.Add(i_davcna);
            //}
            //if (_id == 0) _id = Uporabniki.Dodaj(username.Text, password.Text, ime.Text, priimek.Text, email.Text, davcna.Text, string.Join(",", vrstice), prodajalec.Checked, poslovni_prostor.SelectedValue, elektronska_naprava.SelectedValue, skupine.Text, oznaka.Text, racuni.Checked, popravljanje.Checked, revirji.Text, reprezentanca.Checked, string.Join(",", l_davcne), tiskalnik.Text);
            //else Uporabniki.Popravi(_id, username.Text, password.Text, ime.Text, priimek.Text, email.Text, davcna.Text, string.Join(",", vrstice), prodajalec.Checked, s_poslovni_prostor, s_elektronska_naprava, skupine.Text, oznaka.Text, racuni.Checked, popravljanje.Checked, revirji.Text, reprezentanca.Checked, string.Join(",", l_davcne), tiskalnik.Text, null);

            if (_id == 0)
            {
                _id = Uporabniki.Add(username.Text, password.Text, ime.Text, priimek.Text, true, string.Join(",", vrstice), email.Text, "", anAdmin.Checked, Master.Uporabnik.Id);
            }
            else
            {
                Uporabniki.Edit(_id, username.Text, password.Text, ime.Text, priimek.Text, true, anAdmin.Checked, string.Join(",", vrstice), null, email.Text, "", Master.Uporabnik.Id);
            }
            Response.Redirect("Uporabnik.aspx?id=" + _id + "&msg=" + HttpUtility.UrlEncode("Podatki shranjeni"));
        }
        catch (Exception er)
        {
            Master.SetMessage(er.Message);
        }
    }
Пример #2
0
    protected void shrani_Click(object sender, EventArgs e)
    {
        try
        {
            password.Text      = password.Text.Trim();
            password_new1.Text = password_new1.Text.Trim();
            password_new2.Text = password_new2.Text.Trim();
            email.Text         = email.Text.Trim();
            ime.Text           = ime.Text.Trim();
            priimek.Text       = priimek.Text.Trim();
            if (string.IsNullOrWhiteSpace(ime.Text))
            {
                throw new Exception("Polje Ime ne sme biti prazno");
            }
            if (string.IsNullOrWhiteSpace(priimek.Text))
            {
                throw new Exception("Polje Priimek ne sme biti prazno");
            }
            if (string.IsNullOrWhiteSpace(email.Text))
            {
                throw new Exception("Polje Email ne sme biti prazno");
            }
            if (!string.IsNullOrWhiteSpace(password.Text) && password.Text.Length < 4)
            {
                throw new Exception("Polje Geslo ne sme biti krajše od 4 znakov");
            }
            if (!string.IsNullOrWhiteSpace(password_new1.Text) && password_new1.Text.Length < 4)
            {
                throw new Exception("Polje Novo geslo ne sme biti krajše od 4 znakov");
            }
            if (!string.IsNullOrWhiteSpace(password_new2.Text) && password_new2.Text.Length < 4)
            {
                throw new Exception("Polje Novo geslo (ponovi) ne sme biti krajše od 4 znakov");
            }
            if (password_new1.Text != password_new2.Text)
            {
                throw new Exception("Polji Novo geslo in Novo geslo (ponovi) nista enaki");
            }

            Uporabniki.Edit(Master.Uporabnik.Id, Master.Uporabnik.Username, password_new1.Text, ime.Text, priimek.Text, true, true, string.Join(",", Master.Uporabnik.Pravice), Session, email.Text, "", Master.Uporabnik.Id);
            Response.Redirect("Osebno.aspx?msg=" + HttpUtility.UrlEncode("Podatki shranjeni"));
        }
        catch (Exception er)
        {
            Master.SetMessage(er.Message);
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            using (Uporabnik up = new Uporabnik(Session))
            {
                up.logout(Session);
            }
            string u = "";
            string p = "";
            try
            {
                string[] hash = Varnost.DecryptAES256(Convert.ToBase64String(HttpServerUtility.UrlTokenDecode(Request.QueryString["hash"]))).Split(new string[] { "@-|@|-@" }, StringSplitOptions.None);
                if (hash.Length == 3 && hash[2] == ConfigurationManager.AppSettings["EncryptKey"])
                {
                    u = hash[0].Trim();
                    p = hash[1].Trim();
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                Response.Redirect("Default.aspx", true);
            }

            if (Uporabnik.login(u, p, Session, "", 1) == 0)
            {
                using (Uporabnik uporabnik = new Uporabnik(Session))
                {
                    try
                    {
                        username.Text = uporabnik.Username;
                        if (IsPostBack)
                        {
                            password_new1.Text = password_new1.Text.Trim();
                            password_new2.Text = password_new2.Text.Trim();
                            if (!string.IsNullOrWhiteSpace(password_new1.Text) && password_new1.Text.Length < 6)
                            {
                                throw new Exception("Polje Novo geslo ne sme biti krajše od 6 znakov");
                            }
                            if (!string.IsNullOrWhiteSpace(password_new2.Text) && password_new2.Text.Length < 6)
                            {
                                throw new Exception("Polje Novo geslo (ponovi) ne sme biti krajše od 6 znakov");
                            }
                            if (password_new1.Text != password_new2.Text)
                            {
                                throw new Exception("Polji Novo geslo in Novo geslo (ponovi) nista enaki");
                            }

                            Uporabniki.Edit(uporabnik.Id, uporabnik.Username, password_new1.Text, uporabnik.Ime, uporabnik.Priimek, uporabnik.Active, uporabnik.Admin, string.Join(",", uporabnik.Pravice), Session, uporabnik.Email, uporabnik.Gsm, uporabnik.Id);

                            _js  = "dialog('Geslo uspešno spremenjeno', 'Sedaj se lahko prijavite z novim geslom.', 'i');";
                            _js += "$('#dialog').dialog('option', 'buttons', { Ok: function () { $(this).dialog('close'); window.location='Default.aspx';}});";
                        }
                    }
                    catch (Exception er)
                    {
                        throw er;
                    }
                    finally
                    {
                        uporabnik.logout(Session);
                    }
                }
            }
            else
            {
                _error = "Podatki v povezavi so nepravilni";
            }
        }
        catch (Exception er)
        {
            _error = "Prišlo je do programske napake<br /><i style=\"font-size:0.8em;\">" + er.Message + "</i>";
        }
    }