public void afficherDetail(plateforme p) { var categplat = new Categorie(RequeteSql.srchCategorie(p.codeCateg).First()); rTxtDesc.Text = p.descPlate; rTxtInfoSup.Text = p.infoSupPlate; txtCartemere.Text = p.carteMerePlate; txtCode.Text = p.codePlate; txtCPU.Text = p.cpuPlate; txtID.Text = p.idPlate.ToString(); txtNom.Text = p.nomPlate; txtRam.Text = p.ramPlate; txtStockage.Text = p.stockage; foreach (var item in cboxCateg.Items) { if (((Categorie)item).codeCateg == categplat.codeCateg) { cboxCateg.SelectedItem = item; break; } } foreach (var item in p.lstSysExpPlate) { ajoutSysExpDetails(item); } }
public List<Categorie> rechercher(string chaine) { List<Categorie> lstCat = new List<Categorie>(); foreach (var c in rCategSQL.srchCategorieAll(chaine)) { Categorie cat = new Categorie(c); lstCat.Add(cat); } return lstCat; }
public frmDetCateg(Categorie C) { categSelect = C; InitializeComponent(); this.PositionBtn(194); ctrlCateg = new ctrlCategorie(); this.btnEnregistrer.Click += new EventHandler(enregistrer); this.btnCopier.Click += new EventHandler(btnCopier_Click); annuler = true; }
public void enregistrer(object sender,EventArgs e) { Categorie enregistrement = new Categorie(); bool resulVerif; DialogResult resultEnrg; enregistrement.codeCateg = txtCode.Text.Trim(); enregistrement.descCateg = txtDesc.Text.Trim(); enregistrement.comCateg = rtxtCommentaire.Text.Trim(); resulVerif = ctrlCateg.verifier(enregistrement, categSelect); if (categSelect == null && ((string)Tag) != "Copie" ) { if (resulVerif) { resultEnrg = MessageBox.Show("Voulez-vous vraiment enregister?", "Enregistrement", MessageBoxButtons.YesNo); if (resultEnrg == DialogResult.Yes) { ctrlCateg.modifier(enregistrement); this.Close(); } } else { MessageBox.Show("Veuillez remplir les champs correctement.", "Erreur", MessageBoxButtons.OK); } } else { if (!ctrlCateg.testExiste(enregistrement.codeCateg) && txtCode.Text.Trim().Length != 0) { resultEnrg = MessageBox.Show("Voulez-vous vraiment enregister?", "Enregistrement", MessageBoxButtons.YesNo); if (resultEnrg == DialogResult.Yes) { ctrlCateg.ajouter(enregistrement); this.Close(); } } else { MessageBox.Show("Une categorie avec ce code existe deja ou le code est trop court.", "Erreur", MessageBoxButtons.OK); } } }
public static void addCateg(Categorie settings) { var add = new tblCategorie(); add.CodeCategorie = settings.codeCateg; add.ComCategorie = settings.comCateg; add.DescCategorie = settings.descCateg; db.tblCategorie.Add(add); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } }
public static void setCateg(Categorie settings) { var r = (from categ in db.tblCategorie where categ.CodeCategorie == settings.codeCateg select categ).First(); r.CodeCategorie = settings.codeCateg; r.ComCategorie = settings.comCateg; r.DescCategorie = settings.descCateg; try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } }
private void btnCopier_Click(object sender, EventArgs e) { Categorie info = new Categorie(); frmDetCateg formOuvert; info.comCateg = rtxtCommentaire.Text; info.descCateg = txtDesc.Text; formOuvert = new frmDetCateg(info); formOuvert.Tag = "Copie"; formOuvert.remplirChamp(); formOuvert.btnCopier.Enabled = false; formOuvert.btnSupprimer.Enabled = false; formOuvert.btnActiverModif.Enabled = false; formOuvert.ShowDialog(); if (annuler == false) { this.Close(); } formOuvert.Closed += (s, args) => this.Close(); }
/// <summary> /// /// </summary> /// <param name="code">a = ajouter, m = modifier</param> public void modifierChamp(string code) { if (code == "a") { this.btnActiverModif.Visible = false; categSelect = null; } else { this.txtCode.Enabled = false; this.txtDesc.Enabled = false; this.rtxtCommentaire.Enabled = false; this.btnCopier.Enabled = true; this.btnEnregistrer.Enabled = false; remplirChamp(); } }
private void modifierCateg() { var frmDetails = new frmDetCateg(lvlAcces); Categorie categSelect = new Categorie(); int index = gridCateg.SelectedRows[0].Index; categSelect.codeCateg = (string)gridCateg.Rows[index].Cells[0].Value; categSelect.descCateg = (string)gridCateg.Rows[index].Cells[1].Value; categSelect.comCateg = (string)gridCateg.Rows[index].Cells[2].Value; frmDetails.categSelect = categSelect; frmDetails.modifierChamp("m"); frmDetails.ShowDialog(); update(); if (frmDetails.categSelect != null) { int R = gestionCateg.RowsById(frmDetails.categSelect.codeCateg, gridCateg); gridCateg.Rows[R].Cells[0].Selected = true; gridCateg.Rows[R].Selected = true; Ligne = R; } }
private void modifierCateg() { var frmDetails = new frmDetCateg(); Categorie categSelect = new Categorie(); int index = gridCateg.SelectedRows[0].Index; categSelect.codeCateg = (string)gridCateg.Rows[index].Cells[0].Value; categSelect.descCateg = (string)gridCateg.Rows[index].Cells[1].Value; categSelect.comCateg = (string)gridCateg.Rows[index].Cells[2].Value; frmDetails.categSelect = categSelect; frmDetails.modifierChamp("m"); frmDetails.ShowDialog(); update(); }