private void BTConfirmer_Click(object sender, RoutedEventArgs e) { if (ChampVide()) { Afficher_Msg_Erreur("Erreur : champ(s) vide(s)"); } else { BonProduction adminx = new BonProduction(0, Int16.Parse(TBIdArticle.Text), Int16.Parse(TBIdAtelier.Text), Int16.Parse(TBNbArticle.Text), TBDateDepart.Text, TBDateFin.Text, Int16.Parse(TBCout.Text)); int res = fsg_gpao.Connecteurs.BonProductionC.AjouterBon(adminx); if (res == 1) { Afficher_Msg_Confirmation("Le bon est bien ajouter"); try { DateTime localDate = DateTime.Now; fsg_gpao.Acteurs.JournalArticle journal = new fsg_gpao.Acteurs.JournalArticle(idCourant, adminx.ID, localDate.ToString("F"), "Création du nouveau bon de commande : " + adminx.ID, ""); fsg_gpao.Connecteurs.JournalArticleC.ajouterJournal(journal); } catch (Exception ex) { } } else { Afficher_Msg_Erreur("Erreur de connexion à la base de données!"); } cacherGroupeB(); cacherGroupeB(); } }
private void DataGridBonProd_MouseUp(object sender, MouseButtonEventArgs e) { object item = DataGridBonProd.SelectedItem; try { TBId.Text = (DataGridBonProd.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text; if (!TBIdBon.Text.Equals("") && (BonProductionC.IdExiste(Int16.Parse(TBIdBon.Text)) > 0)) { BonProduction bonTemp = BonProductionC.GetAllFactures(Int16.Parse(TBIdBon.Text)); TBIdArticle.Text = bonTemp.IDARTICLE + ""; TBNbArticle.Text = bonTemp.NBARTICLE + ""; TBDateDepart.Text = bonTemp.DATEDEPART + ""; TBCout.Text = bonTemp.COUT + ""; TBIdBon.Text = (DataGridBonProd.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text; listeClasseurProduit = ClasseurProduitC.GetAllClasseur("idFactureProduction", TBIdBon.Text); LoadAllProduitTemp(); } else { Afficher_Msg_Erreur("Veuillez saisir un identifiant valide"); } } catch (Exception exp) { } }
private void TBIdClient_KeyUp(object sender, KeyEventArgs e) { TextBox textBox = sender as TextBox; Int32 selectionStart = textBox.SelectionStart; Int32 selectionLength = textBox.SelectionLength; String newText = String.Empty; int count = 0; foreach (Char c in textBox.Text.ToCharArray()) { if (Char.IsDigit(c) || Char.IsControl(c) || (c == '.' && count == 0)) { newText += c; if (c == '.') { count += 1; } } } TBIdBon.Text = newText; if (!TBIdBon.Text.Equals("") && (BonProductionC.IdExiste(Int16.Parse(TBIdBon.Text)) > 0)) { BonProduction bonTemp = BonProductionC.GetAllFactures(Int16.Parse(TBIdBon.Text)); TBIdArticle.Text = bonTemp.IDARTICLE + ""; TBNbArticle.Text = bonTemp.NBARTICLE + ""; TBDateDepart.Text = bonTemp.DATEDEPART + ""; TBCout.Text = bonTemp.COUT + ""; listeClasseurProduit = ClasseurProduitC.GetAllClasseur("idFactureProduction", TBIdBon.Text); LoadAllProduitTemp(); } else { Afficher_Msg_Erreur("Veuillez saisir un identifiant valide"); } }
public static BonProduction GetAllFactures(int id) { BonProduction bProduction = new BonProduction(); try { Connexion con = new Connexion(); con.OpenConnection(); string req = " SELECT id, idArticle, idAtelier, nbArticle, dateDepart, dateFin, cout FROM factureproduction WHERE id=" + id; MySqlCommand cmd = new MySqlCommand(req, con.connexion); MySqlDataReader dt = cmd.ExecuteReader(); while (dt.Read()) { bProduction.ID = dt.GetInt16(0); bProduction.IDARTICLE = dt.GetInt16(1); bProduction.IDATELIER = dt.GetInt16(2); bProduction.NBARTICLE = dt.GetInt16(3); bProduction.DATEDEPART = dt.GetString(4); bProduction.DATEFIN = dt.GetString(5); bProduction.COUT = dt.GetInt16(6); } con.CloseConnection(); return(bProduction); } catch (Exception e) { MessageBox.Show(e.Message); return(null); } }
public static int ModifierBon(BonProduction art) { try { Connexion con = new Connexion(); con.OpenConnection(); string req = "UPDATE factureproduction SET idArticle =" + art.IDARTICLE + ", idAtelier=" + art.IDATELIER + ", nbArticle=" + art.NBARTICLE + ", dateDepart='" + art.DATEDEPART + "', dateFin='" + art.DATEFIN + "', cout=" + art.COUT + " WHERE id=" + art.ID + " "; MySqlCommand cmd = new MySqlCommand(req, con.connexion); cmd.ExecuteNonQuery(); con.CloseConnection(); return(1); } catch (Exception e) { MessageBox.Show(e.Message); return(0); } }
public static int AjouterBon(BonProduction art) { try { Connexion con = new Connexion(); con.OpenConnection(); string req = "INSERT INTO factureproduction (id, idArticle, idAtelier, nbArticle, dateDepart, dateFin, cout) VALUES (" + art.ID + "," + art.IDARTICLE + "," + art.IDATELIER + ", " + art.NBARTICLE + ",'" + art.DATEDEPART + "', '" + art.DATEFIN + "'," + art.COUT + "); "; MySqlCommand cmd = new MySqlCommand(req, con.connexion); cmd.ExecuteNonQuery(); con.CloseConnection(); return(1); } catch (Exception e) { MessageBox.Show(e.Message + "" + e.ToString()); return(0); } }