Exemple #1
0
        public IEnumerable<SelectListItem> GetAreas()
        {
            var areaModel = new AreaMasterModel();
            var area = areaModel.GetAreaMasterAll().Select(x =>
                        new SelectListItem
                        {
                            Value = x.AreaId.ToString(),
                            Text = x.AreaName
                        });

            return new SelectList(area, "Value", "Text");
        }
Exemple #2
0
        /// <summary>
        /// Showing complete record from database
        /// </summary>
        /// <returns></returns>
        public List <AreaMasterModel> GetAreaMasterAll()
        {
            try
            {
                string Q_ShowAllAreaMasterDetail = "select * from areamaster";

                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Assigning value to the variable");
                string cmdText = string.Format(Q_ShowAllAreaMasterDetail, this.AreaId);

                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Creating database");
                Database db = new Database();
                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Database created");

                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "reading data from database");
                DbDataReader reader = db.Select(cmdText);

                if (reader.HasRows)
                {
                    List <AreaMasterModel> areaMasterList = new List <AreaMasterModel>();

                    while (reader.Read())
                    {
                        AreaMasterModel areaMas = new AreaMasterModel();

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Id read from database");
                        areaMas.AreaId = Convert.ToInt32(reader["Id"]);

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "AreaName read from database.");
                        areaMas.AreaName = ParameterFormater.UnescapeXML(reader["AreaName"].ToString());

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "ShortAreaName read from database.");
                        areaMas.ShortAreaName = ParameterFormater.UnescapeXML(reader["ShortAreaName"].ToString());

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Adding object to list");
                        areaMasterList.Add(areaMas);
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Checking reader has closed the connection.");
                    if (!reader.IsClosed)
                    {
                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "closing database connection");
                        reader.Close();
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Object returning value");
                    return(areaMasterList);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logger.Error("AreaMasterModel", "GetAreaMasterAll", "Erro occured while Selecting data from area master detail for all", ex);
                throw ex;
            }
            finally
            {
                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Closed sleeping connection");
                Database.KillConnections();
            }
        }
Exemple #3
0
        /// <summary>
        /// Showing complete record from database
        /// </summary>
        /// <returns></returns>
        public List<AreaMasterModel> GetAreaMasterAll()
        {
            try
            {
                string Q_ShowAllAreaMasterDetail = "select * from areamaster";

                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Assigning value to the variable");
                string cmdText = string.Format(Q_ShowAllAreaMasterDetail, this.AreaId);

                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Creating database");
                Database db = new Database();
                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Database created");

                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "reading data from database");
                DbDataReader reader = db.Select(cmdText);

                if (reader.HasRows)
                {

                    List<AreaMasterModel> areaMasterList = new List<AreaMasterModel>();

                    while (reader.Read())
                    {
                        AreaMasterModel areaMas = new AreaMasterModel();

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Id read from database");
                        areaMas.AreaId = Convert.ToInt32(reader["Id"]);

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "AreaName read from database.");
                        areaMas.AreaName = ParameterFormater.UnescapeXML(reader["AreaName"].ToString());

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "ShortAreaName read from database.");
                        areaMas.ShortAreaName = ParameterFormater.UnescapeXML(reader["ShortAreaName"].ToString());

                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Adding object to list");
                        areaMasterList.Add(areaMas);
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Checking reader has closed the connection.");
                    if (!reader.IsClosed)
                    {
                        Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "closing database connection");
                        reader.Close();
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Object returning value");
                    return areaMasterList;
                }

                return null;

            }
            catch (Exception ex)
            {
                Logger.Error("AreaMasterModel", "GetAreaMasterAll", "Erro occured while Selecting data from area master detail for all", ex);
                throw ex;
            }
            finally
            {
                Logger.Debug("AreaMasterModel", "GetAreaMasterAll", "Closed sleeping connection");
                Database.KillConnections();
            }
        }
Exemple #4
0
        /// <summary>
        /// Showing the record from database by id
        /// </summary>
        /// <param name="areaMasterId"></param>
        /// <returns></returns>
        public AreaMasterModel GetAreaMasterById(int areaMasterId)
        {
            try
            {
                string Q_ShowAreaMasterDetail = "select * from areamaster where Id = {0}";

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "storing values in variable.");

                string cmdText = string.Format(Q_ShowAreaMasterDetail, areaMasterId);
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "storing values in variable after id check.");

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", " creating Database");
                Database db = new Database();
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Database created");

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Reading value  from Database by Id");
                DbDataReader reader = db.Select(cmdText);
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Reading value done");

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "checking database has rows!");
                if (reader.HasRows)
                {
                    AreaMasterModel areaMaster = new AreaMasterModel();
                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Areamaster object created");

                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Reading database values");
                    while (reader.Read())
                    {
                        areaMaster.AreaId = Convert.ToInt32(reader["Id"]);
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Id read from database");

                        areaMaster.AreaName = ParameterFormater.UnescapeXML(reader["AreaName"].ToString());
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Areaname read from database");

                        areaMaster.ShortAreaName = ParameterFormater.UnescapeXML(reader["ShortAreaName"].ToString());
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "ShortAreaName read from database.");
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Checking reader has closed the connection.");
                    if (!reader.IsClosed)
                    {
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "closing database connection");
                        reader.Close();
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Connection closed");
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Object returning value");
                    return(areaMaster);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logger.Error("AreaMasterModel", "Delete", "Erro occured while Selecting data from area master detail by id", ex);
                throw ex;
            }
            finally
            {
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Closed sleeping connection");
                Database.KillConnections();
            }
        }
Exemple #5
0
        /// <summary>
        /// Showing the record from database by id
        /// </summary>
        /// <param name="areaMasterId"></param>
        /// <returns></returns>
        public AreaMasterModel GetAreaMasterById(int areaMasterId)
        {
            try
            {
                string Q_ShowAreaMasterDetail = "select * from areamaster where Id = {0}";

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "storing values in variable.");

                string cmdText = string.Format(Q_ShowAreaMasterDetail, areaMasterId);
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "storing values in variable after id check.");

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", " creating Database");
                Database db = new Database();
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Database created");

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Reading value  from Database by Id");
                DbDataReader reader = db.Select(cmdText);
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Reading value done");

                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "checking database has rows!");
                if (reader.HasRows)
                {
                    AreaMasterModel areaMaster = new AreaMasterModel();
                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Areamaster object created");

                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Reading database values");
                    while (reader.Read())
                    {
                        areaMaster.AreaId = Convert.ToInt32(reader["Id"]);
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Id read from database");

                        areaMaster.AreaName = ParameterFormater.UnescapeXML(reader["AreaName"].ToString());
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Areaname read from database");

                        areaMaster.ShortAreaName = ParameterFormater.UnescapeXML(reader["ShortAreaName"].ToString());
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "ShortAreaName read from database.");
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Checking reader has closed the connection.");
                    if (!reader.IsClosed)
                    {
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "closing database connection");
                        reader.Close();
                        Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Connection closed");
                    }

                    Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Object returning value");
                    return areaMaster;
                }

                return null;

            }
            catch (Exception ex)
            {
                Logger.Error("AreaMasterModel", "Delete", "Erro occured while Selecting data from area master detail by id", ex);
                throw ex;
            }
            finally
            {
                Logger.Debug("AreaMasterModel", "GetAreaMasterById", "Closed sleeping connection");
                Database.KillConnections();
            }
        }