private void bt_add_Click(object sender, RoutedEventArgs e) { KitTemplate kt = findkit(cb_addkit.SelectedItem.ToString()); List <Commande_DisplayItem> check = cdi_list.Where(x => x.KitName == kt.getName().ToString() + " " + kt.getProperties().ToString()).ToList(); if (check.Count() == 0) { cdi_list.Add(new Commande_DisplayItem( kt.getName().ToString() + " " + kt.getProperties().ToString(), BikeQuantity.Text + "x", ((float)(kt.getPrice() * int.Parse(BikeQuantity.Text)) / 100).ToString("c2"), kt.getPrice() * int.Parse(BikeQuantity.Text) ) ); } else { check[0].qnt = BikeQuantity.Text + "x"; check[0].price = ((float)(kt.getPrice() * int.Parse(BikeQuantity.Text)) / 100).ToString("c2"); check[0].intprice = kt.getPrice() * int.Parse(BikeQuantity.Text); } total.Text = (((float)totalCalcul() / 100)).ToString("c2"); kitList.ItemsSource = null; kitList.ItemsSource = cdi_list; }
private void bt_editCompatibleKit_Click(object sender, RoutedEventArgs e) { KitTemplate kt = ((KitTemplate.displayInfo)((System.Windows.Controls.Button)e.Source).DataContext).curKit; kit.modCompatibleKitWindow MCKW = new kit.modCompatibleKitWindow(kt); MCKW.ShowDialog(); //update the kits datagrid update_dg_kitList(); }
private void addKit(KitTemplate kt) { try { Controler.Instance.createKit(kt); tools.UI.MessageBox.Show("Kit added", "Action confirmation"); } catch { tools.UI.MessageBox.Show("An error has occured", "Error"); } }
public modCompatibleKitWindow(KitTemplate kt_) { InitializeComponent(); // initialise the windows kt = kt_; //display the kit data tb_kitName.Text = kt.getName(); set_lb_selectCompIt_content(); }
//--1--//Template Builder public static bool TemplateBuilder(this ApplicationContext db, string name) { //Here we add our new template after we determine our check. KitTemplate template = new KitTemplate(); if (db.CheckTemplateName(name)) { template.TemplateName = name; db.TPL_KitTemplates.Add(template); db.SaveChanges(); return(true); } return(false); }
private void BTADD_kit(object sender, RoutedEventArgs e) { //get the form data string kitName = kit_name.Text; string kitProp = kit_prop.Text; int kitCat = kit_cat.SelectedIndex; int kitPrice = Convert.ToInt32(kit_price.Text); int id = Controler.Instance.getLastKitTemplateId() + 1; int bike_qtt = Convert.ToInt32(kit_bike_qtt.Text); int[] locations = crtl.getNewLocation(); int stockLocactionX = locations[0]; int stockLocactionY = locations[1]; KitTemplate kt = new KitTemplate(id, kitName, (KitCategory)kitCat, kitPrice, kitProp, 0, stockLocactionX, stockLocactionY, bike_qtt); addKit(kt); this.Close(); }
private void bt_save_Click(object sender, RoutedEventArgs e) { List <Commande_item> Commande_itemList = new List <Commande_item>(); foreach (Commande_DisplayItem de in cdi_list) { KitTemplate kt = findkit(de.KitName); int qnt = int.Parse(de.qnt.Replace("x", "")); Commande_itemList.Add(new Commande_item(kt, qnt)); } int id = Controler.Instance.getlastCommandeId() + 1; Supplier sup = findSupplier(cb_supplier.SelectedItem.ToString()); User user = Controler.Instance.getCurrentUser(); Classes.Commande cmd = new Classes.Commande(id, user.getId(), sup.getId(), "Open", Today, DateTime.Now.AddDays(Properties.Settings.Default.Cmd_delay), Commande_itemList, Controler.Instance.getUserList(), Controler.Instance.getSupplierList()); Controler.Instance.Addcommande(cmd); this.Close(); }
public modKitWindow(KitTemplate kt_) { InitializeComponent(); kt = kt_; foreach (KitCategory i in Enum.GetValues(typeof(KitCategory))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Content = tools.Converter.GetCatName(i); cbi.Tag = i; kit_cat.Items.Add(cbi); } //display the user data tb_editName.Text = kt.getName(); tb_editProperties.Text = kt.getProperties(); tb_editPrice.Text = kt.getPrice().ToString(); kit_cat.SelectedIndex = (int)kt.getCategory(); tb_editBikeQtt.Text = kt.getBikeQtt().ToString(); }
public static List <Commande> getCommandes(List <KitTemplate> kitTemplatesList, List <User> userList, List <Supplier> clientList) { //get the user query and data from the database string query = DatabaseQuery.getCommande(); DataTable st = tools.Database.getData(query); //convert all the user into a user object List <Commande> temp = new List <Commande>(); for (int i = 0; i < st.Rows.Count; i++) { int id = Convert.ToInt32(st.Rows[i]["id"]); int id_client = Convert.ToInt32(st.Rows[i]["id_human"]); int id_seller = Convert.ToInt32(st.Rows[i]["id_seller"]); string state = (string)st.Rows[i]["state"]; DateTime prevision_date = DateTime.Today; //DateTime.Parse((string)dt.Rows[i]["date"]); DateTime date = DateTime.Today; //DateTime.Parse((string)dt.Rows[i]["date"]); List <Commande_item> ci_list = new List <Commande_item>(); //get commande items string q = DatabaseQuery.getCommandeItems(id); DataTable cmdit_dt = Database.getData(q); for (int j = 0; j < cmdit_dt.Rows.Count; j++) { int id_kit = Convert.ToInt32(cmdit_dt.Rows[j]["id_type_kit"]); int qnt = Convert.ToInt32(cmdit_dt.Rows[j]["qnt"]); KitTemplate kt = kitTemplatesList.Where(x => x.getId() == id_kit).ToList()[0]; Commande_item ci = new Commande_item(kt, qnt); ci_list.Add(ci); } temp.Add(new Commande(id, id_seller, id_client, state, date, prevision_date, ci_list, userList, clientList)); } return(temp); }
public static string link_kit_to_tbike(BikeTemplate bt, KitTemplate kt) { return("INSERT INTO `bv_templatebikekit` (`id_tBike`, `id_tKit`) VALUES (" + bt.getId() + ", " + kt.getId() + ")"); }
public static int updateKitTemplate(KitTemplate kt) { string q = DatabaseQuery.updateKitTemplate(kt.getId(), kt.getName(), (int)kt.getCategory(), kt.getPrice(), kt.getProperties(), kt.getStockQtt(), kt.getStockLocationX(), kt.getStockLocationY(), kt.getBikeQtt()); return(Database.setData(q)); }
public static int unlinkKTCB(CatalogBike cb, KitTemplate kt) { string q = DatabaseQuery.delCompatibleKit(cb.getId(), kt.getId()); return(Database.setData(q)); }
private KitTemplate findkit(string k_name) { KitTemplate k = Controler.Instance.getKitTemplateList().Find(x => (x.getName() + " " + x.getProperties()) == k_name); return(k); }
public static int link_kit_to_tbike(BikeTemplate bt, KitTemplate kt) { string q = tools.DatabaseQuery.link_kit_to_tbike(bt, kt); return(Database.setData(q)); }