Exemple #1
0
        protected void lnkDeleteCategory_Click(object sender, EventArgs e)
        {
            OMAMFundCategory categoryInfo = new OMAMFundCategory();

            categoryInfo.LoadByPrimaryKey(Convert.ToInt32(txtCategoryId.Text.ToString()));
            categoryInfo.MarkAsDeleted();
            categoryInfo.Save();

            divAddActivity.Visible  = false;
            divCategoryList.Visible = true;

            loadDataGrid();
        }
Exemple #2
0
        protected void lnkSaveCategory_Click(object sender, EventArgs e)
        {
            if (txtCategoryId.Text.ToString() == string.Empty)
            {
                //This is an add
                OMAMFundCategory CategoryInfo = new OMAMFundCategory();

                CategoryInfo.FundCategory = txtCategoryName.Text.ToString();
                CategoryInfo.Save();

                //Now add the available site list
                for (int i = 0; i < gvSites.Rows.Count; i++)
                {
                    //CheckBox cbInclude = new CheckBox();
                    CheckBox cbInclude = ((CheckBox)gvSites.Rows[i].Cells[1].FindControl("chkInclude" + i));

                    if (cbInclude.Checked)
                    {
                        OMAMLnkCategoryPortal objCategoryPortal = new OMAMLnkCategoryPortal();

                        DataKey dKey = gvSites.DataKeys[i];
                        objCategoryPortal.PortalId   = Convert.ToInt32(dKey[0].ToString());
                        objCategoryPortal.CategoryId = categoryId;

                        objCategoryPortal.Save();
                    }
                }
            }
            else
            {
                //This is an update
                OMAMFundCategory CategoryInfo = new OMAMFundCategory();

                CategoryInfo.Query.Where(CategoryInfo.Query.Id == Convert.ToInt16(txtCategoryId.Text.ToString()));
                CategoryInfo.Query.Load();

                CategoryInfo.Id           = Convert.ToInt32(txtCategoryId.Text.ToString());
                CategoryInfo.FundCategory = txtCategoryName.Text.ToString();

                CategoryInfo.Save();

                //Delete all the site contents for this category item and add them again
                OMAMLnkCategoryPortalCollection objCategoryPortals = new OMAMLnkCategoryPortalCollection();
                objCategoryPortals.Query.Where(objCategoryPortals.Query.CategoryId == categoryId);
                objCategoryPortals.Query.Load();
                objCategoryPortals.MarkAllAsDeleted();
                objCategoryPortals.Save();

                //Now Add the new site/content list
                //Now add the available site list
                for (int i = 0; i < gvSites.Rows.Count; i++)
                {
                    //CheckBox cbInclude = new CheckBox();
                    CheckBox cbInclude = ((CheckBox)gvSites.Rows[i].Cells[1].FindControl("chkInclude" + i));

                    if (cbInclude.Checked)
                    {
                        OMAMLnkCategoryPortal objCategoryPortal = new OMAMLnkCategoryPortal();

                        DataKey dKey = gvSites.DataKeys[i];
                        objCategoryPortal.PortalId   = Convert.ToInt32(dKey[0].ToString());
                        objCategoryPortal.CategoryId = categoryId;

                        objCategoryPortal.Save();
                    }
                }
            }

            divAddActivity.Visible  = false;
            divCategoryList.Visible = true;

            LoadCategories();
            categoryId = null;
        }