public Beam(int len, int qty) : base(len, qty) { length = len; quantity = qty; if (beamNum == 2) { beamNum = 0; } // Getting stock reference by dimension switch (qty) { case 2: stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'TRR%' AND largeur = " + len.ToString()); break; case 4: stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'TRG%' AND profondeur = " + len.ToString()); break; } beamNum++; beamNumber = beamNum; // Update reservation in the data base Oledb.UpdateReservation(quantity, stockRef); SetPrice(); stock = Oledb.GetDBStock(stockRef); }
private void button3_Click(object sender, EventArgs e) //Delete the object selected { string q = "delete from Piece where PK_Piece=" + IdList.SelectedItem.ToString(); Oledb.SqlRequestInsert(q); Loaddata(); }
private void DeleteButton_Click(object sender, EventArgs e) // Delete the command from the Db { string q = "delete from Commande where PK_Commande=" + IdOrderList.SelectedItem.ToString(); Oledb.SqlRequest(q); Loaddata(); }
public DoorBeam(int len, int qty) : base(len, qty) { // Getting the stock reference by the length stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'TRF%' AND largeur = " + len.ToString()); // Updating the reservation in the data base Oledb.UpdateReservation(quantity, stockRef); SetPrice(); SetStock(); }
public Cleat(int len, int qty) : base(len, qty) { // Getting the stock reference by the length stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'TAS%' AND hauteur LIKE '" + len.ToString() + "'"); SetPrice(); SetStock(); // Updating the reservation in the data base Oledb.UpdateReservation(quantity, stockRef); }
private void button1_Click(object sender, EventArgs e) //Update button for the stock { if (StockTextBox.Text != "" & IdList.SelectedIndex != -1) { string q = "update Piece set Enstock='" + StockTextBox.Text.ToString() + "' where PK_Piece=" + IdList.SelectedItem.ToString(); Oledb.SqlRequestInsert(q); Loaddata(); StockTextBox.Text = ""; } }
private void button2_Click(object sender, EventArgs e) //Update button for the price { if (PriceClientTextBox.Text != "" & IdList.SelectedIndex != -1) { string q = "update Piece set PrixClient=" + PriceClientTextBox.Text.ToString() + " where PK_Piece=" + IdList.SelectedItem.ToString(); Oledb.SqlRequestInsert(q); Loaddata(); PriceClientTextBox.Text = ""; } }
private void addzip_Click(object sender, EventArgs e) //Add a new zip code into the DB { string rsq = "INSERT INTO CodePostal (CodePostal,Commune) VALUES ('" + ZipBox.Text.ToString() + "','" + CityBox.Text.ToString() + "')"; Oledb.SqlRequestInsert(rsq); Loaddata(); ZipBox.Text = ""; CityBox.Text = ""; MessageBox.Show("Congrats! You added a new zip"); }
private void addzip_Click(object sender, EventArgs e) //Complete and reset the form for the zip code { string rsq = "INSERT INTO CodePostal (CodePostal,Commune) VALUES ('" + ZipBox.Text.ToString() + "','" + CityBox.Text.ToString() + "')"; Oledb.SqlRequestInsert(rsq); Loaddata(); //Reset of every box ZipBox.Text = ""; CityBox.Text = ""; MessageBox.Show("Congrats! You added a new Zip Code"); }
public Knop(int qty) { // Getting stock reference for the knop stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'COUP%' "); // Getting knop's price price = Oledb.GetDBPrice(stockRef); stock = Oledb.GetDBStock(stockRef); quantity = qty; // Update reservation in the data base Oledb.UpdateReservation(quantity, stockRef); }
public Angle(int len, string color, int qty) { Oledb.Connection(); length = len; angleColor = color; // Getting the stock reference by the length and color stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'COR%' AND hauteur = " + length.ToString() + " AND Couleur = '" + angleColor + "'"); quantity = qty; CalculPrice(); // Updating the reservation in the data base Oledb.UpdateReservation(quantity, stockRef); stock = Oledb.GetDBStock(stockRef); }
public DoubleDoors(string doormat, int hei, int len) : base(len, hei - 4) { TheDoorMat = doormat; // Getting the stock reference by dimension and color/material stockRef = Oledb.SqlRequest("SELECT Référence FROM Piece WHERE Référence LIKE 'POR%' AND largeur LIKE '" + length.ToString() + "' AND hauteur LIKE '" + height.ToString() + "' AND Couleur LIKE '" + doormat + "'"); knops = new Knop(2); price = Oledb.GetDBPrice(stockRef); // Update the reservation in the data base Oledb.UpdateReservation(2, stockRef); SetPrice(); SetStock(); }
private void finishButton_Click(object sender, EventArgs e) //Add a new product into the DB { string rsq = "INSERT INTO Req (Référence,Enstock,StockMinimum," + "PrixClient,Nb_PiecesCasier,Dimensions_cm,Division," + "hauteur,profondeur,largeur,Reservation,Code,Couleur," + "Prix,Delai,FK_Fournisseur) VALUES ('" + referenceTextBox.Text.ToString() + "','" + InitialStockNum.Text.ToString() + "','" + MinimumStockNum.Text.ToString() + "','" + clientPriceTextBox.Text.ToString() + "','" + numberPerBoxNum.Text.ToString() + "','" + DimensionsTextBox.Text.ToString() + "','" + divisionTextBox.Text.ToString() + "','" + HeigthTextBox.Text.ToString() + "','" + depthTextBox.Text.ToString() + "','" + widthTextBox.Text.ToString() + "','0','" + codeTextBox.Text.ToString() + "','" + colorTextBox.Text.ToString() + "','" + SupplierBox.Text.ToString() + "','" + supplierPriceTextBox.Text.ToString() + "','" + delayNum.Text.ToString() + "')"; Oledb.SqlRequestInsert(rsq); MessageBox.Show("Congrats! You added a new product"); //Reset of every box referenceTextBox.Text = ""; InitialStockNum.Value = 0; MinimumStockNum.Value = 0; clientPriceTextBox.Text = ""; numberPerBoxNum.Value = 0; DimensionsTextBox.Text = ""; divisionTextBox.Text = ""; HeigthTextBox.Text = ""; depthTextBox.Text = ""; widthTextBox.Text = ""; codeTextBox.Text = ""; colorTextBox.Text = ""; SupplierBox.Text = ""; supplierPriceTextBox.Text = ""; delayNum.Value = 0; }
private void finishButton_Click(object sender, EventArgs e) //Add a new supplier into the Db { string rsq = "INSERT INTO Fournisseur (Référence,Nom,Rue,Numero,FK_CodePostal) VALUES ('" + RefTextBox.Text.ToString() + "','" + NameTextBox.Text.ToString() + "','" + StreetTextBox.Text.ToString() + "','" + NumbertextBox.Text.ToString() + "','" + ZipTextBox.Text.ToString() + "')"; Oledb.SqlRequestInsert(rsq); Loaddata(); //Reset all the box RefTextBox.Text = ""; NameTextBox.Text = ""; StreetTextBox.Text = ""; NumbertextBox.Text = ""; ZipTextBox.Text = ""; MessageBox.Show("Congrats! You added a new supplier"); }
// Add an angle with non-standard dimension public void AddScratchAngles(string color) { List <string> possibleLength = Oledb.LoadForDistinct("SELECT DISTINCT hauteur FROM Piece WHERE Référence LIKE 'COR%DEC'"); var closest = int.MaxValue; var minDifference = int.MaxValue; // Finding the first dimension available above the cabinet's height foreach (var element in possibleLength) { int elem = int.Parse(element); var difference = Math.Abs((long)elem - cabinetHeight); if (minDifference > difference) { if (elem > cabinetHeight) { minDifference = (int)difference; closest = elem; } } } angles = new Angle(closest, color, 4); }
private void finishButton_Click(object sender, EventArgs e) //Complete and reset the form for the client { string rsq = "INSERT INTO Client (Nom,Email,Rue,Numero,Telephone,FK_CodePostal) VALUES ('" + NameTextBox.Text.ToString() + "','" + MailTextBox.Text.ToString() + "','" + StreetTextBox.Text.ToString() + "','" + NumbertextBox.Text.ToString() + "','" + PhoneNumberBox.Text.ToString() + "','" + ZipTextBox.Text.ToString() + "')"; Oledb.SqlRequestInsert(rsq); Loaddata(); //Reset of every box MailTextBox.Text = ""; NameTextBox.Text = ""; StreetTextBox.Text = ""; NumbertextBox.Text = ""; PhoneNumberBox.Text = ""; ZipTextBox.Text = ""; MessageBox.Show("Congrats! You added a new Client"); }
protected void SetStock() { stock = Oledb.GetDBStock(stockRef); }
protected void SetPrice() { price = Oledb.GetDBPrice(stockRef); }
private void Form1_Load(object sender, EventArgs e) //Connection to the DB and loading the data into the box { Oledb.Connection(); Loaddata(); }
private void CompleteButton_Click(object sender, EventArgs e) // Complete an order by the update of the Reservation and the Enstock into the Db { if (DeliverTextBox.Text != "" & IdOrderList.SelectedIndex != -1) { string q = "update Commande set Date_Livraison='" + DeliverTextBox.Text.ToString() + "', Status = 'Complete' where PK_Commande=" + IdOrderList.SelectedItem.ToString(); Oledb.SqlRequest(q); string j = "select ListeMateriel from Commande where PK_Commande=" + IdOrderList.SelectedItem.ToString(); string json = Oledb.SqlRequest(j); //Regex for the reading of the Json Regex rgx = new Regex(@"\[StockRef,", RegexOptions.IgnoreCase); Regex rgx2 = new Regex(@"[A-Z]{3}[0-9]{2,}[A-Z]{0,}|COUPEL", RegexOptions.IgnoreCase); Regex rgx3 = new Regex(@"\[Quantity,", RegexOptions.IgnoreCase); Regex rgx4 = new Regex(@"[0-9]{1,}", RegexOptions.IgnoreCase); Regex rgx5 = new Regex(@"\[Qty,", RegexOptions.IgnoreCase); Regex rgx6 = new Regex(@"\[Stockref,", RegexOptions.IgnoreCase); JObject jsonData = JObject.Parse(json); foreach (var Liste in jsonData) { try { JObject Cabinet = (JObject)Liste.Value; foreach (var Floor in Cabinet) { //Loop for the cabinet and the price try { JObject objects = (JObject)Floor.Value; foreach (var pieces in objects) { //Loop for the Angles try { if (rgx.IsMatch(pieces.ToString()) && Quantity == -1 && StockRef == null) //match stockref and register the value { Match match = rgx2.Match(pieces.ToString()); StockRef = match.Value; } if (rgx3.IsMatch(pieces.ToString()) && StockRef != null && Quantity == -1) //match qty and modify the values into the database { Match match = rgx4.Match(pieces.ToString()); Quantity = int.Parse(match.Value); //Register the value of the Reservation string reservesql = "select Reservation from Piece where Référence='" + StockRef + "'"; int reserve = int.Parse(Oledb.SqlRequest(reservesql)); //Register the value of the Enstock string stocksql = "select PK_Piece from Piece where Référence='" + StockRef + "'"; int stock = int.Parse(Oledb.SqlRequest(stocksql)); int final_reserve = reserve - Quantity; int final_stock = stock - Quantity; // Update the Reservation and the Enstock string update_Piece = "Update Piece set Enstock='" + final_stock.ToString() + "', Reservation='" + final_reserve.ToString() + "' where Référence='" + StockRef + "'"; Oledb.SqlRequest(update_Piece); StockRef = null; Quantity = -1; } JObject piece = (JObject)pieces.Value; foreach (var minis in piece) { //Loop for the major of the caracteristics try { if (rgx6.IsMatch(minis.ToString()) && Quantity == -1 && StockRef == null) //match stockref and register the value { Match match = rgx2.Match(minis.ToString()); StockRef = match.Value; } if (rgx5.IsMatch(minis.ToString()) && StockRef != null && Quantity == -1) //match qty and modify the values into the database { Match match = rgx4.Match(minis.ToString()); Quantity = int.Parse(match.Value); //Register the value of the Reservation string reservesql = "select Reservation from Piece where Référence='" + StockRef + "'"; int reserve = int.Parse(Oledb.SqlRequest(reservesql)); //Register the value of the Enstock string stocksql = "select Enstock from Piece where Référence='" + StockRef + "'"; int stock = int.Parse(Oledb.SqlRequest(stocksql)); int final_reserve = reserve - Quantity; int final_stock = stock - Quantity; //Update the Reservation and the Enstock string update_Piece = "Update Piece set Enstock='" + final_stock.ToString() + "', Reservation='" + final_reserve.ToString() + "' where Référence='" + StockRef + "'"; Oledb.SqlRequest(update_Piece); StockRef = null; Quantity = -1; } JObject mini = (JObject)minis.Value; foreach (var coupelle in mini) { //Loop for the Coupelle if (rgx.IsMatch(coupelle.ToString()) && Quantity1 == -1 && StockRef1 == null) //match stockref and register the value { Match match = rgx2.Match(coupelle.ToString()); StockRef1 = match.Value; } if (rgx3.IsMatch(coupelle.ToString()) && StockRef1 != null && Quantity1 == -1) { Match match = rgx4.Match(coupelle.ToString()); Quantity1 = int.Parse(match.Value); //Register the value of the Reservation string reservesql = "select Reservation from Piece where Référence='" + StockRef1 + "'"; int reserve = int.Parse(Oledb.SqlRequest(reservesql)); //Register the value of the Enstock string stocksql = "select Enstock from Piece where Référence='" + StockRef1 + "'"; int stock = int.Parse(Oledb.SqlRequest(stocksql)); int final_reserve = reserve - Quantity1; int final_stock = stock - Quantity1; // Update the Reservation and the Enstock string update_Piece = "Update Piece set Enstock='" + final_stock.ToString() + "', Reservation='" + final_reserve.ToString() + "' where Référence='" + StockRef1 + "'"; Oledb.SqlRequest(update_Piece); StockRef1 = null; Quantity1 = -1; } } } catch { } } } catch { } } } catch { } } } catch { } } Loaddata(); DeliverTextBox.Text = ""; } }
private void CalculPrice() { price = Oledb.GetDBPrice(stockRef); }
private void LoadList(object sender, EventArgs e) //loading data { Oledb.Connection(); Loaddata(); }