Exemplo n.º 1
0
    protected void btnaddItem_Click(object sender, EventArgs e)
    {
        int    proid = id;
        String pname, pcat, pstock, pdes, pimgname;

        pname = productname.Text;
        pcat  = dlscategory.SelectedValue;
        float ppice = float.Parse(productprice.Text);

        pstock   = productstock.Text;
        pdes     = productdescription.Text;
        pimgname = "Images/" + Path.GetFileName(productfileupload.PostedFile.FileName);
        productfileupload.SaveAs(Server.MapPath(pimgname));
        conn = MyConnections.ConnectDB();
        conn.Open();
        try
        {
            cmd             = conn.CreateCommand();
            cmd.CommandText = "insert into product values(" + proid + "," + ppice + ",'" + pname + "','" + pcat + "','" + pimgname + "','" + pdes + "','" + pstock + "')";
            cmd.ExecuteNonQuery();
            // Response.Write("<script>alert('Product has been Added.')</script>");
            conn.Close();


            //   Response.Write("<script>alert('Product has been Added.')</script>");
            Response.Redirect("~/Admin/ItemAvailability.aspx");
        }
        catch (Exception e1)
        {
            Response.Write("<script>alert(" + e1.ToString() + ")</script>");
        }
    }
Exemplo n.º 2
0
    protected void updateStock(DataSet dr)
    {
        MySqlCommand    cmd;
        MySqlConnection conn = null;

        conn = MyConnections.ConnectDB();
        conn.Open();
        int iRows = dr.Tables[0].Rows.Count;

        if (iRows > 0)
        {
            int iCnt = 0;

            for (iCnt = 0; iCnt < iRows; iCnt++)
            {
                cmd = conn.CreateCommand();
                int iOrdrstk = Convert.ToInt32(dr.Tables[0].Rows[iCnt]["quentity"].ToString());
                int iProdstk = Convert.ToInt32(dr.Tables[0].Rows[iCnt]["prostock"].ToString());
                int iProid   = Convert.ToInt32(dr.Tables[0].Rows[iCnt]["proid"].ToString());

                cmd.CommandText = "update product set prostock =" + (iProdstk - iOrdrstk) + " where proid=" + iProid;
                cmd.ExecuteNonQuery();
            }
        }
    }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["User"] == null)
     {
         HyperLink13.Text        = "LOGIN";
         HyperLink13.NavigateUrl = "~/LoginPage.aspx";
     }
     else if (Session["User"] != null)
     {
         conn = MyConnections.ConnectDB();
         conn.Open();
         try
         {
             cmd             = conn.CreateCommand();
             cmd.CommandText = "select fname from userregistration where email='" + Session["User"] + "'";
             mdr             = cmd.ExecuteReader();
             if (mdr.Read())
             {
                 Username.Text = "Welcome " + mdr.GetString(0).ToUpper();
                 mdr.Close();
             }
             conn.Close();
         }
         catch (Exception e1)
         {
             Response.Write("<script>alert(" + e1.ToString() + ")</script>");
         }
         HyperLink13.Text        = "LOGOUT";
         HyperLink13.NavigateUrl = "~/LogoutPage.aspx";
     }
 }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["User"] != null)
     {
         conn = MyConnections.ConnectDB();
         conn.Open();
         try
         {
             cmd = conn.CreateCommand();
             String              strSQL   = "select * from temp";
             MySqlDataAdapter    mydata   = new MySqlDataAdapter(strSQL, conn);
             MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(mydata);
             DataSet             ds       = new DataSet();
             mydata.Fill(ds);
             GridView2.DataSource = ds;
             GridView2.DataBind();
             conn.Close();
         }
         catch (Exception e1)
         {
             Response.Write("<script>alert(" + e1.ToString() + ")</script>");
             conn.Close();
         }
     }
     else
     {
         Response.Redirect("~/HomePage.aspx?category=CR");
     }
 }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Params["category"] != null)
     {
         conn = MyConnections.ConnectDB();
         conn.Open();
         try
         {
             cmd = conn.CreateCommand();
             String              strSQL   = "select * from product where catname='" + Request.Params["category"] + "'";
             MySqlDataAdapter    mydata   = new MySqlDataAdapter(strSQL, conn);
             MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(mydata);
             DataSet             ds       = new DataSet();
             mydata.Fill(ds);
             DataList1.DataSource = ds;
             DataList1.DataBind();
             conn.Close();
         }
         catch (Exception e1)
         {
             Response.Write("<script>alert(" + e1.ToString() + ")</script>");
         }
     }
     else
     {
         Response.Redirect("~/HomePage.aspx?category=CR");
     }
 }
