Exemplo n.º 1
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                bool isDeleted = false;
                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int        typeId   = Convert.ToInt32(data.GetDataKeyValue("NewsTypeID"));
                    CheckBox   cbDelete = (CheckBox)data.FindControl("cbDelete");
                    bool       isDel    = Convert.ToBoolean(data.GetDataKeyValue("IsDel"));
                    KLNewsType newType  = new KLNewsType(typeId);

                    if (newType != null && newType.NewsTypeID != -1)
                    {
                        newType.IsDelected = true;
                        newType.Save();
                        isDeleted = true;
                    }
                }

                if (isDeleted)
                {
                    SiteUtils.QueueIndexing();
                    grid.Rebind();

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemplo n.º 2
0
        private int Save()
        {
            Page.Validate("NewType");

            if (!Page.IsValid)
            {
                return(-1);
            }


            if (newsType == null)
            {
                newsType = new KLNewsType();
            }

            newsType.Name = txtName.Text;
            newsType.Url  = txtUrl.Text;
            if (ddlParent.SelectedValue != "Gốc")
            {
                newsType.ParentID = int.Parse(ddlParent.SelectedValue);
            }
            // newsType.IsDelected = ckDelete.Checked;

            newsType.Save();
            if (newsType.NewsTypeID > 0)
            {
                LogActivity.Write("Update news category ", newsType.Name);
                message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
            }
            else
            {
                LogActivity.Write("Create new  news category ", newsType.Name);
                message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "InsertSuccessMessage");
            }

            return(newsType.NewsTypeID);
        }