protected void btnRemoveFromSelected_Click(object sender, EventArgs e) { if (ViewState["SelectedCode"] != null) { int NewsToRemoveCode = Convert.ToInt32(ViewState["SelectedCode"]); BOLNews NewsBOL = new BOLNews(); int NewPririty = 0; NewsBOL.SetNewPriority(NewsToRemoveCode, NewPririty); rptLatestNews.DataSource = NewsBOL.GetLatestNewsList(null, new int[] { }, 20, 1, null, null, null); rptLatestNews.DataBind(); } }
protected void btnMoveToSelected_Click(object sender, EventArgs e) { if (ViewState["SelectedDragCode"] != null) { int NewstoDragCode = Convert.ToInt32(ViewState["SelectedDragCode"]); BOLNews NewsBOL = new BOLNews(); int NewPririty = NewsBOL.GetLatestPriority(0) + 100; NewsBOL.SetNewPriority(NewstoDragCode, NewPririty); int SelectedDragIndex = Convert.ToInt32(ViewState["SelectedDragIndex"]); rptLatestNews.DataSource = NewsBOL.GetLatestNewsList(null, new int[] { }, 20, 1, null, null, null); rptLatestNews.DataBind(); //rptSelectedNews.Items } else { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgBox.Text = "بروز خطا"; } }
protected void DoSave(object sender, ImageClickEventArgs e) { try { #region Validate Controls bool NewsTypeSelected = true; //for (int i = 0; i < treWorkGroups.Items.Count; i++) //{ // CheckBox CurCheckbox = (CheckBox)dlNewsTypes.Items[i].FindControl("chkNewsType"); // if (CurCheckbox.Checked) // { // NewsTypeSelected = true; // break; // } //} if (!NewsTypeSelected) { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgBox.Text = "لطفا حداقل یک گروه انتخاب کنید."; return; } if (NewMode && uplPicFile2.UploadedFiles.Count == 0) { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgBox.Text = "لطفا عکس خبر را انتخاب کنید."; return; } #endregion int ReturnCode = SaveControls("~/Main/Default.aspx?BaseID=" + BaseID); Code = ReturnCode; BOLNews NewsBOL = new BOLNews(); if (ReturnCode != -1) { DateTime dtNewsDate; News CurNews = ((IBaseBOL <News>)NewsBOL).GetDetails(ReturnCode); #region Save News Date if (NewMode) { dtNewsDate = (DateTime)dteNewsDate.SelectedDateChristian; dtNewsDate = new DateTime(dtNewsDate.Year, dtNewsDate.Month, dtNewsDate.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); } else { dtNewsDate = (DateTime)dteNewsDate.SelectedDateChristian; dtNewsDate = new DateTime(dtNewsDate.Year, dtNewsDate.Month, dtNewsDate.Day, CurNews.NewsDate.Hour, CurNews.NewsDate.Minute, CurNews.NewsDate.Second); } NewsBOL.SaveNewsDate(ReturnCode, dtNewsDate); #endregion if (uplPicFile2.UploadedFiles.Count > 0 || string.IsNullOrEmpty(CurNews.PicFile1)) { Guid newGd = Guid.NewGuid(); string RandSmallPic = newGd.ToString().Replace("-", "") + ".jpg"; PersianCalendar pc = new PersianCalendar(); DateTime thisTime = DateTime.Now; string UplPath = "~/Files/News/" + pc.GetYear(thisTime) + "-" + pc.GetMonth(thisTime) + "-" + pc.GetDayOfMonth(thisTime); if (!Directory.Exists(HttpContext.Current.Request.MapPath(UplPath))) { Directory.CreateDirectory(HttpContext.Current.Request.MapPath(UplPath)); } SavePic(CurNews.PicFile2, RandSmallPic, HttpContext.Current.Request.MapPath(UplPath), 100); NewsBOL.ChangeSmallPic(ReturnCode, UplPath + "/" + RandSmallPic); } #region Save Keywords string Keywords = txtKeywords.Text; Keywords = Keywords.Trim(); while (Keywords.IndexOf(" ") != -1) { Keywords = Keywords.Replace(" ", " "); } while (Keywords.IndexOf("\n\n") != -1) { Keywords = Keywords.Replace("\n\n", "\n"); } string[] KeywordsArray = Keywords.Split('\n'); BOLNewsKeywords NewsKeywordsBOL = new BOLNewsKeywords(1); NewsKeywordsBOL.DeleteAllKeywords((int)Code); for (int i = 0; i < KeywordsArray.Length; i++) { if (KeywordsArray[i].Trim() != "") { NewsKeywordsBOL.Insert((int)Code, KeywordsArray[i]); } } #endregion ShowDetails(); } if (cboPriorityTypeCode.SelectedIndex != 0 && ReturnCode != -1) { News CurNews = ((IBaseBOL <News>)NewsBOL).GetDetails(ReturnCode); if (NewMode) { int PriorityTypeCode = Convert.ToInt32(cboPriorityTypeCode.SelectedValue); int NewPririty = 0; NewPririty = NewsBOL.GetLatestPriority(PriorityTypeCode - 1) + 100; if (PriorityTypeCode > 1) { NewsBOL.MoveTopNews(NewPririty); } NewsBOL.SetNewPriority(ReturnCode, NewPririty); } else { int NewsToBeReplaceCode = NewsBOL.GetPriorityByOrder(cboPriorityTypeCode.SelectedIndex - 1); if (NewsToBeReplaceCode != ReturnCode) { NewsBOL.ChangePririties(ReturnCode, NewsToBeReplaceCode); } } txtNewsNumber.Text = CurNews.NewsNumber; NewMode = false; Code = ReturnCode; ShowDetails(); } } catch { } }