private void addItem(string name, int priceMul) { int id = Controler.Instance.getlastCatalogBikeId() + 1; string pic_filename = "Bike0.jpg"; CatalogBike cb = new CatalogBike(id, name, priceMul, pic_filename); Controler.Instance.createCatalogBike(cb); }
private void bt_editItem_Click(object sender, RoutedEventArgs e) { //get witch row we clicked on CatalogBike kt = ((CatalogBike.displayInfo)((System.Windows.Controls.Button)e.Source).DataContext).CurCatBike; //open the dialog passing the item ID item.modItemWindow MUW = new item.modItemWindow(kt); MUW.ShowDialog(); //update the item datagrid update_dg_itemList(); }
private void bt_editCompKit_Click(object sender, RoutedEventArgs e) { //get witch row we clicked on CatalogBike cb = ((CatalogBike.displayInfo)((System.Windows.Controls.Button)e.Source).DataContext).CurCatBike; item.modCompatibleItemWindow MCIW = new item.modCompatibleItemWindow(cb); MCIW.ShowDialog(); //update the kits datagrid update_dg_itemList(); }
public modCompatibleItemWindow(CatalogBike bc_) { InitializeComponent(); // initialise the windows bc = bc_; //display the kit data tb_BikeName.Text = bc.getName(); tb_title.Text = "Edit compatible kits with " + bc.getName() + "bike"; set_dg_selCompatibleKit_content(); }
public modItemWindow(CatalogBike kt_) { InitializeComponent(); //initialize the windows kt = kt_; //diplay the item data tb_newItemName.Text = kt.getName(); sl_pricemul.Value = kt.getPriceMul(); lb_pricemul.Content = "Price " + (sl_pricemul.Value / 100).ToString("P"); }
private void BT_Add_Click(object sender, RoutedEventArgs e) { int qnt = Convert.ToInt32(BikeQuantity.Text); string b_name = ((CatalogBike.displayInfo)BikeCatalog.SelectedItem).name; string b_color = BikeColor.SelectedItem.ToString(); string b_size = BikeSize.SelectedItem.ToString(); CatalogBike cb = ((CatalogBike.displayInfo)BikeCatalog.SelectedItem).CurCatBike; BikeBasket bb = new BikeBasket(b_name, b_color, b_size, cb, qnt); BikeTemplate bt = bb.CreateBikeTemplate(); if (bt.getId() == -1) { int id_bt = Controler.Instance.getLastBikeTemplateId() + 1; bt.setId(id_bt); Controler.Instance.createBikeTemplate(bt); } for (int i = 0; i < bb.qnt; i++) { int bikeID = Controler.Instance.getLastBikeId() + 1; DateTime constr_date = TempSale.getConstrDate(); DateTime planned_date = TempSale.getNextPrevisionDate(); int poste = Controler.Instance.getAvailablePoste(); Bike tempB = new Bike(bikeID, 0, -1, poste, bt, planned_date, constr_date); Controler.Instance.createBike(tempB); } this.Close(); }
public static List <CatalogBike> getCatalogBikes(List <KitTemplate> ktList) { string q = DatabaseQuery.getCatalogBike(); DataTable dt = Database.getData(q); //convert all the user into a user object List <CatalogBike> temp = new List <CatalogBike>(); for (int i = 0; i < dt.Rows.Count; i++) { int id = Convert.ToInt32(dt.Rows[i]["id"]); string name = (string)dt.Rows[i]["name"]; int PriceMul = Convert.ToInt32(dt.Rows[i]["PriceMul"]); string pic_filename = (string)dt.Rows[i]["picture"]; string query = DatabaseQuery.getKit_by_catalogBikeId(id); DataTable kdt = Database.getData(query); CatalogBike cb = new CatalogBike(id, name, PriceMul, pic_filename); for (int j = 0; j < kdt.Rows.Count; j++) { foreach (KitTemplate kt in ktList) { if (kt.getId() == Convert.ToInt32(kdt.Rows[j]["id_tKit"])) { cb.linkKitTemplate(kt); } } } temp.Add(cb); } return(temp); }
private void BT_update_Click(object sender, RoutedEventArgs e) { //get the list of all bike List <selectedBike> listCBike = (List <selectedBike>)lb_selectCompBike.ItemsSource; foreach (selectedBike scb in listCBike) { CatalogBike cb = scb.curCBike; //check if checked or not if (scb.itemChecked == true) //we want the kit //we do not have the kit (do nothing if already here { if (!cb.getKitTemplateList().Contains(kt)) { cb.linkKitTemplate(kt); tools.DatabaseClassInterface.linkKTCB(cb, kt); } } else //we don't want the kit //we have the kit -> we need to remove it (if not do nothing) { if (cb.getKitTemplateList().Contains(kt)) { cb.unlinkKitTemplate(kt); tools.DatabaseClassInterface.unlinkKTCB(cb, kt); } } } tools.UI.MessageBox.Show("Updated", "Action confirmation"); this.Close(); }
public static string updateCatalogBike(CatalogBike kt) { return("UPDATE `bv_catalog` SET `name` = '" + kt.getName() + "' , `PriceMul` = '" + kt.getPriceMul().ToString() + "' WHERE `id` = " + kt.getId().ToString()); }
public static string addCatalogBike(CatalogBike cb) { return("INSERT INTO `bv_catalog` (`id`,`name`,`PriceMul`,`picture`) VALUES (" + cb.getId().ToString() + ",'" + cb.getName() + "'," + cb.getPriceMul().ToString() + ", 'Bike0.jpg')"); }
private void setCombobox(CatalogBike cb) { (BikeSize.ItemsSource, BikeColor.ItemsSource) = cb.getProperties(); }
public static int addCatalogBike(CatalogBike cb) { string q = DatabaseQuery.addCatalogBike(cb); return(Database.setData(q)); }
public static int unlinkKTCB(CatalogBike cb, KitTemplate kt) { string q = DatabaseQuery.delCompatibleKit(cb.getId(), kt.getId()); return(Database.setData(q)); }
public static int updateCatalogBike(CatalogBike kt) { string q = DatabaseQuery.updateCatalogBike(kt); return(Database.setData(q)); }