private void M_previeworder_Click(object sender, EventArgs e) { if (order.CurrentClient != null) { wardrobe.Book(true); DbOrder.DbAddOrder(order); button22_Click(sender, e); tabControl1.SelectTab(0); } else { tabControl1.SelectTab(0); } }
private void M_previeworder_Click(object sender, EventArgs e) { if (order.CurrentClient != null) { wardrobe.Book(true); DbOrder.DbAddOrder(order); order = new Order(); wardrobe = new Wardrobe(new Size3D(120, 36, 42)); order.Wardrobes.Add(wardrobe); player_modif = false; M_selectwardrobe.Text = Convert.ToString(0); Preset(); tabControl1.SelectTab(2); } else { tabControl1.SelectTab(1); } }
public Dictionary <string, object> GetBill(int order_id) { List <List <object> > list = new List <List <object> >(); string RelTableName = "rel_Cat_Ord"; string OrderTableName = "orders"; string columnNames; string condition = string.Format("WHERE (Order_Id = {0})", order_id); double total_price = 0; bill["Header"] = DbOrder.DbSearchOrder(OrderTableName, "Header_Bill", string.Format("WHERE (Order_Id = {0} AND Client_Id = {1})", order_id, current_client)); columnNames = "DISTINCT Wardrobe_Id"; list = DbOrder.DbSearchOrder(RelTableName, columnNames, condition); for (int i = 1; i <= list.Count; i++) { bill["Components"] += string.Format("Wardrobe {0} :\n\t", i); columnNames = "DISTINCT Box_Id"; condition = string.Format("WHERE (Order_Id = {0} AND Wardrobe_Id = {1})", order_id, i); list = DbOrder.DbSearchOrder(RelTableName, columnNames, condition); for (int j = 1; j <= list.Count; j++) { bill["Components"] += string.Format("Box {0} :\n\t\t", i); columnNames = "Component_Id"; condition = string.Format("WHERE (Order_Id = {0} AND Wardrobe_Id = {1} AND Box_Id = {2})", order_id, i, j); list = DbOrder.DbSearchOrder(RelTableName, columnNames, condition); for (int k = 1; k <= list.Count; k++) { //condition = Convert.ToString(list[k-1][0]); columnNames = "Réf, Code, Dimensions, Couleur, hauteur, profondeur, largeur, Prix-Client"; condition = string.Format("WHERE Component_Id = {0}", Convert.ToString(list[k - 1][0])); list = DbOrder.DbSearchOrder(OrderTableName, columnNames, condition); foreach (List <object> component in list) { for (int spec_nbr = 0; spec_nbr < list.Count; spec_nbr++) { // In case it is the price if (spec_nbr == list.Count - 1) { bill["Components"] += string.Format("{0} €", list[spec_nbr]); total_price += Convert.ToDouble(component[spec_nbr]); } else if (spec_nbr == 0) { bill["Components"] += string.Format("\n\t\t{0}", component[spec_nbr]); } else { bill["Components"] += string.Format("{0} \t", component[spec_nbr]); } } } } } } bill["Header"] += String.Format("\n\nPrix total : {0} €", Convert.ToString(total_price)); bill["Footer"] = DbOrder.DbSearchOrder(OrderTableName, "Footer_Bill", string.Format("WHERE (Order_Id = {0} AND Client_Id = {1})", order_id, current_client)); return(bill); }
/// <summary> /// Returns a dictionnary containing all the information about an order /// </summary> /// <returns>The bill.</returns> /// <param name="order_id">Order identifier.</param> public Dictionary <string, object> GetBill(int order_id) { bill = new Dictionary <string, object>(); Dictionary <string, Dictionary <string, List <object> > > components = new Dictionary <string, Dictionary <string, List <object> > >(); int wardrobes = components.Count; List <List <object> > list = new List <List <object> >(); string RelTableName = "rel_catord"; string OrderTableName = "orders"; string catalog_table_name = "catalog"; string columnNames; string condition = string.Format("WHERE (Order_Id = '{0}')", order_id); list = DbOrder.DbSearchOrder(OrderTableName, "Header_Bill", string.Format("WHERE (Order_Id ='{0}' AND Client_Id ='{1}')", order_id, current_client.Id)); bill.Add("Header", list[0][0]); columnNames = "DISTINCT Wardrobe_Id"; // List of the wardrobe Id's List <List <object> > list1 = DbOrder.DbSearchOrder(RelTableName, columnNames, condition); bill.Add("Components", new Dictionary <string, Dictionary <string, List <object> > >()); // Choose a wardrobe for (int i = 1; i <= list1.Count; i++) { columnNames = "DISTINCT Box_Id"; condition = string.Format("WHERE (Order_Id = '{0}' AND Wardrobe_Id = '{1}')", order_id, i); // Add the wardrobe as a dictionnary key if it doesn't already exist if (!components.ContainsKey(String.Format("Wardrobe{0}", i))) { components.Add(String.Format("Wardrobe{0}", i), new Dictionary <string, List <object> >()); } // Read all the Box_Id's of the database for this wardrobe and this order id List <List <object> > list2 = DbOrder.DbSearchOrder(RelTableName, columnNames, condition); // Choose a box for (int j = 1; j <= list2.Count; j++) { columnNames = "Component_Id"; condition = string.Format("WHERE (Order_Id = '{0}' AND Wardrobe_Id = '{1}' AND Box_Id = '{2}')", order_id, i, j - 1); List <List <object> > list3 = DbOrder.DbSearchOrder(RelTableName, columnNames, condition); // Choose a component(part) of the box for (int k = 1; k <= list3.Count; k++) { columnNames = "Ref, Code, Dimensionscm, Couleur, hauteur, profondeur, largeur, PrixClient"; condition = string.Format("WHERE Id = '{0}'", Convert.ToString(list3[k - 1][0])); // Read all the specifications of a component in the database List <List <object> > list4 = DbOrder.DbSearchOrder(catalog_table_name, columnNames, condition); // Choose the specifications of the component foreach (List <object> component in list4) { if (!components[String.Format("Wardrobe{0}", i)].ContainsKey(Convert.ToString(component[1]))) { components[String.Format("Wardrobe{0}", i)].Add(Convert.ToString(component[1]), new List <object>()); List <object> component_code = components[String.Format("Wardrobe{0}", i)][Convert.ToString(component[1])]; //Quantity component_code.Add(1); //Price component_code.Add(component[7]); //Reference component_code.Add(component[0]); //Dimensions component_code.Add(component[2]); //Colour component_code.Add(component[3]); //Height component_code.Add(component[4]); //Depth component_code.Add(component[5]); //Width component_code.Add(component[6]); } // In case the component is already in the dictionnary, we only increment the quantity else { List <object> component_code = components[String.Format("Wardrobe{0}", i)][Convert.ToString(component[1])]; int number = (int)component_code[0]; number += 1; component_code[0] = number; } } } } } bill["Components"] = components; bill["Footer"] = DbOrder.DbSearchOrder(OrderTableName, "Footer_Bill", string.Format("WHERE (Order_Id = '{0}' AND Client_Id = '{1}')", order_id, current_client.Id))[0][0]; return(bill); }