示例#1
0
        public void PopulateBanner(SqlDataReader _dtr, Banner obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Name = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_HASH);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Hash = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_DETAILS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Details = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_CRERATIONDATE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.CrerationDate = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_CREATEDBY);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.CreatedBy = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_PUBLISHFROM);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.PublishFrom = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_PUBLISHTO);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.PublishTo = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_CATEGORYID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.CategoryID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_STATUS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Status = (RootEnums.BannerStatus)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_URL_TYPE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.UrlType = (RootEnums.UrlType)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_URL);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Url = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_TOTALCOUNT);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.TotalCount = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_TOTALVIEWS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.TotalPassed = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_TYPE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Type = (RootEnums.BannerType)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(BannerDataMapper.CN_USER_SIDE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.UserSide = _dtr.GetString((columnIndex));
            }

        }
示例#2
0
        public static int Add(Banner obj)
        {
            BannerDataMapper objCaller = new BannerDataMapper();

            return objCaller.Add(obj);
        }
示例#3
0
        public static void Update(Banner obj)
        {
            BannerDataMapper objCaller = new BannerDataMapper();

            objCaller.Update(obj);
        }
示例#4
0
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            TG.ExpressCMS.DataLayer.Entities.Banner banner = new TG.ExpressCMS.DataLayer.Entities.Banner();
            if (ObjectID <= 0)
            {
                try
                {
                    banner.Name = txtName.Text;
                    banner.Details = (txtDetails.Content);
                    banner.Hash = txtHash.Text;

                    banner.Status = DataLayer.Enums.RootEnums.BannerStatus.Active;
                    banner.CrerationDate = DateTime.Now.ToString("dd/MM/yyy");
                    banner.CreatedBy = SecurityContext.LoggedInUser.ID.ToString();
                    //banner.CreatedBy = "0";
                    int bannerid = -1;
                    Int32.TryParse(ddlCategories.SelectedValue, out bannerid);
                    banner.CategoryID = bannerid;
                    banner.PublishFrom = txtPublishFrom.SelectedDate.Value.ToString("dd/MM/yyyy");
                    banner.PublishTo = txtDateTo.SelectedDate.Value.ToString("dd/MM/yyyy");
                    banner.UrlType = (RootEnums.UrlType)Convert.ToInt32(ddlUrlType.SelectedValue);
                    banner.Url = "";
                    if (banner.UrlType == RootEnums.UrlType.External)
                        banner.Url = txtUrl.Text;
                    //    if (chkUpdateImage.Checked)
                    banner.UserSide = txtUserSide.Content;
                    banner.Type = RootEnums.BannerType.StaticBased;
                    banner.TotalCount = 999999;
                    banner.TotalPassed = 0;
                    BannerManager.Add(banner);
                    if (banner.UrlType == RootEnums.UrlType.Internal)
                    {
                        banner.Url = ResolveUrl(ConfigContext.GetBannerDetailsPage) + "?" + ConstantsManager.BannerID + "=" + banner.ID;
                        BannerManager.Update(banner);
                    }
                    AddMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    banner = BannerManager.GetByID(ObjectID);
                    if (null == banner)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    banner.Name = txtName.Text;
                    banner.Details = (txtDetails.Content);
                    banner.Hash = txtHash.Text;
                    banner.UserSide = txtUserSide.Content;
                    banner.Status = DataLayer.Enums.RootEnums.BannerStatus.Active;
                    banner.CrerationDate = DateTime.Now.ToString("dd/MM/yyyy");
                    banner.CreatedBy = SecurityContext.LoggedInUser.ID.ToString();
                    //banner.CreatedBy = "0";
                    int bannerid = -1;
                    Int32.TryParse(ddlCategories.SelectedValue, out bannerid);
                    banner.CategoryID = bannerid;
                    banner.PublishFrom = txtPublishFrom.SelectedDate.Value.ToString("dd/MM/yyyy");
                    banner.PublishTo = txtDateTo.SelectedDate.Value.ToString("dd/MM/yyyy");

                    banner.UrlType = (RootEnums.UrlType)Convert.ToInt32(ddlUrlType.SelectedValue);
                    if (banner.UrlType == RootEnums.UrlType.Internal)
                    {
                        banner.Url = ResolveUrl(ConfigContext.GetBannerDetailsPage) + "?" + ConstantsManager.BannerID + "=" + banner.ID;
                    }
                    else
                        banner.Url = txtUrl.Text;
                    banner.Type = RootEnums.BannerType.StaticBased;
                    banner.TotalCount = 999999;
                    banner.TotalPassed = 0;

                    BannerManager.Update(banner);
                    EditMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
        }
示例#5
0
        private void EditMode()
        {
            if (ObjectID > 0)
            {

                TG.ExpressCMS.DataLayer.Entities.Banner banner = new TG.ExpressCMS.DataLayer.Entities.Banner();
                banner = BannerManager.GetByID(ObjectID);
                if (null == banner)
                    return;

                txtName.Text = banner.Name;
                txtHash.Text = banner.Hash;
                txtUserSide.Content = banner.UserSide;
                txtCount.Text = banner.TotalCount.ToString();
                rdblstTypes.SelectedValue = Convert.ToInt32(banner.Type).ToString();
                txtDetails.Content = banner.Details;
                txtPublishFrom.DbSelectedDate = banner.PublishFrom;
                txtDateTo.DbSelectedDate = banner.PublishTo;
                if (banner.UrlType == (RootEnums.UrlType.External))
                {
                    trDetails.Visible = false;
                }
                else
                    trDetails.Visible = true;
                ddlUrlType.SelectedValue = Convert.ToInt32(banner.UrlType).ToString();
                txtUrl.Text = banner.Url;
                ddlCategories.SelectedValue = banner.CategoryID.ToString();
                plcControls.Visible = true;
            }
        }
示例#6
0
        public int Add(Banner obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTBanner;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Output;
            _command.Parameters.Add(parameterID);
            SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar);
            parameterName.Value = obj.Name;
            parameterName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterName);
            SqlParameter parameterHash = new SqlParameter(PN_HASH, SqlDbType.NVarChar);
            parameterHash.Value = obj.Hash;
            parameterHash.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterHash);
            SqlParameter parameterDetails = new SqlParameter(PN_DETAILS, SqlDbType.NVarChar);
            parameterDetails.Value = obj.Details;
            parameterDetails.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDetails);
            SqlParameter parameterCrerationDate = new SqlParameter(PN_CRERATIONDATE, SqlDbType.NVarChar);
            parameterCrerationDate.Value = obj.CrerationDate;
            parameterCrerationDate.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCrerationDate);
            SqlParameter parameterCreatedBy = new SqlParameter(PN_CREATEDBY, SqlDbType.NVarChar);
            parameterCreatedBy.Value = obj.CreatedBy;
            parameterCreatedBy.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCreatedBy);
            SqlParameter parameterPublishFrom = new SqlParameter(PN_PUBLISHFROM, SqlDbType.NVarChar);
            parameterPublishFrom.Value = obj.PublishFrom;
            parameterPublishFrom.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterPublishFrom);
            SqlParameter parameterPublishTo = new SqlParameter(PN_PUBLISHTO, SqlDbType.NVarChar);
            parameterPublishTo.Value = obj.PublishTo;
            parameterPublishTo.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterPublishTo);
            SqlParameter parameterCategoryID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int);
            parameterCategoryID.Value = obj.CategoryID;
            parameterCategoryID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCategoryID);
            SqlParameter parameterStatus = new SqlParameter(PN_STATUS, SqlDbType.Int);
            parameterStatus.Value = obj.Status;
            parameterStatus.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterStatus);
            SqlParameter pType = new SqlParameter(PN_TYPE, SqlDbType.Int);
            pType.Value = obj.Type;
            pType.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pType);
            SqlParameter pTotalCount = new SqlParameter(PN_TOTALCOUNT, SqlDbType.Int);
            pTotalCount.Value = obj.TotalCount;
            pTotalCount.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pTotalCount);
            SqlParameter pTotalViews = new SqlParameter(PN_TOTALVIEWS, SqlDbType.Int);
            pTotalViews.Value = obj.TotalPassed;
            pTotalViews.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pTotalViews);

            SqlParameter pUrlType = new SqlParameter(PN_URL_TYPE, SqlDbType.Int);
            pUrlType.Value = obj.UrlType;
            pUrlType.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pUrlType);
            SqlParameter pUrl = new SqlParameter(PN_URL, SqlDbType.NVarChar);
            pUrl.Value = obj.Url;
            pUrl.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pUrl);
            SqlParameter pUserSide = new SqlParameter(PN_USER_SIDE, SqlDbType.NVarChar);
            pUserSide.Value = obj.UserSide;
            pUserSide.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pUserSide);

            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
示例#7
0
 public Banner GetBanner(SqlDataReader _dtr, IList<Banner> colobj)
 {
     Banner obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new Banner();
         colobj.Add(obj);
     }
     return obj;
 }
示例#8
0
        public IList<Banner> GetAllPublished()
        {

            Banner obj = new Banner();

            IList<Banner> colobj = new List<Banner>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "GetallPublishedBanners";

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Banner();
                        colobj = new List<Banner>();
                        while (_dtreader.Read())
                        {
                            obj = GetBanner(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
示例#9
0
 private void GetEntityFromReader(SqlDataReader _dtr, Banner obj)
 {
     PopulateBanner(_dtr, obj);
 }
示例#10
0
        public Banner GetByID(int ID)
        {

            Banner obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTBanner;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(CN_ID, SqlDbType.Int);
            parameterID.Value = ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Banner();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }