private void dgMyDataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            DataGrid dg         = (sender as DataGrid);
            var      allObjects = dg.ItemsSource as List <ObjELEMENTDEVIS>;

            if (dg.SelectedItem != null)
            {
                ObjELEMENTDEVIS SelectedObject = Shared.ClasseMEthodeGenerique.RetourneCopyObjet <ObjELEMENTDEVIS>((ObjELEMENTDEVIS)dg.SelectedItem);
                if ((DateTime.Now - lastClick).Ticks < 2500000)
                {
                    if (SelectedObject.QUANTITE == null || SelectedObject.QUANTITE == 0)
                    {
                        if (SelectedObject.ISCOMPTEUR && MaDemande.LaDemande.TYPEDEMANDE == SessionObject.Enumere.AugmentationPuissance)
                        {
                            UcSaisiQuantite ctrl = new UcSaisiQuantite(SelectedObject, true, true, taxe);
                            this.IsEnabled = false;
                            ctrl.Closed   += ctrl_Closed;
                            ctrl.Show();
                        }
                        else
                        {
                            UcSaisiQuantite ctrl = new UcSaisiQuantite(SelectedObject, true, taxe);
                            this.IsEnabled = false;
                            ctrl.Closed   += ctrl_Closed;
                            ctrl.Show();
                        }
                    }
                    else
                    {
                        btn_Ajouter_Click(null, null);
                    }
                }
                lastClick = DateTime.Now;
            }
        }
        void ctrl_Closed(object sender, EventArgs e)
        {
            this.IsEnabled = true;
            UcSaisiQuantite ctrs = sender as UcSaisiQuantite;

            if (ctrs.isOkClick)
            {
                List <ObjELEMENTDEVIS> lesElements = new List <ObjELEMENTDEVIS>();
                if (this.dataGridElementDevisFinal.ItemsSource != null)
                {
                    lesElements = ((List <ObjELEMENTDEVIS>) this.dataGridElementDevisFinal.ItemsSource).ToList();
                    //ObjELEMENTDEVIS leElemt = lesElements.FirstOrDefault(t => t.FK_IDMATERIELDEVIS == ctrs.SelectedObject.FK_IDMATERIELDEVIS && t.FK_IDRUBRIQUEDEVIS == ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS);
                    ObjELEMENTDEVIS leElemt = lesElements.FirstOrDefault(t => t.FK_IDMATERIELDEVIS == ctrs.SelectedObject.FK_IDMATERIELDEVIS /*&& t.FK_IDRUBRIQUEDEVIS == ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS*/);
                    if (leElemt == null)
                    {
                        if (MaDemande.LaDemande.TYPEDEMANDE == SessionObject.Enumere.BranchementAbonement)
                        {
                            if (this.Chk_Extension.IsChecked == true)
                            {
                                ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS = SessionObject.LstRubriqueDevis.FirstOrDefault(t => t.CODE == SessionObject.Enumere.DEVISBRANCHEMENT).PK_ID;
                                ctrs.SelectedObject.RUBRIQUE           = SessionObject.Enumere.DEVISBRANCHEMENT;
                                ctrs.SelectedObject.ISEXTENSION        = true;
                            }
                            else
                            {
                                ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS = SessionObject.LstRubriqueDevis.FirstOrDefault(t => t.CODE == SessionObject.Enumere.DEVISDEXTENSION).PK_ID;
                                ctrs.SelectedObject.RUBRIQUE           = SessionObject.Enumere.DEVISDEXTENSION;
                                ctrs.SelectedObject.ISEXTENSION        = false;
                            }
                        }
                        lesElements.Add(ctrs.SelectedObject);
                    }
                    else
                    {
                        lesElements.Remove(leElemt);
                        lesElements.Add(leElemt);
                    }
                }
                else
                {
                    ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS = this.Chk_Extension.IsChecked == false?
                                                             SessionObject.LstRubriqueDevis.FirstOrDefault(t => t.CODE == SessionObject.Enumere.DEVISBRANCHEMENT).PK_ID:
                                                             SessionObject.LstRubriqueDevis.FirstOrDefault(t => t.CODE == SessionObject.Enumere.DEVISDEXTENSION).PK_ID;

                    lesElements.Add(ctrs.SelectedObject);
                }
                this.dataGridElementDevisFinal.ItemsSource = null;
                this.dataGridElementDevisFinal.ItemsSource = lesElements;

                this.Txt_TotalHt.Text  = lesElements.Where(p => p.QUANTITE != null && p.QUANTITE != 0).ToList().Sum(t => t.MONTANTHT).Value.ToString(SessionObject.FormatMontant);
                this.Txt_TotalTtc.Text = lesElements.Where(p => p.QUANTITE != null && p.QUANTITE != 0).ToList().Sum(t => t.MONTANTTTC).Value.ToString(SessionObject.FormatMontant);
                this.Txt_TotalTva.Text = lesElements.Where(p => p.QUANTITE != null && p.QUANTITE != 0).ToList().Sum(t => t.MONTANTTAXE).Value.ToString(SessionObject.FormatMontant);
            }
        }
Beispiel #3
0
        void ctrl_Closed(object sender, EventArgs e)
        {
            this.IsEnabled = true;
            UcSaisiQuantite ctrs = sender as UcSaisiQuantite;

            if (ctrs.isOkClick)
            {
                List <ObjELEMENTDEVIS> lesElements = new List <ObjELEMENTDEVIS>();
                if (this.dataGridElementDevisFinal.ItemsSource != null)
                {
                    lesElements = ((List <ObjELEMENTDEVIS>) this.dataGridElementDevisFinal.ItemsSource).ToList();
                    ObjELEMENTDEVIS leElemt = lesElements.FirstOrDefault(t => t.FK_IDMATERIELDEVIS == ctrs.SelectedObject.FK_IDMATERIELDEVIS && t.FK_IDRUBRIQUEDEVIS == ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS);
                    if (leElemt == null)
                    {
                        if (MaDemande.LaDemande.TYPEDEMANDE == SessionObject.Enumere.BranchementAbonnementMt)
                        {
                            if (this.dataGridRubriqueDevis.SelectedItem != null)
                            {
                                ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS = ((CsRubriqueDevis)this.dataGridRubriqueDevis.SelectedItem).PK_ID;
                                ctrs.SelectedObject.RUBRIQUE           = ((CsRubriqueDevis)this.dataGridRubriqueDevis.SelectedItem).CODE;
                                ctrs.SelectedObject.ISEXTENSION        = true;
                            }
                        }
                        lesElements.Add(ctrs.SelectedObject);
                    }
                    else
                    {
                        lesElements.Remove(leElemt);
                        lesElements.Add(leElemt);
                    }
                }
                else
                {
                    if (this.dataGridRubriqueDevis.SelectedItem != null)
                    {
                        ctrs.SelectedObject.FK_IDRUBRIQUEDEVIS = ((CsRubriqueDevis)this.dataGridRubriqueDevis.SelectedItem).PK_ID;
                        ctrs.SelectedObject.RUBRIQUE           = ((CsRubriqueDevis)this.dataGridRubriqueDevis.SelectedItem).CODE;
                        ctrs.SelectedObject.ISEXTENSION        = true;
                    }
                    lesElements.Add(ctrs.SelectedObject);
                }
                this.dataGridElementDevisFinal.ItemsSource = null;
                this.dataGridElementDevisFinal.ItemsSource = lesElements;
                if (lesElements != null && lesElements.Count != 0)
                {
                    this.txt_MontantTotalDevis.Text = lesElements.Sum(t => t.MONTANTTTC).Value.ToString(SessionObject.FormatMontant);
                }
            }
        }