Beispiel #1
0
    protected void btnNew_Click(object sender, EventArgs e)
    {
        if (btnNew.Text.Equals("Save New"))
        {
            try
            {
                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 updated.";
                SQLDataClass.getAllProducts();
            }
            catch (Exception ex)
            {
                txtMessage.Text = "Product Not Inserted: " + ex.Message;
            }
        }
        else if (btnNew.Text.Equals("New"))
        {
            txtDescription.Text = "";
            txtID.Text          = "";
            txtName.Text        = "";
            txtPrice.Text       = "";

            btnUpdate.Enabled   = false;
            btnFirst.Enabled    = false;
            btnLast.Enabled     = false;
            btnNext.Enabled     = false;
            btnPrevious.Enabled = false;
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     TextArea1.InnerText = "";
     if (!IsPostBack)
     {
         DisplayRow((int)Session["Prog3_Index"]);
     }
 }
Beispiel #3
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;
     }
 }
        protected void Button5_Click(object sender, EventArgs e)
        {
            try
            {
                string theID    = TextBox1.Text;
                string newName  = TextBox2.Text;
                double newPrice = double.Parse(TextBox3.Text.Replace("$", ""));
                string newDesc  = TextBox4.Text;

                SQLDataClass.UpdateProduct(theID, newName, newPrice, newDesc);
                TextArea1.InnerText = "Record Updated";
                SQLDataClass.getAllProducts();
            }
            catch (Exception ex)
            {
                TextArea1.InnerText = "Product Not Updated:" + ex.Message;
            }
        }
        protected void Button7_Click(object sender, EventArgs e)
        {
            if (Button7.Text.Equals("Save New"))
            {
                try
                {
                    string theID    = TextBox1.Text;
                    string newName  = TextBox2.Text;
                    double newPrice = double.Parse(TextBox3.Text.Replace("$", ""));
                    string newDesc  = TextBox4.Text;

                    SQLDataClass.AddProduct(theID, newName, newPrice, newDesc);
                    TextArea1.InnerText = "Record Added";
                    SQLDataClass.getAllProducts();
                    ResetButtons();
                }
                catch (Exception ex)
                {
                    TextArea1.InnerText = "Product Not added:" + ex.Message;
                }
            }
            else
            {
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox4.Text = "";

                Button1.Enabled = false;
                Button2.Enabled = false;
                Button3.Enabled = false;
                Button4.Enabled = false;
                Button5.Enabled = false;

                Button6.Text = "Cancel";
                Button7.Text = "Save New";
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     //dtlProduct.DataSource = SQLDataClass.tblProduct;
     //dtlProduct.DataBind();
 }
Beispiel #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SQLDataClass.getAllProducts();
     DisableText();
 }