コード例 #1
0
        crlUSInfoPasse IntfDalUSInfoPasse.selectUSInfoPasse(string numInfoPasse)
        {
            #region delcaration
            crlUSInfoPasse           infoPasse = null;
            IntfDalUSReductionBillet serviceUSReductionBillet = new ImplDalUSReductionBillet();
            #endregion

            #region implementation
            if (numInfoPasse != "")
            {
                this.strCommande = "SELECT * FROM `usinfopasse` WHERE `numInfoPasse`='" + numInfoPasse + "'";

                this.serviceConnectBase.openConnection();
                this.reader = this.serviceConnectBase.select(this.strCommande);
                if (this.reader != null)
                {
                    if (this.reader.HasRows)
                    {
                        if (this.reader.Read())
                        {
                            infoPasse = new crlUSInfoPasse();
                            try
                            {
                                infoPasse.Niveau = int.Parse(this.reader["niveau"].ToString());
                            }
                            catch (Exception) { }
                            try
                            {
                                infoPasse.NombrePasse = int.Parse(this.reader["nombrePasse"].ToString());
                            }
                            catch (Exception) { }
                            infoPasse.NumInfoPasse       = this.reader["numInfoPasse"].ToString();
                            infoPasse.NumReductionBillet = this.reader["numReductionBillet"].ToString();
                        }
                    }
                    this.reader.Dispose();
                }
                this.serviceConnectBase.closeConnection();
                if (infoPasse != null)
                {
                    if (infoPasse.NumReductionBillet != "")
                    {
                        infoPasse.reductionBillet = serviceUSReductionBillet.selectUSReductionBillet(infoPasse.NumReductionBillet);
                    }
                }
            }
            #endregion

            return(infoPasse);
        }
コード例 #2
0
        DataTable IntfDalUSInfoPasse.getDataTableInfoPasse(string strRqst)
        {
            #region declaration
            DataTable                  dataTable                  = new DataTable();
            IntfDalGeneral             serviceGeneral             = new ImplDalGeneral();
            IntfDalUSPlageNombreBillet serviceUSPlageNombreBillet = new ImplDalUSPlageNombreBillet();
            IntfDalUSReductionBillet   serviceUSReductionBillet   = new ImplDalUSReductionBillet();
            IntfDalUSPrixBase          serviceUSPrixBase          = new ImplDalUSPrixBase();
            crlUSReductionBillet       reduction                  = null;
            crlUSPlageNombreBillet     plageNombreBillet          = null;
            crlUSPrixBase              prixBase = null;
            #endregion

            #region implementation

            #region initialisation du dataTable
            dataTable = new DataTable();
            dataTable.Columns.Add("numInfoPasse", typeof(string));
            dataTable.Columns.Add("nombrePasse", typeof(string));
            dataTable.Columns.Add("niveau", typeof(string));
            dataTable.Columns.Add("prixUnitaire", typeof(string));
            dataTable.Columns.Add("dureeValidite", typeof(string));

            DataRow dr;
            #endregion

            this.serviceConnectBase.openConnection();
            this.reader = this.serviceConnectBase.select(strRqst);
            if (this.reader != null)
            {
                if (this.reader.HasRows)
                {
                    while (this.reader.Read())
                    {
                        dr = dataTable.NewRow();

                        dr["numInfoPasse"] = reader["numInfoPasse"].ToString();
                        dr["nombrePasse"]  = reader["nombrePasse"].ToString();
                        dr["niveau"]       = reader["niveau"].ToString();

                        reduction = serviceUSReductionBillet.selectUSReductionBillet(this.reader["numReductionBillet"].ToString());
                        try
                        {
                            prixBase = serviceUSPrixBase.selectUSPrixBase(int.Parse(reader["niveau"].ToString()));
                        }
                        catch (Exception) { }
                        try
                        {
                            plageNombreBillet = serviceUSPlageNombreBillet.getPlageNombreBillet(int.Parse(reader["nombrePasse"].ToString()));
                        }
                        catch (Exception) { }


                        if (prixBase != null)
                        {
                            if (reduction != null)
                            {
                                if (reduction.ReductionMontant > 0)
                                {
                                    dr["prixUnitaire"] = serviceGeneral.separateurDesMilles((prixBase.MontantPrixBase - reduction.ReductionMontant).ToString("0")) + " Ar";
                                }
                                else
                                {
                                    dr["prixUnitaire"] = serviceGeneral.separateurDesMilles((prixBase.MontantPrixBase - (prixBase.MontantPrixBase * reduction.ReductionPourcentage / 100)).ToString("0")) + " Ar";
                                }
                            }
                            else
                            {
                                dr["prixUnitaire"] = serviceGeneral.separateurDesMilles(prixBase.MontantPrixBase.ToString("0")) + " Ar";
                            }
                        }
                        else
                        {
                            dr["prixUnitaire"] = "";
                        }

                        if (plageNombreBillet != null)
                        {
                            dr["dureeValidite"] = serviceGeneral.getTextTimeSpan(serviceGeneral.getStringTimeSpan(plageNombreBillet.DureeDeValidite));
                        }
                        else
                        {
                            dr["dureeValidite"] = "";
                        }


                        reduction         = null;
                        prixBase          = null;
                        plageNombreBillet = null;


                        dataTable.Rows.Add(dr);
                    }
                }
                this.reader.Dispose();
            }
            this.serviceConnectBase.closeConnection();

            #endregion

            return(dataTable);
        }