示例#1
0
 protected void uiButtonCancel_Click(object sender, EventArgs e)
 {
     uiPanelEdit.Visible = false;
     uiPanelViewNews.Visible = true;
     Clearfields();
     CurrentArNews = null;
 }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Master.PageTitle = "الأخبار";
         if (Request.QueryString["NID"] != null && !string.IsNullOrEmpty(Request.QueryString["NID"]))
         {
             uiPanelAllNews.Visible = false;
             uiPanelViewNews.Visible = true;
             int id = Convert.ToInt32(Request.QueryString["NID"].ToString());
             News currentnews = new News();
             currentnews.LoadByPrimaryKey(id);
             uiLabelDate.Text = string.Format("{0:yyyy-MMM-dd}", currentnews.PostedDate);
             uiLabelDate.Text += " " + string.Format("{0:hh:mm}", currentnews.PostedDate);
             uiLabelTitle.Text = currentnews.ArTitle;
             if (!string.IsNullOrEmpty(currentnews.MainImagePath))
                 uiImageNews.ImageUrl = "images.aspx?Inner=news&Image="+currentnews.MainImagePath;
             else
                 uiImageNews.ImageUrl = "images.aspx?Inner=news&Image=" + "arabic/images/logo_Big_watermark.jpg";
             uiLiteralContent.Text = Server.HtmlDecode(currentnews.ArContent);
         }
         else
         {
             uiPanelAllNews.Visible = true;
             uiPanelViewNews.Visible = false;
             BindData();
         }
     }
 }
示例#3
0
        private void BindData()
        {
            PagedDataSource dt = new PagedDataSource();
            News currentnews = new News();
            currentnews.LoadAll();
            currentnews.DefaultView.Sort = "PostedDate desc";
            dt.DataSource = currentnews.DefaultView;
            dt.AllowPaging = true;
            dt.PageSize = 10;
            dt.CurrentPageIndex = PageIndex;
            uiRepeaterCurrentNews.DataSource = dt;
            uiRepeaterCurrentNews.DataBind();

            uiLinkButtonPrev.Enabled = !dt.IsFirstPage;
            uiLinkButtonNext.Enabled = !dt.IsLastPage;
            uiLabelPages.Text = "صفحة " + (PageIndex + 1).ToString() + " من " + dt.PageCount.ToString() + " صفحات";
        }
示例#4
0
        protected void uiGridViewNews_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditNews")
            {
                News objData = new News();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                CurrentArNews = objData;
                uiTextBoxArTitle.Text = objData.ArTitle;
                uiTextBoxBrief.Text = objData.Description;
                uiTextBoxDate.Text = objData.PostedDate.ToString("dd/MM/yyyy");
                uiDropDownListHours.SelectedValue = objData.PostedDate.Hour.ToString("00");
                uiDropDownListMins.SelectedValue = objData.PostedDate.Minute.ToString("00");
                uiRadEditorPageContent.Content = Server.HtmlDecode(objData.ArContent);
                uiPanelViewNews.Visible = false;
                uiPanelEdit.Visible = true;

            }
            else if (e.CommandName == "DeleteNews")
            {
                News objData = new News();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                objData.MarkAsDeleted();
                objData.Save();
                CurrentArNews = null;
                BindData();

            }
        }
示例#5
0
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            if (CurrentArNews != null)
            {
                UpdateRecord();
            }
            else
            {
                AddNewRecord();
            }

            uiPanelEdit.Visible = false;
            uiPanelViewNews.Visible = true;
            Clearfields();
            BindData();
            CurrentArNews = null;
        }
示例#6
0
 private void UpdateRecord()
 {
     News objData = new News();
     objData = CurrentArNews;
     objData.ArTitle = uiTextBoxArTitle.Text;
     objData.ArContent = Server.HtmlEncode(uiRadEditorPageContent.Content);
     objData.Description = uiTextBoxBrief.Text;
     if (uiFileUploadMainPicturePath.HasFile)
     {
         uiFileUploadMainPicturePath.SaveAs(Server.MapPath("~/UploadedFiles/News/" + uiFileUploadMainPicturePath.FileName));
         objData.MainImagePath = "/UploadedFiles/News/" + uiFileUploadMainPicturePath.FileName;
     }
     objData.PostedDate = DateTime.ParseExact(uiTextBoxDate.Text, "dd/MM/yyyy", null);
     objData.PostedDate = objData.PostedDate.AddHours(double.Parse(uiDropDownListHours.SelectedValue));
     objData.PostedDate = objData.PostedDate.AddMinutes(double.Parse(uiDropDownListMins.SelectedValue));
     objData.Save();
 }
示例#7
0
        private void BindData()
        {
            News objData = new News();

            objData.LoadAll();
            objData.DefaultView.Sort = "PostedDate Desc";
            uiGridViewNews.DataSource = objData.DefaultView;
            uiGridViewNews.DataBind();
        }