private List <Diaries> fetchDiary(SqlCommand cmd) { SqlConnection con = cmd.Connection; List <Diaries> diary = null; con.Open(); using (con) { SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { diary = new List <Diaries>(); while (dr.Read()) { Diaries d = new Diaries(); d.db_Id = Convert.ToString(dr["id"]); d.Diary_date = Convert.ToString(dr["diary_date"]); d.Settings = Convert.ToString(dr["settings"]); diary.Add(d); } diary.TrimExcess(); } } return(diary); }
public ActionResult PublishDiary(Diary pd, int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { Diaries diary = new Diaries(); diary.Settings = pd.Settings; //new Cateloge().PublishSubResults(diary, id); if (pd.Settings == "2") { TempData["Msg"] = "Diary Have Published Successfully"; } else { TempData["Msg"] = "Diary Have Blocked Successfully"; } return(RedirectToAction("View", new { id = id })); } return(RedirectToAction("Index")); } }
public void SettingsDiary(Diaries pd, int id) { SqlCommand cmd = new SqlCommand("Update diary Set settings=@Settings Where id = @Id", DALUtil.getConnection()); cmd.Parameters.AddWithValue("@Id", id); cmd.Parameters.AddWithValue("@Settings", (pd.Settings == null) ? Convert.DBNull : pd.Settings); _diary(cmd); }
public void UpdateDiary(Diaries ud, int id) { SqlCommand cmd = new SqlCommand("Update diary Set diary_date=@Diary_date Where id=@Id", DALUtil.getConnection()); cmd.Parameters.AddWithValue("@Id", id); cmd.Parameters.AddWithValue("@Diary_date", (ud.Diary_date == null) ? Convert.DBNull : ud.Diary_date); _diary(cmd); }
public void Signout(bool needsave) { Status = $"感谢使用!"; if (needsave) { Save(); } Currentuser = null; Diaries.Clear(); AllDiaries.Clear(); }
public void AddDiary(Diaries d) { SqlCommand cmd = new SqlCommand("INSERT into diary (diary_date,settings,date,month,year,time) VALUES (@Diary_date,'2',@Date,@Month,@Year,@Time)", DALUtil.getConnection()); cmd.Parameters.AddWithValue("@Diary_date", (d.Diary_date == null) ? Convert.DBNull : d.Diary_date); cmd.Parameters.AddWithValue("@Date", (d.Date == null) ? Convert.DBNull : d.Date); cmd.Parameters.AddWithValue("@Month", (d.Month == null) ? Convert.DBNull : d.Month); cmd.Parameters.AddWithValue("@Year", (d.Year == null) ? Convert.DBNull : d.Year); cmd.Parameters.AddWithValue("@Time", (d.Time == null) ? Convert.DBNull : d.Time); _diary(cmd); }
public void InitializeDiary() { AllDiaries.Clear(); Diaries.Clear(); var QDiaries = from r in DataContext.Diary where r.UserID == Currentuser.ID select r; foreach (var QD in QDiaries) { AllDiaries.Add(QD); Diaries.Add(QD); } }
public DiaryViewModel() : base() { logger.Trace("DiaryViewmodel()..."); _selectedDate = DateTime.Now.Date; _diaries = new AsyncObservableCollection <Diary>(); var rooms = DesktopApplication.Librarian.GetItems(typeof(Room), new List <RetrievalCriteria>()); foreach (IDataStoreItem i in rooms) { if ((i as Room).CameraRoom) { Diary d = new Diary(this, (i as Room)); Diaries.Add(d); } } logger.Trace(Diaries.Count + " Diaries created "); }
public void CreateDiary(string ntitle, string ncontent) { if (string.IsNullOrWhiteSpace(ntitle)) { ntitle = "Untitled"; } Diary diary = new Diary { UserID = Currentuser.ID, Title = ntitle, Content = ncontent, WritenDT = DateTime.Now }; Diaries.Add(diary); AllDiaries.Add(diary); Status = "创建日记成功!"; }
public ActionResult Edit(Diary Update, int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { Diaries UpdateDiary = new Diaries(); UpdateDiary.Diary_date = Update.Diary_date; new Cateloge().UpdateDiary(UpdateDiary, id); TempData["Msg"] = "Diary Have Updated Successfully"; return(RedirectToAction("Index")); } return(View(Update)); } }
public void Search() { Diaries.Clear(); var NQDiaries = from r in DataContext.Diary where r.UserID == Currentuser.ID select r; foreach (var QD in NQDiaries) { if (!string.IsNullOrWhiteSpace(SearchTitle)) { if (!QD.Title.Contains(SearchTitle)) { continue; } } if (SearchYear != 0) { if (QD.WritenDT.Year != SearchYear) { continue; } if (SearchMonth != 0) { if (QD.WritenDT.Month != SearchMonth) { continue; } if (SearchDay != 0) { if (QD.WritenDT.Day != SearchDay) { continue; } } } } Diaries.Add(QD); } Status = $"查询中!"; }
private void CheckNewDiary() { DateTime recordedOn = new DateTime(_year, _month, _day); Current = Diaries.FirstOrDefault(a => a.RecordDate >= recordedOn.Date && a.RecordDate < recordedOn.Date.AddDays(1)); if (Current == null) { _lvwDiarys.SelectedIndex = -1; Current = new Diary() { ID = -1, Title = "[新日记]", Keywords = string.Empty, Content = string.Empty, IsRemindRequired = false, JobGroup = "TaskGroup", JobName = Guid.NewGuid().ToString(), JobTypeFullName = $"{typeof(RemindJob).FullName},{System.IO.Path.GetFileName(Common.CurrentAssembly.Location)}", CronExpress = string.Empty, RunningStart = null, RunningEnd = null, RecordDate = new DateTime(_year, _month, _day), RowVersion = DateTime.Now }; } for (int i = 0; i < _lvwDiarys.Items.Count; i++) { Diary diary = (Diary)_lvwDiarys.Items[i]; if (diary.Equals(Current)) { _lvwDiarys.SelectedIndex = i; break; } } _txtTitle.SelectAll(); _txtTitle.Focus(); }
public ActionResult Create(Diary Add) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { Diaries AddDiary = new Diaries(); AddDiary.Diary_date = Add.Diary_date; AddDiary.Date = DateTime.Today.ToString("dd-MM-yyyy"); AddDiary.Month = DateTime.Today.ToString("MMM"); AddDiary.Year = DateTime.Today.ToString("yyyy"); AddDiary.Time = DateTime.Now.ToString("HH:mm:ss"); new Cateloge().AddDiary(AddDiary); TempData["Msg"] = "New Diary Have Added Successfully"; return(RedirectToAction("Index")); } return(View(Add)); } }
public void UpdateDiary(Diaries ud, int id) { new AddAndUpdtDiaryDAL().UpdateDiary(ud, id); }
public void AddDiary(Diaries d) { new AddAndUpdtDiaryDAL().AddDiary(d); }