From 116d3c090b65664ba4dc041e41eaa74abf9dd450 Mon Sep 17 00:00:00 2001 From: Erwann PHILIPPE Date: Tue, 24 Mar 2026 22:08:01 +0100 Subject: [PATCH] =?UTF-8?q?gestion=20de=20la=20modification=20de=20command?= =?UTF-8?q?es=20commenc=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/FrmMediatek.Designer.cs | 1 + MediaTekDocuments/view/FrmMediatek.cs | 40 ++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/MediaTekDocuments/view/FrmMediatek.Designer.cs b/MediaTekDocuments/view/FrmMediatek.Designer.cs index 3fb7c84..fd3e22f 100644 --- a/MediaTekDocuments/view/FrmMediatek.Designer.cs +++ b/MediaTekDocuments/view/FrmMediatek.Designer.cs @@ -2181,6 +2181,7 @@ namespace MediaTekDocuments.view this.dgvCommandes.Size = new System.Drawing.Size(843, 154); this.dgvCommandes.TabIndex = 5; this.dgvCommandes.SelectionChanged += new System.EventHandler(this.dgvCommandes_SelectionChanged); + this.dgvCommandes.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dgvCommandes_MouseDown); // // label66 // diff --git a/MediaTekDocuments/view/FrmMediatek.cs b/MediaTekDocuments/view/FrmMediatek.cs index cd23742..25edeb1 100644 --- a/MediaTekDocuments/view/FrmMediatek.cs +++ b/MediaTekDocuments/view/FrmMediatek.cs @@ -1337,15 +1337,19 @@ namespace MediaTekDocuments.view } } + // Checkpoint private void RemplirCommandesListe(List lesCommandes) { dgvCommandes.DataSource = null; dgvCommandes.Columns.Clear(); dgvCommandes.DataSource = lesCommandes; - string[] toHide = { "id", "idLivreDvd", "idSuivi", "LibelleSuivi" }; + string[] toHide = { "id", "idLivreDvd", "idSuivi" }; foreach (string col in toHide) if (dgvCommandes.Columns.Contains(col)) dgvCommandes.Columns[col].Visible = false; dgvCommandes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + + dgvCommandes.ClearSelection(); + dgvCommandes.CurrentCell = null; } private void AfficheCommandeLivresInfos(Livre livre) @@ -1370,11 +1374,26 @@ namespace MediaTekDocuments.view grpNewCommande.Enabled = false; } + + //Checkpoint private void dgvCommandes_SelectionChanged(object sender, EventArgs e) { - if (dgvListeLivre2.CurrentCell != null) + if (dgvCommandes.CurrentRow?.DataBoundItem is CommandeDocument commande) { btnDeleteCommande.Enabled = true; + cboSuivi.Enabled = true; + + if (dgvCommandes.CurrentRow.Cells["Montant"].Value != null) + { + CommandeDocument commandeDocument = (CommandeDocument)dgvCommandes.CurrentRow.DataBoundItem; + updownMontant.Value = Convert.ToDecimal(dgvCommandes.CurrentRow.Cells["Montant"].Value); + updownNbExemplaire.Value = Convert.ToDecimal(dgvCommandes.CurrentRow.Cells["NbExemplaire"].Value); + string etape = commandeDocument.LibelleSuivi; + cboSuivi.SelectedIndex = cboSuivi.FindStringExact(etape); + //cboSuivi.SelectedIndex = etape; + + + } } else { @@ -1445,5 +1464,22 @@ namespace MediaTekDocuments.view List lesCommandes = controller.GetCommandesDocument(livre.Id); RemplirCommandesListe(lesCommandes); } + + private void dgvCommandes_MouseDown(object sender, MouseEventArgs e) + { + DataGridView.HitTestInfo hit = dgvCommandes.HitTest(e.X, e.Y); + if (hit.Type == DataGridViewHitTestType.None || hit.Type == DataGridViewHitTestType.ColumnHeader) + { + dgvCommandes.ClearSelection(); + dgvCommandes.CurrentCell = null; + ViderZonesSaisieCommande(); + } + } + + private void ViderZonesSaisieCommande() + { + updownMontant.Value = 0; + updownNbExemplaire.Value = 0; + } } }