protected void Button1_Click(object sender, EventArgs e)
        {
            reutrn r = new reutrn();
            string s = r.returnscalar("select count(c_id) from customer where c_email='" + txtemail.Text + "'");

            if (s.Equals("0"))
            {
                Response.Write("<script>alert('This email doesnot exist') </script>");
            }
            else if (s.Equals("1"))
            {
                s = r.returnscalar("select c_password from customer where c_email='" + txtemail.Text + "'");
                if (s.Equals(password.Text))
                {
                    HttpCookie cookie = new HttpCookie("DONOR");
                    cookie["email"] = Server.UrlEncode(txtemail.Text);
                    cookie["pwd"]   = Server.UrlEncode(password.Text);
                    cookie.Expires  = DateTime.Now.AddDays(30);
                    Session["u_id"] = r.returnscalar("select c_id from customer where c_email='" + txtemail.Text + "'");
                    Response.Cookies.Add(cookie);
                    Response.Redirect("~/views/custprofile.aspx");
                }
                else
                {
                    Response.Write("<script>alert('Invalid Password') </script>");
                }
            }
            else
            {
                Response.Write("<script>alert('some error') </script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["DONOR"];

            if (cookie == null)
            {
                Response.Redirect("~/views/login.aspx");
            }
            else
            {
                if (Session["u_id"] != null)
                {
                    reutrn r       = new reutrn();
                    string imgpath = r.returnscalar("select count(img_id) from donor_img where img_fk_donor=" + Session["u_id"].ToString());
                    if (imgpath.Equals("0"))
                    {
                        Image1.ImageUrl = "~/img/profile-icon-9.png";
                    }
                    else
                    {
                        Image1.ImageUrl = r.returnscalar("select img_path from donor_img where img_fk_donor=" + Session["u_id"].ToString());
                    }



                    string        q   = "select d_id,d_name,d_cnic,d_email,d_contact,d_age,B.B_NAME,d_hb,d_sex from user_donor d JOIN  bloodgroup B ON B.b_id=d_blood where d.d_id=" + Session["u_id"];
                    SqlConnection con = new SqlConnection(cs);
                    try
                    {
                        SqlCommand cmd = new SqlCommand(q, con);
                        con.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            Label1.Text = reader.GetValue(1).ToString();
                            Label2.Text = reader.GetValue(2).ToString();
                            Label3.Text = reader.GetValue(3).ToString();
                            Label4.Text = reader.GetValue(4).ToString();
                            Label5.Text = reader.GetValue(5).ToString();
                            Label6.Text = reader.GetValue(6).ToString();
                            Label8.Text = reader.GetValue(7).ToString();
                            Label9.Text = reader.GetValue(8).ToString();
                        }
                    }
                    catch (Exception)
                    {
                    }
                    finally
                    {
                        con.Close();
                    }
                }

                else
                {
                    Response.Redirect("~/views/login.aspx");
                }
            }
        }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["u_id"] == null)
     {
         LinkButton1.Text = "Login";
         LinkButton2.Text = "Sign Up";
     }
     else
     {
         reutrn r = new reutrn();
         LinkButton1.Text = r.returnscalar("select d_name from user_donor where d_id=" + Session["u_id"]);
         LinkButton2.Text = "Log Out";
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["view"] != null)
            {
                HiddenField1.Value = Request.QueryString["view"].ToString();
            }
            else
            {
                Response.Redirect("~/default.aspx");
            }



            DataSet ds = GetData();



            Repeater1.DataSource = ds;
            Repeater1.DataBind();


            reutrn r       = new reutrn();
            string imgpath = r.returnscalar("select count(img_id) from donor_img where img_fk_donor=" + HiddenField1.Value);

            if (imgpath.Equals("0"))
            {
                Image1.ImageUrl = "~/img/profile-icon-9.png";
            }
            else
            {
                Image1.ImageUrl = r.returnscalar("select img_path from donor_img where img_fk_donor=" + HiddenField1.Value);
            }



            string        q   = "select d_id,d_name,d_cnic,d_email,d_contact,d_age,B.B_NAME from user_donor d  JOIN  bloodgroup B ON B.b_id=d_blood where d.d_id=" + HiddenField1.Value;
            SqlConnection con = new SqlConnection(cs);

            try
            {
                SqlCommand cmd = new SqlCommand(q, con);
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Label1.Text = reader.GetValue(1).ToString();
                    Label2.Text = reader.GetValue(2).ToString();
                    Label3.Text = reader.GetValue(3).ToString();
                    Label4.Text = reader.GetValue(4).ToString();
                    Label5.Text = reader.GetValue(5).ToString();
                    Label6.Text = reader.GetValue(6).ToString();
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                con.Close();
            }
        }