public ResourceCategories ResourceCategories_GetById(ref BaseEntity Entity, Int32 Id)
        {
            Entity = new BaseEntity();
            ResourceCategories dt = null;

            if (Id > 0)
            {
                dt = ResourceCategoriesDAO.Instance.GetById(ref Entity, Id);
            }

            return(dt);
        }
        public Boolean ResourceCategories_Save(ref BaseEntity Entity, ResourceCategories ResourceCategory)
        {
            Boolean success = false;

            Entity = new BaseEntity();
            if (!String.IsNullOrEmpty(ResourceCategory.Name) && !String.IsNullOrEmpty(ResourceCategory.Description))
            {
                success = ResourceCategoriesDAO.Instance.Save(ref Entity, ResourceCategory);
            }
            else
            {
                Entity.Errors.Add(new BaseEntity.ListError(new Exception {
                }, "An error occurred while sending data"));
            }

            return(success);
        }
Exemple #3
0
        public Boolean Save(ref BaseEntity Entity, ResourceCategories ResourceCategory)
        {
            Boolean    Success = false;
            SqlCommand cmd     = null;

            try
            {
                cmd = new SqlCommand("SP_RESOURCECATEGORIES_SAVE", clsConnection.GetConnection())
                {
                    CommandType = CommandType.StoredProcedure
                };

                SqlParameter paramID = cmd.Parameters.Add("@NEWID", SqlDbType.Int);
                paramID.Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@ID", ResourceCategory.ID);
                cmd.Parameters.AddWithValue("@NAME", ResourceCategory.Name);
                cmd.Parameters.AddWithValue("@translationKey", ResourceCategory.TranslationKey);
                cmd.Parameters.AddWithValue("@DESCRIPTION", ResourceCategory.Description);
                cmd.Parameters.AddWithValue("@STATUS", ResourceCategory.Status);
                cmd.Parameters.AddWithValue("@CREATEDBY", ResourceCategory.Createdby);
                cmd.Parameters.AddWithValue("@UPDATEDBY", ResourceCategory.Updatedby);
                cmd.ExecuteNonQuery();

                if (!String.IsNullOrEmpty(cmd.Parameters["@NEWID"].Value.ToString()))
                {
                    ResourceCategory.ID = Convert.ToInt32(cmd.Parameters["@NEWID"].Value);
                }

                Success = true;
            }
            catch (Exception ex)
            {
                Success = false;
                Entity.Errors.Add(new BaseEntity.ListError(ex, "An error occurred  saving a vendor. Error on Level 3"));
            }
            finally
            {
                clsConnection.DisposeCommand(cmd);
            }

            return(Success);
        }
Exemple #4
0
        public ResourceCategories GetById(ref BaseEntity Entity, Int32 Id)
        {
            SqlDataReader      dr = null;
            ResourceCategories objResourceCategory = null;
            SqlCommand         cmd = null;

            try
            {
                cmd = new SqlCommand("SP_RESOURCECATEGORIES_GETBYID", clsConnection.GetConnection())
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("ID", Id);

                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    objResourceCategory = new ResourceCategories
                    {
                        ID             = dr.GetColumnValue <Int32>("ID"),
                        Name           = dr.GetColumnValue <String>("NAME"),
                        Description    = dr.GetColumnValue <String>("DESCRIPTION"),
                        Status         = dr.GetColumnValue <Int16>("STATUS"),
                        TranslationKey = dr.GetColumnValue <String>("TranslationKey")
                    };
                }
            }
            catch (Exception ex)
            {
                cmd = null;
                Entity.Errors.Add(new BaseEntity.ListError(ex, ex.Message));
            }
            finally
            {
                clsConnection.DisposeCommand(cmd);
            }
            return(objResourceCategory);
        }