Untitled

 avatar
user_3456920
plain_text
7 months ago
5.6 kB
2
Indexable
Never
   private void calculateResultatFiscale1(string code) {
            decimal TotalNet = 0;
            decimal totalNetMoins = 0;
            decimal TotalAddition = 0, TotalSoustraction = 0, TotalAdditionMoin = 0, TotalSoustractionMoin = 0;
            
            //on a fait comme ca parceque le code Racine deja utilisé dans une autre condition (cas speciale)
            if (code == "00097") {
                        TotalAddition =decimal.Parse(Grid_ResultatFiscale.Rows[78].Cells["ColMontantNetResultatFiscale"].Value.ToString());
                        TotalAdditionMoin =decimal.Parse(Grid_ResultatFiscale.Rows[78].Cells["ColMontantNetResultatFiscale"].Value.ToString());
                        foreach (DataRow MyRow in ((DataTable)Binding_ResultatFiscale.DataSource).Select("CRacineResultatFiscale = '" + code + "'"))
                        {   
                             if (MyRow["Operation"].ToString() != "" && MyRow["Operation"].ToString() != null && MyRow["Operation"].ToString() == "-")
                            {
                                TotalSoustraction += decimal.Parse(MyRow["MontantNet"].ToString());
                                TotalSoustractionMoin += decimal.Parse(MyRow["MontantNetMoins"].ToString());
                            }
                        }
                        foreach (DataRow MyRow in ((DataTable)Binding_ResultatFiscale.DataSource).Select("CResultatFiscale = '" + code + "'"))
                        {
                            MyRow["MontantNet"] = TotalAddition - TotalSoustraction;
                            MyRow["MontantNetMoins"] = TotalAdditionMoin - TotalSoustractionMoin;
                        }
                    }
            else {
                    foreach (DataRow MyRow in ((DataTable)Binding_ResultatFiscale.DataSource).Select("CRacineResultatFiscale = '" + code + "'"))
                    {
                        if (MyRow["Operation"].ToString() != "" && MyRow["Operation"].ToString() != null && MyRow["Operation"].ToString() == "+")
                        {
                            TotalAddition += decimal.Parse(MyRow["MontantNet"].ToString());
                            TotalAdditionMoin += decimal.Parse(MyRow["MontantNetMoins"].ToString());
                        }
                        else if (MyRow["Operation"].ToString() != ""&& MyRow["Operation"].ToString() != null && MyRow["Operation"].ToString() == "-")
                        {
                            TotalSoustraction += decimal.Parse(MyRow["MontantNet"].ToString());
                            TotalSoustractionMoin += decimal.Parse(MyRow["MontantNetMoins"].ToString());
                        }
                    }
                    foreach (DataRow MyRow in ((DataTable)Binding_ResultatFiscale.DataSource).Select("CResultatFiscale = '" + code + "'"))
                    {
                        if (code == "00060") {
                            if (TotalSoustraction > TotalAddition / 2)
                            {
                                MyRow["MontantNet"] = TotalAddition / 2;
                                MyRow["MontantNetMoins"] = TotalAdditionMoin / 2;
                            }
                            else {
                                MyRow["MontantNet"] = TotalAddition - TotalSoustraction;
                                MyRow["MontantNetMoins"] = TotalAdditionMoin - TotalSoustractionMoin;
                            }
                        }
                        else if (code == "00079") {
                            if (TotalAddition < TotalSoustraction)
                            {
                                MyRow["MontantNet"] = 0;
                            }
                            else {
                                MyRow["MontantNet"] = TotalAddition - TotalSoustraction;
                                MyRow["MontantNetMoins"] = TotalAdditionMoin - TotalSoustractionMoin;
                            }
                        }
                        else
                        {
                            MyRow["MontantNet"] = TotalAddition - TotalSoustraction;
                            MyRow["MontantNetMoins"] = TotalAdditionMoin - TotalSoustractionMoin;

                        }
              
                    }
            }
        
        }

        private void FnCalculeResultatFiscale()
        {
            //string[] CodesResultatFiscales = { "00002", "00024", "00032", "00038", "00044", "00053",/* "00054",*/ "00060", "00067", "00079", "00080", "00085", "00090", "00091", "00096", "00100", "00106" };
            string[] CodesResultatFiscales = { "00002", "00024","00032","00038","00044","00053","00054","00060","00062","00067","00079","00080","00085","00090","00091","00097","00100","00106"};
            foreach (string CResultatFiscale in CodesResultatFiscales)
            {
                //CalculeResultatFiscale(CResultatFiscale);
                calculateResultatFiscale1(CResultatFiscale);
            }
            for (int i = 0; i < Grid_ResultatFiscale.Rows.Count; i++)
            {
                if (bool.Parse(Grid_ResultatFiscale.Rows[i].Cells["ColIntervalleResultatFiscale"].Value.ToString()) == true)
                {
                    Grid_ResultatFiscale.Rows[i].ReadOnly = true;
                }
                else {
                    Grid_ResultatFiscale.Rows[i].ReadOnly = false;                
                }

            }
        }
Leave a Comment