Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Request.Cookies["usr"] != null) && (Session["user"]==null))
            {
                MySqlConnection conn;
                MySqlCommand cmd;
                MySqlDataReader rdr;
                MySqlParameter param;

                conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CS"].ConnectionString);

                conn.Open();

                cmd = new MySqlCommand("SELECT userID FROM users_zapamietaj WHERE zapamietaneID = @zapamietaneID;");
                cmd.Connection = conn;

                param = new MySqlParameter("zapamietaneID", MySqlDbType.String);
                param.Value = Request.Cookies["usr"].Value;
                cmd.Parameters.Add(param);

                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Session["user"] = new User(rdr.GetInt32(rdr.GetOrdinal("userID")));
                }

                conn.Close();
            }

            if (Request.Params["action"] != null)
            {
                if (Request.Params["action"] == "logout")
                {
                    HttpCookie cookie = new HttpCookie("usr","");
                    cookie.Expires = DateTime.Now.AddYears(-10);

                    Response.Cookies.Add(cookie);

                    Session.RemoveAll();
                    Session.Abandon();
                }
            }

            if (Session["user"] != null)
            {
                HyperLinkLogowanie.Visible = false;
                HyperLinkWyloguj.Visible = true;
                HyperLinkRejestracja.Visible = false;
                HyperLinkMyAcc.Visible = true;
            }
            else
            {
                HyperLinkLogowanie.Visible = true;
                HyperLinkWyloguj.Visible = false;
                HyperLinkRejestracja.Visible = true;
                HyperLinkMyAcc.Visible = false;
            }
        }
Ejemplo n.º 2
0
        protected void Zaloguj_Click(object sender, EventArgs e)
        {
            DataView dv = (DataView)SqlDataSourceLogin.Select(DataSourceSelectArguments.Empty);

            if (dv.Count > 0)
            {
                DataRowView drv = dv[0];

                if (drv["blokada"].ToString().Equals("True"))
                {
                    LInfo.Text = "To konto jest zablokowane!";
                    LInfo.Visible = true;
                }
                else
                {
                    if (CheckBoxZapamietaj.Checked)
                    {
                        HttpCookie cookie = new HttpCookie("usr", System.Guid.NewGuid().ToString());
                        cookie.Expires = DateTime.Now.AddYears(10);

                        Response.Cookies.Add(cookie);

                        SqlDataSourceLogin.DeleteParameters["userID"].DefaultValue = drv["userID"].ToString();

                        SqlDataSourceLogin.Delete();

                        SqlDataSourceLogin.InsertParameters["userID"].DefaultValue = drv["userID"].ToString();
                        SqlDataSourceLogin.InsertParameters["zapamietaneID"].DefaultValue = cookie.Value;

                        SqlDataSourceLogin.Insert();
                    }

                    Session["user"] = new User(int.Parse(drv["userID"].ToString()));

                    if (Request.Params["order"] != null)
                    {
                        Response.Redirect("~/Order.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                }
            }
            else
            {
                LInfo.Text = "Niepoprawny login lub hasło!";
                LInfo.Visible = true;
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Server.Transfer("~/Login.aspx?order=true");
            }

            if (Request.Cookies["basket"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }

            usr = (User)Session["user"];

            DataView dv = (DataView)SqlDataSourceOrder.Select(DataSourceSelectArguments.Empty);

            Boolean czyil = false;

            if (dv.Count == 0)
            {
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                foreach (DataRowView drv in dv)
                {
                    int magazyn = int.Parse(drv["ileMagazyn"].ToString());
                    int ilosc = int.Parse(drv["ilosc"].ToString());
                    if (ilosc > magazyn)
                    {
                        czyil = true;
                        break;
                    }
                }
            }

            if (czyil)
            {
                Panel1.Visible = false;
                Panel4.Visible = true;
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }

            usr = (User)Session["user"];

            if (Request.Params["page"] != null)
            {
                if (Request.Params["page"].Equals("1"))
                {
                    PanelZamowienia.Visible = true;
                }
                else if (Request.Params["page"].Equals("2"))
                {
                    PanelProfil.Visible = true;
                    //PanelProfil.DataBind();
                }
                else if (Request.Params["page"].Equals("3"))
                {
                    PanelZmianaPass.Visible = true;
                }
            }
            else
            {
                PanelMyAcc.Visible = true;
            }
        }