private void button4_Click(object sender, EventArgs e) { form.OpenConnection(); CupBoard cupBoard = form.GetCupBoard(form.connection, GetFkOrder()); int lockerNumber = cupBoard.GetLockerList().Count(); string colorExtrusion = cupBoard.GetExtrusion().GetColor(); string path = @"/Users/Fatine/source/DetailParts.txt"; using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine("DETAIL PARTS"); sw.WriteLine(" "); sw.WriteLine("there is in this order: 1 cupboard with " + lockerNumber + " locker(s)."); sw.WriteLine(" "); int i = 1; foreach (Locker locker in cupBoard.GetLockerList()) { sw.WriteLine("Locker n°" + i + " "); sw.WriteLine("Color: " + locker.GetColor() + " Price: " + locker.GetPrice(form.connection) + " euros"); sw.WriteLine(" Parts : "); foreach (Accessory access in locker.GetAccessoryList()) { string availability; if (access.GetInstock(form.connection) > 1) { availability = "available"; } else { availability = "not available"; } sw.WriteLine(" Type : " + access.GetAccessType() + " color : " + GetRealColor(access.GetColor()) + " dimensions : " + GetDimension(access.GetHeight(), access.GetWidth(), access.GetDepth()) + " price : " + access.GetPrice(form.connection) + " euros" + " " + availability); } sw.WriteLine(" "); i++; } Extrusion extrusion = cupBoard.GetExtrusion(); string availabilityC; if (extrusion.GetInstock(form.connection) > 1) { availabilityC = "available"; } else { availabilityC = "not available"; } sw.WriteLine("Corner "); sw.WriteLine("Color: " + colorExtrusion + " height : " + extrusion.GetHeight() + " Price : " + extrusion.GetPrice(form.connection) + " euros " + " " + availabilityC); sw.WriteLine(" "); sw.WriteLine("Total : " + cupBoard.GetPrice(form.connection) + " euros"); } form.CloseConnection(); }
public void CompleteLinkedTable() { CupBoard cupBoard = Form1.GetCupBoard(); foreach (Kitbox.Locker locker in cupBoard.GetLockerList()) { foreach (Accessory access in locker.GetAccessoryList()) { //Prendre les references de toutes les parts d'un locker MySqlDataReader reader; MySqlCommand command = new MySqlCommand("SELECT Idpart FROM `kitboxdb2.0`.`parts` WHERE ref='" + access.GetRefDB() + "'AND height='" + Convert.ToString(access.GetHeight()) + "'AND width='" + Convert.ToString(access.GetWidth()) + "'AND depth='" + Convert.ToString(access.GetDepth()) + "'AND color='" + access.GetColorDB(access.GetColor()) + "'", form.connection); reader = command.ExecuteReader(); string idPart = ""; if (reader.HasRows) { while (reader.Read()) { idPart = reader.GetString(0); } } else { MessageBox.Show("there is no idPart in the datareader"); } reader.Close(); //insérer les IDPARTS dans la table linked, ainsi on sait quel type de part est concerné pour chaque locker --> facile pour faire -1 MySqlCommand command2 = new MySqlCommand("INSERT INTO `kitboxdb2.0`.`linked` (FkkOrder, FkkLocker,`FkkPart`) VALUES ('" + order.GetIdOrder() + " ', '" + Convert.ToString(locker.GetID()) + "', '" + idPart + "');", form.connection); command2.ExecuteNonQuery(); } } //Ajout de extrusion dans linked : une seule fois Extrusion extrusion = cupBoard.GetExtrusion(); double extrusionHeight = 0; if (extrusion.IsCut(extrusion.GetHeight())) { extrusionHeight = extrusion.GetExistingTopHeight(extrusion.GetHeight()); } else { extrusionHeight = extrusion.GetHeight(); } string refcor = "Cornières"; MySqlDataReader reader3; MySqlCommand command3 = new MySqlCommand("SELECT Idpart FROM `kitboxdb2.0`.`parts` WHERE ref='" + refcor + "'AND height='" + Convert.ToString(extrusionHeight) + "'AND color='" + extrusion.GetColorDB(extrusion.GetColor()) + "'", form.connection); reader3 = command3.ExecuteReader(); string idCor = ""; if (reader3.HasRows) { while (reader3.Read()) { idCor = reader3.GetString(0); } } else { MessageBox.Show("there is no extrusion in the datareader"); } reader3.Close(); //prendre nptqel id de locker int fkkLocker = cupBoard.GetLockerList()[0].GetID(); MySqlCommand command4 = new MySqlCommand("INSERT INTO `kitboxdb2.0`.`linked` (FkkOrder, FkkLocker,`FkkPart`) VALUES ('" + order.GetIdOrder() + "', '" + fkkLocker + "', '" + idCor + "');", form.connection); command4.ExecuteNonQuery(); }