protected void btnDeleteSchedule_Click(object sender, EventArgs e) { int sid = Convert.ToInt32(Request.QueryString["id"]); Schedule Schedule = new Schedule(); using (Dal.DB db = new Dal.DB()) { Schedule = db.Schedules.Find(sid); db.Schedules.Remove(Schedule); db.SaveChanges(); } Response.Redirect("Admin_Schedules.aspx"); }
protected void btnSubmitUpdate_Click(object sender, EventArgs e) { int sid = Convert.ToInt32(Request.QueryString["id"]); User User=(User)Session["User"]; Schedule Schedule = new Schedule(); using (Dal.DB db = new Dal.DB()) { Schedule = db.Schedules.Find(sid); Schedule.Title = txtEditScheduleName.Text; Schedule.Content = txtEditScheduleContent.Text; Schedule.Time = DateTime.Now; Schedule.ToUserID = Convert.ToInt32(ddlEditScheduleToUser.SelectedValue); Schedule.SubmittionUserID = User.ID; Schedule.DepartmentID = Convert.ToInt32(ddlEditScheduleDepartment.SelectedValue); db.SaveChanges(); } Response.Redirect("Admin_Schedules.aspx"); }
public static string AddSchedule(int submit_user_id, int to_user_id, string title, string content, int department_id) { Schedule Schedule = new Schedule(); Schedule.ToUserID = to_user_id; Schedule.SubmittionUserID = submit_user_id; Schedule.Title = title; Schedule.Content = content; Schedule.DepartmentID = department_id; Schedule.Time = DateTime.Now; using (Dal.DB db = new DB()) { db.Schedules.Add(Schedule); db.SaveChanges(); } return "ok"; }