private void gd_handler1(object sender, EventArgs e) { sender_parser sp = new sender_parser(); db_adapter db = new db_adapter(); DataTable dt = new DataTable(); int order_id = 0; string name_sender = sp.parse(sender.ToString()); dt = db.get_dish(); int sender_id = -1; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i].Field<string>("name") == name_sender) { sender_id = dt.Rows[i].Field<int>("id"); } } dt = db.get_dish_by_id(sender_id); os.orders.Last().check.quantity++; os.orders.Last().check.total_cost += dt.Rows[0].Field<int>("cost"); os.orders.Last().check.add_dish(sender_id); os.orders.Last().id = order_id; order_id++; this.f.Controls[3].Text += "\n"; this.f.Controls[3].Text += dt.Rows[0].Field<string>("name"); this.f.Controls[0].Text = os.orders.Last().check.total_cost.ToString(); this.f.Controls[2].Text += "\n"; this.f.Controls[2].Text += dt.Rows[0].Field<int>("cost"); this.f.Controls[0].Text = os.orders.Last().check.total_cost.ToString(); }
public dish(int arg_id) { db_adapter db = new db_adapter(); DataTable dt = db.get_dish_by_id(arg_id); name = dt.Rows[0].Field<string>("name"); id = dt.Rows[0].Field<int>("id"); cost = dt.Rows[0].Field<int>("cost"); }