public mst_class_notebook findWork(mst_class_notebook notebook) { string query = @"SELECT session, class_id, section_id, chapter_id, work_id, work_name, work_date, work_type, subject_id FROM mst_class_notebook WHERE session = @session AND class_id = @class_id AND section_id = @section_id AND subject_id = @subject_id AND chapter_id = @chapter_id AND work_type = @work_type AND work_id = @work_id"; var result = con.Query <mst_class_notebook>(query, notebook).SingleOrDefault(); return(result); }
public ActionResult AddHW(mst_class_notebook notebook) { mst_class_notebookMain main = new mst_class_notebookMain(); main.AddWork(notebook); return(RedirectToAction("AllHWWorkList", new { session = notebook.session, subject_id = notebook.subject_id, class_id = notebook.class_id, section_id = notebook.section_id, chapter_id = notebook.chapter_id })); }
public ActionResult DeleteHW(mst_class_notebook notebook) { mst_class_notebookMain main = new mst_class_notebookMain(); notebook.work_type = "HW"; main.deleteWork(notebook); return(RedirectToAction("AllHWWorkList", new { session = notebook.session, subject_id = notebook.subject_id, class_id = notebook.class_id, section_id = notebook.section_id, chapter_id = notebook.chapter_id })); }
public ActionResult AddHW(string session, int class_id, int subject_id, int section_id, int chapter_id) { mst_class_notebook notebook = new mst_class_notebook(); notebook.session = session; notebook.class_id = class_id; notebook.subject_id = subject_id; notebook.section_id = section_id; notebook.chapter_id = chapter_id; notebook.work_type = "HW"; return(View(notebook)); }
public ActionResult DeleteHW(string session, int class_id, int subject_id, int section_id, int chapter_id, int work_id) { mst_class_notebook notebook = new mst_class_notebook(); mst_class_notebookMain main = new mst_class_notebookMain(); notebook.session = session; notebook.class_id = class_id; notebook.subject_id = subject_id; notebook.section_id = section_id; notebook.chapter_id = chapter_id; notebook.work_type = "HW"; notebook.work_id = work_id; return(View(main.findWork(notebook))); }
public void AddWork(mst_class_notebook notbook) { try { string query = @"INSERT INTO `mst_class_notebook` (`session`, `class_id`, `section_id`, `subject_id`, `chapter_id`, `work_id`, `work_name`, `work_date`, `work_type`) VALUES (@session, @class_id, @section_id, @subject_id, @chapter_id, @work_id, @work_name, curdate(), @work_type)"; string maxid = @"SELECT IFNULL(MAX(work_id), 0) + 1 FROM mst_class_notebook WHERE session = @session"; notbook.work_id = con.ExecuteScalar <int>(maxid, new { session = notbook.session }); con.Execute(query, notbook); } catch (Exception ex) { throw ex; } }
public void deleteWork(mst_class_notebook work) { try { string query = @"DELETE FROM `mst_class_notebook` WHERE session = @session AND class_id = @class_id AND section_id = @section_id AND subject_id = @subject_id AND chapter_id = @chapter_id AND work_id = @work_id AND work_type = @work_type"; var result = con.Query <mst_class_notebook>(query, work); } catch (Exception ex) { // do whatever is required } }