コード例 #1
0
    protected void grvNewsLog_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int        Id         = Convert.ToInt32(e.CommandArgument.ToString());
        NewsLogBSO newsLogBSO = new NewsLogBSO();
        NewsLog    newslog    = newsLogBSO.GetNewsLogById(Id);

        string   nName    = e.CommandName.ToLower();
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        switch (nName)
        {
        case "_view":
            break;

        case "_edit":
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                // Response.Redirect("~/Admin/editnewslog/" + Id + "/Default.aspx");
                Response.Redirect("~/Admin/s/EditNewsbyUser/" + hddNewsGroupID.Value + "/" + Id + "/Default.aspx");
            }
            break;

        case "_delete":
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                newsLogBSO.DeleteNewsLog(Id, -1);
                ViewNewsLog(Convert.ToInt32(hddNewsGroupID.Value));
                AspNetCache.Reset();
            }


            break;
        }
    }
コード例 #2
0
    private void ViewNews(int Id)
    {
        NewsLogBSO newsLogBSO = new NewsLogBSO();
        NewsLog    newsLog    = newsLogBSO.GetNewsLogById(Id);

        if (newsLog != null)
        {
            ltlTitle.Text     = newsLog.Title;
            LabelDate.Text    = newsLog.PostDate.ToString("dd/MM/yyyy");// Convert.ToString(newsLog.PostDate);
            ltlDescribe.Text  = newsLog.ShortDescribe;
            FullDescirbe.Text = newsLog.FullDescribe;
            LabelAuthor.Text  = newsLog.Author;

            //if (newsLog.ImageThumb != "")
            //    ltlImageThumb.Text = @"<img src='" + ResolveUrl("~/") + "Upload/newsLog/newsLogThumb/" + newsLog.ImageThumb + "' align='left' class='border_image' width='250'  >";
        }
    }
コード例 #3
0
    private void initControl(int Id, int subId)
    {
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        if (Id > 0)
        {
            btn_add.Visible   = false;
            btn_edit.Visible  = true;
            btn_add2.Visible  = false;
            btn_add1.Visible  = false;
            btn_edit1.Visible = true;
            try
            {
                NewsLog    newsgroup    = new NewsLog();
                NewsLogBSO newsgroupBSO = new NewsLogBSO();
                newsgroup = newsgroupBSO.GetNewsLogById(subId);

                //NewsGroup newsgroup = new NewsGroup();
                //NewsGroupBSO newsgroupBSO = new NewsGroupBSO();
                //newsgroup = newsgroupBSO.GetNewsGroupById(Id);
                hddNewsGroupID.Value      = Convert.ToString(newsgroup.NewsGroupID);
                ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID);
                hddParentNewsID.Value     = Convert.ToString(newsgroup.ParentNewsID);

                //rdbGroupCate.SelectedValue = Convert.ToString(newsgroup.GroupCate); //Thêm

                txtTitle.Text       = newsgroup.Title;
                txtRadShort.Text    = System.Net.WebUtility.HtmlDecode(newsgroup.ShortDescribe);
                txtRadFull.Text     = newsgroup.FullDescribe;
                hddImageThumb.Value = newsgroup.ImageThumb;
                hddImageLarge.Value = newsgroup.ImageLarge;

                txtimage4_3.Text  = newsgroup.ImageThumb;
                txtimage16_9.Text = newsgroup.ImageLarge;

                if (newsgroup.ImageThumb != "")
                {
                    img_thumb.Text = "<img src='" + newsgroup.ImageThumb + "' width='48px' valign='middle'>";
                }
                if (newsgroup.ImageLarge != "")
                {
                    img_large.Text = "<img src='" + newsgroup.ImageLarge + "' width='48px' valign='middle'>";
                }


                hddFileName.Value = newsgroup.FileName;

                txtAuthor.Text         = newsgroup.Author;
                txtRadDate.Text        = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString();
                hddPostDate.Value      = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); // "9/3/2008 16:05:07" .ToString();
                hddRelationTotal.Value = Convert.ToString(newsgroup.RelationTotal);
                rdbStatus.Checked      = newsgroup.Status;
                rdbIshot.Checked       = newsgroup.Ishot;
                rdbIshome.Checked      = newsgroup.Ishome;


                hddCommentTotal.Value     = Convert.ToString(newsgroup.CommentTotal);
                hddIsView.Value           = Convert.ToString(newsgroup.Isview);
                hddCreateUserName.Value   = newsgroup.CreatedUserName;
                hddApprovalUserName.Value = newsgroup.ApprovalUserName;
                hddApprovalDate.Value     = Convert.ToString(newsgroup.ApprovalDate);

                txtKeywords.Text = newsgroup.Keyword;
                txtTags.Text     = newsgroup.Tags;
                txtSlug.Text     = newsgroup.Slug;

                rdbComment.Checked = newsgroup.IsComment;

                rdbApproval.Checked = newsgroup.IsApproval;

                if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                {
                    rdbApproval.Enabled = true;
                }
                else
                {
                    rdbApproval.Enabled = false;
                }

                //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

                //if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                //{
                //    rdbApproval.Checked = newsgroup.IsApproval;
                //    rdbApproval.Enabled = true;
                //}
                //else
                //{
                //    rdbApproval.Checked = newsgroup.IsApproval;
                //    rdbApproval.Enabled = false;
                //}

                hddGroup.Value = newsgroup.GroupCate.ToString();
                BindToCateNews(newsgroup.GroupCate);
                ddlCateNewsGroup.SelectedValue = hddGroup.Value;
                ddlCateNews.SelectedValue      = Convert.ToString(newsgroup.CateNewsID);

                rdbTypeNews.Checked = newsgroup.TypeNews;

                txtShortTitle.Text = newsgroup.ShortTitle;
                chkUrl.Checked     = newsgroup.isUrl;
                txtUrl.Text        = newsgroup.Url;
                if (newsgroup.isUrl)
                {
                    txtUrl.Visible   = true;
                    panelUrl.Visible = true;
                }
                else
                {
                    txtUrl.Visible   = false;
                    panelUrl.Visible = false;
                }
                hddisDelete.Value = newsgroup.isDelete.ToString();
                BindListCate(newsgroup.NewsGroupID); //MultiCate
                ViewNewsLog(newsgroup.NewsGroupID);
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
        else
        {
            txtRadDate.Text   = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString();
            hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); // "9/3/2008 16:05:07" .ToString();

            txtUrl.Visible    = false;
            btn_add.Visible   = true;
            btn_edit.Visible  = false;
            btn_add2.Visible  = true;
            btn_add1.Visible  = true;
            btn_edit1.Visible = false;
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
            {
                rdbApproval.Enabled = true;
            }
            else
            {
                rdbApproval.Enabled = false;
            }
            txtUrl.Visible   = false;
            panelUrl.Visible = false;
            chkUrl.Checked   = false;
        }
    }