Ejemplo n.º 1
0
        public int Add(Category obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTCategory;

            #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 parameterDescription = new SqlParameter(PN_DESCRIPTION, SqlDbType.NVarChar);
            parameterDescription.Value = obj.Description;
            parameterDescription.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDescription);
            SqlParameter parameterType = new SqlParameter(PN_TYPE, SqlDbType.Int);
            parameterType.Value = Convert.ToInt32(obj.Type);
            parameterType.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterType);
            SqlParameter parameterAttributes = new SqlParameter(PN_ATTRIBUTES, SqlDbType.NVarChar);
            parameterAttributes.Value = obj.Attributes;
            parameterAttributes.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterAttributes);
            SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Bit);
            parameterIsDeleted.Value = obj.IsDeleted;
            parameterIsDeleted.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsDeleted);
            SqlParameter parameterxslID = new SqlParameter(PN_XSL_ID, SqlDbType.Int);
            parameterxslID.Value = obj.XslID;
            parameterxslID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterxslID);

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


            SqlParameter parameterxsimage = new SqlParameter(PN_image, SqlDbType.NVarChar);
            parameterxsimage.Value = obj.Image;
            parameterxsimage.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterxsimage);

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

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
Ejemplo n.º 2
0
        public void PopulateCategory(SqlDataReader _dtr, Category obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Name = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_DESCRIPTION);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Description = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_TYPE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Type = (TG.ExpressCMS.DataLayer.Enums.RootEnums.CategoryType)_dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_ATTRIBUTES);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Attributes = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_ISDELETED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsDeleted = _dtr.GetBoolean((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_XSL_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.XslID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_image);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Image = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_LANGUAGE_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.LanguageID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(CategoryDataMapper.CN_HASH);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Hash = _dtr.GetString((columnIndex));
            }
        }
Ejemplo n.º 3
0
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                Category cat = new Category();
                cat = CategoryManager.GetByID(ObjectID);
                if (null == cat)
                    return;

                txtName.Text = cat.Name;
                txtDesc.Content = cat.Description;

                // ddlLanguages.SelectedValue = cat.LanguageID.ToString();
                plcControls.Visible = true;
            }
        }
Ejemplo n.º 4
0
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            Category Cat = new Category();
            if (ObjectID <= 0)
            {
                try
                {
                    Cat.IsDeleted = false;
                    Cat.Name = txtName.Text;
                    Cat.Type = TG.ExpressCMS.DataLayer.Enums.RootEnums.CategoryType.Projects;
                    Cat.Description = txtDesc.Content;
                    Cat.XslID = -1;
                    Cat.Attributes = string.Empty;
                    Cat.Image = string.Empty;
                    Cat.Hash = "";
                    Cat.LanguageID = 1;//Convert.ToInt32(ddlLanguages.SelectedValue);
                    CategoryManager.Add(Cat);
                    AddMode();
                    dvProblems.InnerText = "Saved Successfully";
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    Cat = CategoryManager.GetByID(ObjectID);
                    if (null == Cat)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    Cat.IsDeleted = false;
                    Cat.Name = txtName.Text;
                    Cat.Type = TG.ExpressCMS.DataLayer.Enums.RootEnums.CategoryType.Projects;
                    Cat.Description = txtDesc.Content;
                    Cat.XslID = -1;
                    Cat.Hash = "";
                    Cat.Attributes = string.Empty;
                    Cat.Image = string.Empty;
                    Cat.LanguageID = 1;//Convert.ToInt32(ddlLanguages.SelectedValue);
                    CategoryManager.Update(Cat);
                    EditMode();
                    dvProblems.InnerText = "Saved Successfully";
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
        }
Ejemplo n.º 5
0
        public static void Update(Category obj)
        {
            CategoryDataMapper objCaller = new CategoryDataMapper();

            objCaller.Update(obj);
        }
Ejemplo n.º 6
0
        public static int Add(Category obj)
        {
            CategoryDataMapper objCaller = new CategoryDataMapper();

            return objCaller.Add(obj);
        }
Ejemplo n.º 7
0
 public Category GetCategory(SqlDataReader _dtr, IList<Category> colobj)
 {
     Category obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new Category();
         colobj.Add(obj);
     }
     return obj;
 }
Ejemplo n.º 8
0
        public IList<Category> GetByHashCode(string hash)
        {

            Category obj = new Category();

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

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

            _connection.Open();
            try
            {

                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {

                        while (_dtreader.Read())
                        {
                            obj = GetCategory(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

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

            return colobj;
        }
Ejemplo n.º 9
0
        public IList<Category> GetAll()
        {

            Category obj = new Category();

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

            _connection.Open();
            try
            {

                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {

                        while (_dtreader.Read())
                        {
                            obj = GetCategory(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

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

            return colobj;
        }
Ejemplo n.º 10
0
 private void GetEntityFromReader(SqlDataReader _dtr, Category obj)
 {
     PopulateCategory(_dtr, obj);
 }
Ejemplo n.º 11
0
        public Category GetByID(int ID)
        {

            Category obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTCategory;

            #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 Category();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

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

            return obj;
        }