コード例 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Boolean proceed = true;
            //if validation is correct then proceed
            if (TextBox1.Text == "")
            {
                Label7.Visible = true;
                proceed        = false;
            }
            if (TextBox2.Text == "")
            {
                Label8.Visible = true;
                proceed        = false;
            }
            if (proceed == true)
            {
                float price = 0;


                con = new SqlDbConnect();

                //finding item price
                con.SqlQuery("SELECT Item_Price FROM Item_Table WHERE Item_ID=" + int.Parse(TextBox1.Text));
                price = float.Parse(con.ExecuteScalar().Trim());
                //finding item name
                con.SqlQuery("SELECT Item_Name FROM Item_Table WHERE Item_ID=" + int.Parse(TextBox1.Text));
                this.name = con.ExecuteScalar().Trim();


                this.nameArr.Add(this.name);
                Label6.Text   = Label6.Text + ", " + this.name;
                TextBox3.Text = ((float)price * int.Parse(TextBox2.Text)).ToString();                         //price of item * quantity

                ListBox1.Items.Add(setText(this.name, float.Parse(TextBox3.Text), int.Parse(TextBox2.Text))); //prints the receipt of purchase
                float temp = 0;
                if (TextBox5.Text == "")
                {
                    TextBox5.Text = temp.ToString();
                }
                TextBox5.Text = (float.Parse(TextBox3.Text) + float.Parse(TextBox5.Text)).ToString();//calculation for total amount
                TextBox1.Text = "";
                TextBox2.Text = "";
            } //end proceed
        }     //ends try
        catch {
        }
    }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["User"] == null)    //if no user session created, revert to login page
     {
         Response.Redirect("~/Pages/LoginPage.aspx");
     }
     //load customer ID
     con = new SqlDbConnect();
     con.SqlQuery("SELECT Customer_ID FROM Cust_Table WHERE Customer_Username= '******'");    //finding the users unique ID
     this.id        = int.Parse(con.ExecuteScalar().Trim());
     LabelDate.Text = this.id.ToString();
 }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["User"] == null)
         {
             Response.Redirect("~/Pages/LoginPage.aspx");//if no session is created, reverts to login page
         }
         Label1.Text = Session["User"].ToString();
         con         = new SqlDbConnect();
         con.SqlQuery("SELECT Customer_ID FROM Cust_Table WHERE Customer_Username= '******' ");//selects customer ID (FOREIGN KEY) to identify the customers products
         this.id     = int.Parse(con.ExecuteScalar());
         Label2.Text = this.id.ToString();
     }
     catch { }
 }
コード例 #4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Boolean proceed = false;
            string  Email   = "";
            //validation cell number


            //validation email
            con = new SqlDbConnect();
            con.SqlQuery("SELECT Customer_Email FROM Cust_Table ");//selecting email from customer table for validation
            Email = con.ExecuteScalar();
            if (TextBox3.Text == Email)
            {
                Label2.Visible = true;
                proceed        = false;
            }
            else
            {
                Label2.Visible = false;
                proceed        = true;
            }

            if (proceed == true)
            {
                con = new SqlDbConnect();
                con.SqlQuery("INSERT INTO Cust_Table (Customer_Name, Customer_Surname, Customer_Email, Customer_Cell, Customer_Username, Customer_Password) VALUES(@NameP,@SurnameP,@EmailP, @CellP,@UserP,@PassP )");
                con.cmd.Parameters.Add("@NameP", TextBox1.Text.Trim());
                con.cmd.Parameters.Add("@SurnameP", TextBox2.Text.Trim());
                con.cmd.Parameters.Add("@EmailP", TextBox3.Text.Trim());
                con.cmd.Parameters.Add("@CellP", TextBox4.Text.Trim());
                con.cmd.Parameters.Add("@UserP", TextBox5.Text.Trim());
                con.cmd.Parameters.Add("@PassP", TextBox6.Text.Trim());
                con.NonQuery();
                //inserting new details into db


                Response.Redirect("~/Pages/LoginPage.aspx");
            }
        }
        catch {
        }
    }
コード例 #5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            con = new SqlDbConnect();
            con.SqlQuery("SELECT Customer_Username , Customer_Password FROM Cust_Table WHERE Customer_Username = '******' AND Customer_Password= '******'");

            Uname = con.ExecuteScalar();


            if (Uname.Equals(TextBox1.Text.Trim()))
            {
                //  Label1.Text = "Found";
                Label1.Visible  = false;
                Session["User"] = TextBox1.Text.Trim();
                Response.Redirect("~/Pages/Home.aspx");
            }
        }
        catch {
            Label1.Visible = true;
        }
    }