Exemplo n.º 6
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        MySqlCommand    cmd;
        MySqlConnection conn = null;

        conn = MyConnections.ConnectDB();
        conn.Open();
        try
        {
            cmd = conn.CreateCommand();
            String              strSQL   = "select t.proid,t.quentity, p.prostock from temp t inner join product p on t.proid = p.proid";
            MySqlDataAdapter    mydata   = new MySqlDataAdapter(strSQL, conn);
            MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(mydata);
            DataSet             ds       = new DataSet();
            mydata.Fill(ds);
            updateStock(ds);

            cmd             = conn.CreateCommand();
            cmd.CommandText = "INSERT INTO `orders` SELECT * FROM `temp`;";
            cmd.ExecuteNonQuery();

            cmd             = conn.CreateCommand();
            cmd.CommandText = "truncate table temp";
            cmd.ExecuteNonQuery();

            conn.Close();
        }
        catch (Exception e1)
        {
            Response.Write("<script>alert(" + e1.ToString() + ")</script>");
        }

        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Your Order has been placed successfully and will be delivered within 7 days at your doorstep!.Thank You for Shopping');window.location ='HomePage.aspx?category=CR';", true);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string anstb = fpanstb.Text;

        if (ansdb == anstb)
        {
            String newpass1 = newpass.Text;
            conn = MyConnections.ConnectDB();
            conn.Open();
            try
            {
                email           = fpemailtb.Text;
                cmd             = conn.CreateCommand();
                cmd.CommandText = "update userregistration set password='******' where email='" + email + "'";
                cmd.ExecuteNonQuery();
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Password Updated Successfully!');", true);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Password changed Successfully!');window.location ='HomePage.aspx?category=CR';", true);
                //Response.Write("<script>alert('Password Updated Successfully!')</script>");
                // Response.Redirect("~/HomePage.aspx");
                conn.Close();
            }
            catch (Exception e1)
            {
                Response.Write("<script>alert(" + e1.ToString() + ")</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('Please Enter Correct Answer..!!')</script>");
        }
    }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String s = Request.Params["name"];

        conn = MyConnections.ConnectDB();
        try
        {
            conn.Open();
            cmd             = conn.CreateCommand();
            cmd.CommandText = "select * from product where proname='" + s + "'";
            mdr             = cmd.ExecuteReader();
            if (mdr.Read())
            {
                productimage.ImageUrl   = mdr.GetString(4);
                productname.Text        = mdr.GetString(2);
                productprice.Text       = mdr.GetString(1);
                productdescription.Text = mdr.GetString(5);
                proid = mdr.GetString(0);
            }
        }
        catch (Exception e1)
        {
            Response.Write("<script>alert(" + e1.ToString() + ")</script>");
        }
        finally
        {
            conn.Close();
        }
    }
Exemplo n.º 9
0
 protected void listview(String s)
 {
     conn = MyConnections.ConnectDB();
     conn.Open();
     cmd                  = conn.CreateCommand();
     cmd.CommandText      = "select proid,proname from product where catname='" + s + "'";
     mdr                  = cmd.ExecuteReader();
     GridView1.DataSource = mdr;
     GridView1.DataBind();
     conn.Close();
 }
Exemplo n.º 10
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        String proid = productid.Text.Trim();

        if (proid == "" || proid == null)
        {
            Response.Write("<scritp>alert('Please Enter the Product ID to Delete from Your Cart..!!')</script>");
        }
        else
        {
            conn = MyConnections.ConnectDB();
            conn.Open();
            try
            {
                cmd             = conn.CreateCommand();
                cmd.CommandText = "select * from temp where proid='" + proid + "'";
                mdr             = cmd.ExecuteReader();
                if (mdr.Read())
                {
                    mdr.Close();
                    try
                    {
                        cmd             = conn.CreateCommand();
                        cmd.CommandText = "delete from temp where proid='" + proid + "'";
                        cmd.ExecuteNonQuery();
                        conn.Close();
                        Response.Redirect("~/MyCartPage.aspx");
                    }
                    catch (Exception e1)
                    {
                        Response.Write("<script>alert(" + e1.ToString() + ")</script>");
                        conn.Close();
                    }
                }
                else
                {
                    Response.Write("<script>alert('Please Enter Proper Product ID..!!')</script>");
                }
            }
            catch (Exception e2)
            {
                Response.Write("<script>alert(" + e2.ToString() + ")</script>");
            }
            finally
            {
                conn.Close();
            }
        }
    }
