Пример #1
0
        public int CreateSubCategory(SubCategoryFilter SCFilt)
        {
            int result = 0;

            try
            {
                SqlCommand sqlCommand = ProjectConnection.CreateCommand();
                sqlCommand.CommandText = CREATE_SUBCategory_SP;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.Add(new SqlParameter(SUBCATEGORY_PARENTID_PARAM, SqlDbType.Int)).Value = SCFilt.SubCategory.ParentID;
                sqlCommand.Parameters.Add(new SqlParameter(SUBCATEGORY_SUBCATEGORYDESCRIPTION_PARAM, SqlDbType.NVarChar)).Value = SCFilt.SubCategory.SubCategoryDescription;
                ProjectConnection.Open();
                result = sqlCommand.ExecuteNonQuery();
                ProjectConnection.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("SUBCATEGORY", ex);
            }
            finally
            {
                if (ProjectConnection.State == ConnectionState.Open)
                {
                    ProjectConnection.Close();
                }
            }
            return(result);
        }
Пример #2
0
        public SubCategoryList GetFilteredSubcategory(int ParentID)
        {
            SubCategoryList   SCList   = new SubCategoryList();
            SubCategoryFilter SCFilter = new SubCategoryFilter();

            SCFilter.SubCategory.ParentID = ParentID;
            SCList = MaadSun_Interface.MaadSun_In.GetFilteredSubCategory(SCFilter);
            return(SCList);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            if (dgSubCategories.DataKeys.Count > 0)
            {
                //  List<ProductUI> prodlist = (List<ProductUI>)dgProducts.DataSource;
                foreach (DataGridItem item in dgSubCategories.Items)
                {
                    object obj = dgSubCategories.DataKeys[item.ItemIndex];

                    if (obj == null)
                    {
                        continue;
                    }
                    Int64 SubCategoryId = obj != null?Convert.ToInt64(obj) : 0;

                    TextBox     txtRate     = item.FindControl("txtSubCategoryRate") as TextBox;
                    SubCategory subcategory = SubCategory.FetchByID(SubCategoryId);
                    if (subcategory != null)
                    {
                        subcategory.SubCategoryRate = Convert.ToInt64(txtRate.Text);
                        subcategory.Save();
                    }
                    //Save Filters for SubCategory
                    ListBox      ddlFilters    = item.FindControl("ddlFilters") as ListBox;
                    List <Int64> FiltersIdList = new List <Int64>();
                    foreach (ListItem filter in ddlFilters.Items)
                    {
                        if (filter.Selected)
                        {
                            FiltersIdList.Add(Convert.ToInt64(filter.Value));
                        }
                    }
                    if (FiltersIdList.Count > 0)
                    {
                        foreach (Int64 id in FiltersIdList)
                        {
                            SubCategoryFilter subCategoryFilter = SubCategoryFilter.FetchByID(subcategory.SubCategoryId, id, subcategory.CategoryId);
                            if (subCategoryFilter == null)
                            {
                                subCategoryFilter = new SubCategoryFilter();
                                subCategoryFilter.SubCategoryId = SubCategoryId;
                                subCategoryFilter.FilterId      = id;
                                subCategoryFilter.CategoryId    = subcategory.CategoryId;
                                subCategoryFilter.Save();
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        public SubCategoryList GetFilteredSubCategories(SubCategoryFilter SCFilter)
        {
            SqlDataReader   dataReader = null;
            SubCategoryList SCList     = null;

            try
            {
                SqlCommand sqlCommand = ProjectConnection.CreateCommand();
                sqlCommand.CommandText = GETFILTERED_SUBCategory_SP;
                sqlCommand.Parameters.Add(new SqlParameter(SUBCATEGORY_PARENTID_PARAM, SqlDbType.Int)).Value = SCFilter.SubCategory.ParentID;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                ProjectConnection.Open();
                dataReader = sqlCommand.ExecuteReader();
                SCList     = new SubCategoryList();
                while (dataReader.Read())
                {
                    SubCategory I = new SubCategory();
                    I.FillForObject(dataReader);
                    SCList.Rows.Add(I);
                }
                dataReader.Close();
                ProjectConnection.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("SUBCATEGORY", ex);
            }
            finally
            {
                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }
                if (ProjectConnection.State == ConnectionState.Open)
                {
                    ProjectConnection.Close();
                }
            }
            return(SCList);
        }
Пример #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SubCategory subCategory;

            if (!Page.IsValid)
            {
                return;
            }
            if (IsNewMode)
            {
                Int64 CategoryId = ddlCategory.SelectedValue != null?Convert.ToInt64(ddlCategory.SelectedValue) : 0;

                subCategory = SubCategory.FetchByName(txtCategoryName.Text, CategoryId);
                if (subCategory != null)
                {
                    Master.MessageCenter.DisplayErrorMessage(CategoriesStrings.GetText(@"MessageSubCategoryAlreadyExists"));
                    return;
                }
                subCategory = new SubCategory();
                subCategory.SubCategoryName = txtCategoryName.Text;
                subCategory.CategoryId      = Convert.ToInt64(ddlCategory.SelectedValue);
            }
            else
            {
                subCategory = SubCategory.FetchByID(SubCategoryId);
                subCategory.SubCategoryName = txtCategoryName.Text;
                //if(txtCategoryName.Text != subCategory.SubCategoryName)
            }
            if (subCategory == null)
            {
                Master.MessageCenter.DisplayErrorMessage(CategoriesStrings.GetText(@"MessageUnknownError"));
                return;
            }
            subCategory.Save();

            List <Int64> FiltersToSave = FillFiltersrList();

            if (FiltersToSave.Count > 0)
            {
                foreach (Int64 item in FiltersToSave)
                {
                    SubCategoryFilter subCategoryFilter = SubCategoryFilter.FetchByID(subCategory.SubCategoryId, item, subCategory.CategoryId);
                    if (subCategoryFilter == null)
                    {
                        subCategoryFilter = new SubCategoryFilter();
                        subCategoryFilter.SubCategoryId = subCategory.SubCategoryId;
                        subCategoryFilter.FilterId      = item;
                        subCategoryFilter.CategoryId    = subCategory.CategoryId;
                        subCategoryFilter.Save();
                    }
                }
            }

            //if (fuImage.HasFile)
            //{
            //    if (!IsNewMode) MediaUtility.DeleteImageFilePath("SubCategory", subCategory.SubCategoryImage, 64, 64, 0);
            //    string fn = MediaUtility.SaveFile(fuImage.PostedFile, "SubCategory", 0);
            //    subCategory.SubCategoryImage = fn;
            //    imgImage.ImageUrl = Snoopi.core.MediaUtility.GetImagePath("SubCategory", subCategory.SubCategoryImage, 0, 64, 64);
            //    ImageFileHandler(fuImage, imgImage, btnDeleteImage, imgImage.ImageUrl);
            //}
            //else if (subCategory.SubCategoryImage != "" && fuImage.Visible)
            //{
            //    MediaUtility.DeleteImageFilePath("SubCategory", subCategory.SubCategoryImage, 64, 64, 0);
            //    subCategory.SubCategoryImage = "";
            //}


            SubCategoryId = subCategory.SubCategoryId;
            string successMessage = IsNewMode ? CategoriesStrings.GetText(@"MessageSubCategoryCreated") : CategoriesStrings.GetText(@"MessageSubCategorySaved");
            string url            = @"EditSubCategory.aspx?New=yes";

            url += @"&message-success=" + Server.UrlEncode(successMessage);
            Response.Redirect(url, true);
        }
Пример #6
0
        public static SubCategoryList GetFilteredSubCategory(SubCategoryFilter SCFilter)
        {
            MaadSunDB MDB = new MaadSunDB();

            return(MDB.GetFilteredSubCategories(SCFilter));
        }