public int Add(HtmlItem obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTHtmlItem;

            #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 parameterDetails = new SqlParameter(PN_DETAILS, SqlDbType.NVarChar);
            parameterDetails.Value = obj.Details;
            parameterDetails.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDetails);
            SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Bit);
            parameterIsDeleted.Value = obj.IsDeleted;
            parameterIsDeleted.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsDeleted);

            SqlParameter parameterHash = new SqlParameter(PN_HASH, SqlDbType.NVarChar);
            parameterHash.Value = obj.Hash;
            parameterHash.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterHash);

            SqlParameter paramType = new SqlParameter(PN_TYPE, SqlDbType.Int);
            paramType.Value = Convert.ToInt32(obj.Type);
            paramType.Direction = ParameterDirection.Input;
            _command.Parameters.Add(paramType);

            SqlParameter paramStatus = new SqlParameter(PN_STATUS, SqlDbType.Int);
            paramStatus.Value = obj.Status;
            paramStatus.Direction = ParameterDirection.Input;
            _command.Parameters.Add(paramStatus);

            SqlParameter paramDate = new SqlParameter(PN_DATE, SqlDbType.NVarChar);
            paramDate.Value = obj.Date;
            paramDate.Direction = ParameterDirection.Input;
            _command.Parameters.Add(paramDate);

            SqlParameter paramlangID = new SqlParameter(PN_LANGUAGE_ID, SqlDbType.Int);
            paramlangID.Value = obj.LanguageID;
            paramlangID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(paramlangID);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
Exemple #2
0
        public void PopulateHtmlItem(SqlDataReader _dtr, HtmlItem obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Name = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_DETAILS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Details = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_ISDELETED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsDeleted = _dtr.GetBoolean((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_HASH);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Hash = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_DATE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Date = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_STATUS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Status = (RootEnums.HtmlBlockStatus)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_TYPE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Type = (RootEnums.HtmlBlockType)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(HtmlItemDataMapper.CN_LANGUAGE_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.LanguageID = _dtr.GetInt32((columnIndex));
            }
        }
Exemple #3
0
        public static void Update(HtmlItem obj)
        {
            HtmlItemDataMapper objCaller = new HtmlItemDataMapper();

            objCaller.Update(obj);
        }
Exemple #4
0
        public static int Add(HtmlItem obj)
        {
            HtmlItemDataMapper objCaller = new HtmlItemDataMapper();

            return objCaller.Add(obj);
        }
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                HtmlItem cat = new HtmlItem();
                cat = HtmlItemManager.GetByID(ObjectID);
                if (null == cat)
                    return;

                txtName.Text = cat.Name;
                txtHash.Text = cat.Hash;
                txtDetails.Text = cat.Details;

                plcControls.Visible = true;
            }
        }
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            HtmlItem html = new HtmlItem();
            if (ObjectID <= 0)
            {
                try
                {
                    html.IsDeleted = false;
                    html.Name = txtName.Text;
                    html.Details = (txtDetails.Text);
                    html.Hash = txtHash.Text;
                    html.Type = DataLayer.Enums.RootEnums.HtmlBlockType.HTML;
                    html.Status = DataLayer.Enums.RootEnums.HtmlBlockStatus.Visible;
                    html.Date = DateTime.Now.ToString("dd/MM/yyyy");
                    HtmlItemManager.Add(html);
                    AddMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    html = HtmlItemManager.GetByID(ObjectID);
                    if (null == html)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    html.IsDeleted = false;
                    html.Name = txtName.Text;
                    html.Details = (txtDetails.Text);
                    html.Hash = txtHash.Text;
                    html.Type = DataLayer.Enums.RootEnums.HtmlBlockType.HTML;
                    html.Status = DataLayer.Enums.RootEnums.HtmlBlockStatus.Visible;
                    html.Date = DateTime.Now.ToString("dd/MM/yyyy");
                    HtmlItemManager.Update(html);
                    EditMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
        }
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                HtmlItem cat = new HtmlItem();
                cat = HtmlItemManager.GetByID(ObjectID);
                if (null == cat)
                    return;
                ddlStatus.SelectedValue = Convert.ToInt32(cat.Status).ToString();
                txtName.Text = cat.Name;
                txtHash.Text = cat.Hash;
                txtDetails.Content = cat.Details;

                plcControls.Visible = true;
            }
        }
 public HtmlItem GetHtmlItem(SqlDataReader _dtr, IList<HtmlItem> colobj)
 {
     HtmlItem obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new HtmlItem();
         colobj.Add(obj);
     }
     return obj;
 }
        public IList<HtmlItem> Search(string keyword)
        {

            HtmlItem obj = null;

            IList<HtmlItem> colobj = new List<HtmlItem>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "[usp_SearchHtmlItem]";

            #region [Parameters]
            SqlParameter parameterhash = new SqlParameter("Keyword", SqlDbType.NVarChar);
            parameterhash.Value = keyword;
            parameterhash.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterhash);
            #endregion;

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

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

            return colobj;
        }
        public IList<HtmlItem> GetAll()
        {

            HtmlItem obj = null;

            IList<HtmlItem> colobj = new List<HtmlItem>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLHtmlItem;

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

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

            return colobj;
        }
 private void GetEntityFromReader(SqlDataReader _dtr, HtmlItem obj)
 {
     PopulateHtmlItem(_dtr, obj);
 }
        public HtmlItem GetByHashNameandLangID(string hashName, int langid)
        {

            HtmlItem obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "usp_SelectHtmlItemByHashNameandLangID";

            #region [Parameters]
            SqlParameter parameterhash = new SqlParameter(PN_HASH, SqlDbType.NVarChar);
            parameterhash.Value = hashName;
            parameterhash.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterhash);

            SqlParameter paramlang = new SqlParameter(PN_LANGUAGE_ID, SqlDbType.Int);
            paramlang.Value = langid;
            paramlang.Direction = ParameterDirection.Input;
            _command.Parameters.Add(paramlang);
            #endregion;

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

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

            return obj;
        }
        public HtmlItem GetByID(int ID)
        {

            HtmlItem obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTHtmlItem;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_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 HtmlItem();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

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

            return obj;
        }