Exemplo n.º 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Session.Abandon();
     conn = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd             = conn.CreateCommand();
         cmd.CommandText = "truncate table temp";
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception e1)
     {
         Response.Write("<script>alert(" + e1.ToString() + ")</script>");
     }
     Response.Redirect("~/HomePage.aspx");
 }
Exemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     conn = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd                 = conn.CreateCommand();
         cmd.CommandText     = "select * from userregistration order by userid";
         mdr                 = cmd.ExecuteReader();
         CustGrid.DataSource = mdr;
         CustGrid.DataBind();
         mdr.Close();
         conn.Close();
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
     }
 }
Exemplo n.º 13
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int id    = int.Parse(txtid.Text);
        int stock = int.Parse(txtstock.Text);

        conn = MyConnections.ConnectDB();
        conn.Open();
        try
        {
            cmd             = conn.CreateCommand();
            cmd.CommandText = "update product set prostock=" + stock + " where proid=" + id;
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
            conn.Close();
        }
    }
Exemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     conn = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd = conn.CreateCommand();
         String              strSQL   = "select * from orders";
         MySqlDataAdapter    mydata   = new MySqlDataAdapter(strSQL, conn);
         MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(mydata);
         DataSet             ds       = new DataSet();
         mydata.Fill(ds);
         GridView1.DataSource = ds;
         GridView1.DataBind();
         conn.Close();
     }
     catch (Exception e1)
     {
         Response.Write("<script>alert(" + e1.ToString() + ")</script>");
     }
 }
Exemplo n.º 15
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         conn = MyConnections.ConnectDB();
         conn.Open();
         try
         {
             cmd             = conn.CreateCommand();
             cmd.CommandText = "delete from product where proid=" + id;
             cmd.ExecuteNonQuery();
             conn.Close();
             listview(DropDownList1.SelectedValue);
         }
         catch (Exception e1)
         {
             Response.Write(e1.ToString());
         }
     }
 }
Exemplo n.º 16
0
 protected void LinkButton8_Click(object sender, EventArgs e)
 {
     conn = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd = conn.CreateCommand();
         String              strSQL   = "select * from product where catname='" + DropDownList1.SelectedValue + "'";
         MySqlDataAdapter    mydata   = new MySqlDataAdapter(strSQL, conn);
         MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(mydata);
         DataSet             ds       = new DataSet();
         mydata.Fill(ds);
         GridView1.DataSource = ds;
         GridView1.DataBind();
         conn.Close();
     }
     catch (Exception e1)
     {
         Response.Write("<script>alert(" + e1.ToString() + ")</script>");
     }
 }
Exemplo n.º 17
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        String adminemail = adminlogintb.Text;
        String pass       = adminpasstb.Text;

        if (adminemail == "*****@*****.**")
        {
            conn = MyConnections.ConnectDB();
            conn.Open();
            try
            {
                cmd             = conn.CreateCommand();
                cmd.CommandText = "select password from userregistration where email='" + adminemail + "'";
                mdr             = cmd.ExecuteReader();
                if (mdr.Read())
                {
                    if (mdr.GetString(0) == pass)
                    {
                        Session["User"] = "******";
                        mdr.Close();
                        conn.Close();
                        Response.Redirect("~/Admin/ItemAvailability.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('Please Enter Proper Password..!!')</script>");
                    }
                }
                conn.Close();
            }
            catch (Exception e1)
            {
                Response.Write("<script>alert(" + e1.ToString() + ")</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('Please Enter proper Admin Email ID..!!')</script>");
        }
    }
Exemplo n.º 18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     conn = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd             = conn.CreateCommand();
         cmd.CommandText = "select MAX(proid) from product";
         mdr             = cmd.ExecuteReader();
         if (mdr.Read())
         {
             id          = int.Parse(mdr.GetString(0)) + 1;
             prodid.Text = id.ToString();
         }
         mdr.Close();
         conn.Close();
     }
     catch (Exception e1)
     {
         Response.Write("<script>alert(" + e1.ToString() + ")</script>");
     }
 }
Exemplo n.º 19
0
 protected void btnlogin_Click(object sender, EventArgs e)
 {
     conn = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd             = conn.CreateCommand();
         cmd.CommandText = "select * from userregistration where email='" + logintb.Text + "' and password='******'";
         mdr             = cmd.ExecuteReader();
         if (mdr.Read())
         {
             Session["User"] = logintb.Text;
             conn            = MyConnections.ConnectDB();
             conn.Open();
             try
             {
                 cmd             = conn.CreateCommand();
                 cmd.CommandText = "truncate table temp";
                 cmd.ExecuteNonQuery();
                 conn.Close();
             }
             catch (Exception e1)
             {
                 Response.Write("<script>alert(" + e1.ToString() + ")</script>");
             }
             //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You have logged in successfully!');window.location ='HomePage.aspx?category=CR';", true);
             Response.Redirect("HomePage.aspx");
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Login Unsuccessfull!');", true);
             // Response.Write("<script>alert('Login Unsuccessful!')</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
     }
 }
 protected void Button2_Click(object sender, EventArgs e)
 {
     email = fpemailtb.Text;
     conn  = MyConnections.ConnectDB();
     conn.Open();
     try
     {
         cmd             = conn.CreateCommand();
         cmd.CommandText = "select securityqts,securityans from userregistration where email='" + email + "'";
         mdr             = cmd.ExecuteReader();
         if (mdr.Read())
         {
             question = mdr.GetString(0);
             ansdb    = mdr.GetString(1);
             conn.Close();
             Label1.Text          = question;
             fpans.Visible        = true;
             fpanstb.Visible      = true;
             Fpresetpass.Visible  = true;
             Fpresetpass0.Visible = true;
             newpass.Visible      = true;
             newpass0.Visible     = true;
             fpsecqts.Visible     = true;
             Label1.Visible       = true;
             Resetbtn.Visible     = true;
         }
         else
         {
             Response.Write("<script>alert('Enter your registered email id')</script>");
         }
     }
     catch (Exception e1)
     {
         Response.Write("<script>alert(" + e1.ToString() + ")</script>");
     }
 }
Exemplo n.º 21
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        String proid = productid.Text.Trim();
        int    proqt = int.Parse(productqt.Text.Trim());

        if (proid == "" || proid == null || proqt == null)
        {
            Response.Write("<scritp>alert('Please Enter the Product ID and Quantity to update the quantity of a product..!!')</script>");
        }
        else
        {
            int iCurrStock = 0;
            conn.Open();
            cmd             = conn.CreateCommand();
            cmd.CommandText = "select proid, prostock from product where proid=" + proid;
            mdr             = null;
            mdr             = cmd.ExecuteReader();

            if (mdr.Read())
            {
                int iProId = mdr.GetInt32(0);
                iCurrStock = mdr.GetInt32(1);

                if (iCurrStock > 10)
                {
                    iCurrStock = 10;
                }
            }
            conn.Close();

            if (proqt < 1 || proqt > iCurrStock)
            {
                Response.Write("<script>alert('Maximum Quantity is " + iCurrStock + " only..!!')</script>");
            }
            else
            {
                conn = MyConnections.ConnectDB();
                conn.Open();
                int totalprice;
                try
                {
                    cmd             = conn.CreateCommand();
                    cmd.CommandText = "select * from temp where proid='" + proid + "'";
                    mdr             = cmd.ExecuteReader();
                    if (mdr.Read())
                    {
                        mdr.Close();
                        cmd.CommandText = "select price from product where proid=" + proid;
                        mdr             = cmd.ExecuteReader();
                        if (mdr.Read())
                        {
                            Int32 price = mdr.GetInt32(0);
                            totalprice = price * proqt;
                            mdr.Close();
                            cmd.CommandText = "update temp set quentity=" + proqt + ", price='" + totalprice + "'where proid='" + proid + "'";
                            cmd.ExecuteNonQuery();
                        }
                        Response.Redirect("~/MyCartPage.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('Please Enter Proper Product ID..!!')</script>");
                    }
                }
                catch (Exception e2)
                {
                    Response.Write("<script>alert(" + e2.ToString() + ")</script>");
                }
                finally
                {
                    conn.Close();
                }
            }
        }
    }