public List <CsComptable> RetourneComptaDuMoisComptable(string pMoisCompta, string pTypeEnc) { CsComptable _ta; List <CsComptable> ListeTA = new List <CsComptable>(); ConnectionString = Session.GetSqlConnexionStringAbo07(); cn = new SqlConnection(ConnectionString); cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = EnumProcedureStockee.RetourneComptaParMoisCompta; cmd.Parameters.Clear(); cmd.Parameters.Add("@MOISCOMPTA", SqlDbType.VarChar).Value = pMoisCompta; cmd.Parameters.Add("@TYPEENC", SqlDbType.VarChar).Value = pTypeEnc; DBBase.SetDBNullParametre(cmd.Parameters); try { if (this.cn.State == ConnectionState.Closed) { this.cn.Open(); } SqlDataReader reader = cmd.ExecuteReader(); if (!reader.HasRows) { reader.Close(); // throw new Exception("Erreur survenue."); } while (reader.Read()) { _ta = new CsComptable(); _ta.MOISCOMPTA = string.IsNullOrEmpty(reader.GetValue(0).ToString()) ? string.Empty : reader.GetValue(0).ToString().Trim(); _ta.CENTRE = string.IsNullOrEmpty(reader.GetValue(1).ToString()) ? string.Empty : reader.GetValue(1).ToString().Trim(); _ta.NATURE = string.IsNullOrEmpty(reader.GetValue(2).ToString()) ? string.Empty : reader.GetValue(2).ToString().Trim(); _ta.COMMUNE = string.IsNullOrEmpty(reader.GetValue(3).ToString()) ? string.Empty : reader.GetValue(3).ToString().Trim(); _ta.PRODUIT = string.IsNullOrEmpty(reader.GetValue(4).ToString()) ? string.Empty : reader.GetValue(4).ToString().Trim(); _ta.REDEVANCE = string.IsNullOrEmpty(reader.GetValue(5).ToString()) ? string.Empty : reader.GetValue(5).ToString().Trim(); _ta.REDHT = string.IsNullOrEmpty(reader.GetValue(6).ToString()) ? 0 : Convert.ToDecimal(reader.GetValue(6).ToString().Trim()); _ta.REDTAXE = string.IsNullOrEmpty(reader.GetValue(7).ToString()) ? 0 : Convert.ToDecimal(reader.GetValue(7).ToString().Trim()); ListeTA.Add(_ta); } //Fermeture reader reader.Close(); return(ListeTA); } catch (Exception ex) { throw new Exception(EnumProcedureStockee.SelectARRETE + ":" + ex.Message); } finally { if (this.cn.State == ConnectionState.Open) { this.cn.Close(); // Fermeture de la connection } cmd.Dispose(); } }
bool?ComptabilisationTaxe(CsComptable pComptabilisation, List <CsNature> pNature, string pSens, int pOperation, string pOrigineLigne) { int origine = pOperation; string CodeTaxeEncours = string.Empty; string CompteEncours = string.Empty; string CompteAnalEnCours = string.Empty; string Libelle = string.Empty; decimal? dTauxTaxe = 0; bool bTrouve = false; string tax = string.Empty; string resultCpt = string.Empty; List <CsCtax> taxes = new List <CsCtax>(); try { taxes.AddRange(SelectAll_CTAX()); if (pOperation == Enumere.FACTURATION || pOperation == Enumere.GUICHET) { origine = Enumere.FACTURATION; } else { origine = Enumere.ENCAISSEMENT; } for (int i = 0; i < taxes.Count; i++) { //if (pComptabilisation.CTAX == taxes[i].CTAX) //{ // bTrouve = true; // CodeTaxeEncours = taxes[i].CTAX; // CsNature nature = pNature.Where(n => n.NATURE == pComptabilisation.NATURE).FirstOrDefault(); // if (nature.COMPTGENE.Contains('S')) // il n'y a un shéma comptable sur la nature // { // RecupererCompteTVASchema(pComptabilisation.CENTRE,nature.COMPTGENE.Substring(1), CompteEncours, CompteAnalEnCours); // if (string.IsNullOrEmpty(CompteEncours)) // CompteEncours = taxes[i].CIMP; // } // else // CompteEncours = taxes[i].CIMP; // Libelle = taxes[i].LIBELLE; // dTauxTaxe = taxes[i].TAUX; // break; //} } tax = "T" + pComptabilisation.CTAX; if (Enumere.ORIGINE_LIGNE.DEMANDE.ToString() == pOrigineLigne) { pComptabilisation.REDTAXE = dTauxTaxe * pComptabilisation.REDHT; } if (bTrouve) { if (CompteEncours.Contains('S')) { ExploiterSchema(CompteEncours, pComptabilisation.NATURE, pComptabilisation.CENTRE, pComptabilisation.PRODUIT, pComptabilisation.MOISCOMPTA, pComptabilisation.REDTAXE, pSens, Libelle, tax, Parametres.CompteAnalytique, pComptabilisation.CODEJOURNAL); } else { ExploiterSchema(CompteEncours, resultCpt, pComptabilisation.NATURE, pComptabilisation.CENTRE, pComptabilisation.PRODUIT, pComptabilisation.MOISCOMPTA, "G", null, null); EcritureLigneCompte(pSens, pComptabilisation.CENTRE, pComptabilisation.NATURE, pComptabilisation.PRODUIT, pComptabilisation.REDTAXE, resultCpt, CompteAnalEnCours, tax, Libelle, "", "", origine, "", pComptabilisation.CODEJOURNAL); } } return(true); } catch (Exception ex) { string error = ex.Message; return(null); } }