Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDataClass.getAllProducts();
            txtMessage.Text = "";
            if (!IsPostBack)
            {
                DisplayRow((int)Session["Prog3_Index"]);
            }
            string        Output = "";
            SqlConnection conn   = new SqlConnection(ConfigurationManager.ConnectionStrings["UWPCS3870ConnectionString1"].ConnectionString);

            conn.Open();
            string insertQuery = "Select Role from Users where UserName = '******'";

            SqlCommand com = new SqlCommand(insertQuery, conn);

            //com.ExecuteNonQuery();
            SqlDataReader item = com.ExecuteReader();

            while (item.Read())
            {
                Output = item.GetValue(0).ToString();
            }
            conn.Close();
            if (!Output.Contains("Admin"))
            {
                Response.Redirect("Default.aspx");
            }
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     this.DataBind();
     if (!IsPostBack)
     {
         DisplayRow((int)Application["Prog3_Index"]);
     }
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     txtMessage.Text = "";
     if (!IsPostBack)
     {
         DisplayRow((int)Session["Prog3_Index"]);
     }
 }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SQLDataClass.getAllProducts();
            this.DataBind();

            //txtID.Text = (string)Application["Prog2_ProductID"];
            //txtQuantity.Text = (string)Application["Prog2_ProductQuantity"];
            //txtPrice.Text = Application["Prog2_ProductPrice"].ToString();

            txtID.Focus();
        }
Ejemplo n.º 5
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         string theID    = txtID.Text;
         string newName  = txtName.Text;
         double newPrice = double.Parse(txtPrice.Text.Replace("$", ""));
         string newDesc  = txtDescription.Text;
         SQLDataClass.UpdateProduct(theID, newName, newPrice, newDesc);
         txtMessage.Text = "Record updated.";
         SQLDataClass.getAllProducts();
     }
     catch (Exception ex)
     {
         txtMessage.Text = "Product Not Updated: " + ex.Message;
     }
 }
Ejemplo n.º 6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text == "Add")
            {
                btnDelete.Enabled   = false;
                btnNext.Enabled     = false;
                btnPrevious.Enabled = false;
                btnFirst.Enabled    = false;
                btnLast.Enabled     = false;
                btnUpdate.Enabled   = false;
                btnAdd.Text         = "Save";
                clearTextFields();
            }
            else
            {
                btnDelete.Enabled   = true;
                btnNext.Enabled     = true;
                btnPrevious.Enabled = true;
                btnFirst.Enabled    = true;
                btnLast.Enabled     = true;
                btnUpdate.Enabled   = true;
                try
                {
                    btnAdd.Text = "Add";
                    string theID    = txtID.Text;
                    string newName  = txtName.Text;
                    double newPrice = double.Parse(txtPrice.Text.Replace("$", ""));
                    string newDesc  = txtDescription.Text;

                    SQLDataClass.InsertProduct(theID, newName, newPrice, newDesc);
                    txtMessage.Text = "Record added.";
                    SQLDataClass.getAllProducts();
                }
                catch (Exception ex)
                {
                    txtMessage.Text = "Product Not Added: " + ex.Message;
                }
            }
        }
Ejemplo n.º 7
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string theID = txtID.Text;
                SQLDataClass.DeleteProduct(theID);
                txtMessage.Text = "Record deleted.";
                SQLDataClass.getAllProducts();

                int index = (int)Application["Prog3_Index"] - 1;
                if (index < 0)
                {
                    index = 0;
                }
                Application["Prog3_index"] = index;
                DisplayRow(index);
            }
            catch (Exception ex)
            {
                txtMessage.Text = "Product Not Deleted: " + ex.Message;
            }
        }
Ejemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
 }
Ejemplo n.º 9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     ProductGrid.DataSource = SQLDataClass.tblProduct;
     ProductGrid.DataBind();
 }