예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                OrderTable ot = new OrderTable
                {
                    Vehicle_Id     = int.Parse(textBox4.Text),
                    Customer_Id    = textBox1.Text,
                    Catagory       = textBox9.Text,
                    Brand_Name     = textBox8.Text,
                    Car_Model      = textBox2.Text,
                    Order_Quantity = int.Parse(textBox5.Text),
                    Price          = int.Parse(textBox6.Text),
                    Color          = textBox7.Text,
                    Order_Date     = dateTimePicker1.Text
                };
                c.OrderTables.InsertOnSubmit(ot);
                c.SubmitChanges();
                GridViewUpdate();

                var x = from a in c.VehicleInfos
                        where a.Id == int.Parse(textBox4.Text.ToString())
                        select a;
                int oq = int.Parse(textBox5.Text.ToString());
                int vq;
                int rslt;
                vq = x.First().Quantity;
                if ((vq > 0) && (oq < vq))
                {
                    rslt = vq - oq;
                    x.First().Quantity = rslt;
                    c.SubmitChanges();
                    GridViewUpdate();
                    MessageBox.Show("Your order has been placed in queue. Please be with us untill we contact with you");
                }
                else
                {
                    var z = from a in c.OrderTables
                            where a.Customer_Id == textBox1.Text
                            select a;
                    foreach (OrderTable vi in z)
                    {
                        c.OrderTables.DeleteOnSubmit(vi);
                    }
                    c.SubmitChanges();
                    GridViewUpdate();
                    MessageBox.Show(oq + " cars is not available right now");
                }
            }
            catch (Exception ex)
            {
                if (textBox5.Text == "" && textBox8.Text != "")
                {
                    MessageBox.Show("Please provide order quantity");
                }
                else
                {
                    MessageBox.Show("Please provide all the information correctly");
                }
            }
        }
예제 #2
0
 partial void UpdateOrderTable(OrderTable instance);
예제 #3
0
 partial void DeleteOrderTable(OrderTable instance);
예제 #4
0
 partial void InsertOrderTable(OrderTable instance);