protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            var         db          = new QCDBMLDataContext();
            food_master sel_food    = db.food_masters.Single(food_master => food_master.name.Equals(Label1.Text));
            int         sel_food_id = sel_food.food_item_id;
            menu_master menu        = (from sel_menu in db.menu_masters
                                       where sel_menu.canteen_id == (int)Session["can_id"] &&
                                       sel_menu.food_item_id == sel_food_id
                                       select sel_menu).FirstOrDefault();

            if (Int32.Parse(TextBox1.Text) > menu.qty)
            {
                Label2.Text = "Reduce your quantity or select a new food item";
            }
        }
        protected void Button6_Click(object sender, EventArgs e)
        {
            int            rate;
            var            db            = new QCDBMLDataContext();
            int            pending_order = db.order_headers.Count(order_header => order_header.canteen_id == (int)Session["can_id"] && order_header.status == "placed");
            canteen_master canteen       = db.canteen_masters.Single(canteen_master => canteen_master.canteen_id == (int)Session["can_id"]);

            if (canteen.order_limit <= pending_order)
            {
                Label4.Text = "Canteen is overcrowded. Please order after a few minutes";
            }
            else
            {
                student_master student    = db.student_masters.Single(student_master => student_master.id == (int)Session["id"]);
                long           stu_wallet = (long)student.wallet;
                if (((int)Session["tot_amt"]) > stu_wallet)
                {
                    Label4.Text = "You dont have enough money in your wallet";
                }
                else
                {
                    student.wallet -= (int)Session["tot_amt"];
                    db.SubmitChanges();
                    canteen_master sel_canteen = db.canteen_masters.Single(canteen_master => canteen_master.canteen_id == (int)Session["can_id"]);
                    sel_canteen.wallet += (int)Session["tot_amt"];
                    db.SubmitChanges();
                    order_header neworder = new order_header();
                    neworder.stu_id     = (int)Session["id"];
                    neworder.canteen_id = (int)Session["can_id"];
                    neworder.order_date = DateTime.Now;
                    DateTime temp_date = (DateTime)neworder.order_date;
                    neworder.amount = (int)Session["tot_amt"];
                    neworder.status = "placed";
                    db.order_headers.InsertOnSubmit(neworder);
                    db.SubmitChanges();
                    order_header oh  = db.order_headers.Single(order_header => order_header.order_date.Equals(temp_date));
                    int          oid = oh.order_id;
                    foreach (GridViewRow gv2row in GridView2.Rows)
                    {
                        order_detail neworderdet = new order_detail();
                        neworderdet.order_id = oid;
                        food_master sel_food    = db.food_masters.Single(food_master => food_master.name.Equals(gv2row.Cells[1].Text));
                        int         sel_food_id = sel_food.food_item_id;
                        neworderdet.food_item_id = sel_food_id;
                        foreach (GridViewRow gvrow in GridView1.Rows)
                        {
                            if (gvrow.Cells[1].Text.Equals(gv2row.Cells[1].Text))
                            {
                                rate             = Int32.Parse(gvrow.Cells[3].Text);
                                neworderdet.rate = rate;
                                neworderdet.qty  = Int32.Parse(gv2row.Cells[2].Text);
                                break;
                            }
                        }
                        db.order_details.InsertOnSubmit(neworderdet);
                        menu_master menu = db.menu_masters.Single(menu_master => menu_master.canteen_id == neworder.canteen_id && menu_master.food_item_id == neworderdet.food_item_id);
                        menu.qty -= neworderdet.qty;
                        db.SubmitChanges();
                    }
                }
            }
            DropDownList1_SelectedIndexChanged(sender, e);
        }
Esempio n. 3
0
 private void detach_menu_masters(menu_master entity)
 {
     this.SendPropertyChanging();
     entity.food_master = null;
 }
Esempio n. 4
0
 partial void Deletemenu_master(menu_master instance);
Esempio n. 5
0
 partial void Updatemenu_master(menu_master instance);
Esempio n. 6
0
 partial void Insertmenu_master(menu_master instance);