Exemple #1
0
        //saves an order
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (sales db = new sales())
                {

                    Order obj = new Order();
                    obj.qty = Convert.ToInt32(txtqty.Text);
                    obj.orderDate = Convert.ToDateTime(txtOrderDate.Text);
                    obj.shipDate = Convert.ToDateTime(txtShipDate.Text);
                    obj.tax = Convert.ToDouble(txtTax.Text);
                    obj.estimateShipDate = Convert.ToDateTime(txtEstShipDate.Text);
                    obj.price = Convert.ToDecimal(txtPrice.Text);

                    //save
                    db.Orders.Add(obj);
                    db.SaveChanges();

                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/error.aspx");
            }
        }
Exemple #2
0
        //purchase product on btn click and save data to database
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            try
            {

                using (sales db = new sales())
                {
                    DateTime today = DateTime.Now;

                    Order obj = new Order();
                    obj.productID = Convert.ToInt32(ddlProduct.SelectedValue);
                    obj.qty = Convert.ToInt32(txtqty.Text);
                    obj.price = 10000.00m;
                    obj.shipDate = today;
                    obj.orderDate = today;
                    obj.tax = .11;

                    //save
                    db.Orders.Add(obj);
                    db.SaveChanges();

                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/error.aspx");
            }
        }