public ActionResult CreateProcess(FormCollection frm) { int kt = 0; try { Programs pro = new Programs() { Name = frm["Name"], CauseId = int.Parse(frm["CauseId"]), Status = 0, Contents = frm["Contents"] }; kt = ProgramsBusiness.AddPrograms(pro); } catch { kt = 0; } if (kt > 0) { return RedirectToAction("ListProgram", "ProgramsAD", new { add = "success" }); } else { return RedirectToAction("ListProgram", "ProgramsAD", new { add = "error" }); } }
public static int EditPrograms(Programs ad) { int upt = 0; try { upt = DataAccessLayer.ProgramsDA.EditProgram(ad); } catch (Exception) { return 0; } return upt; }
public static int AddPrograms(Programs ad) { int ins = 0; try { ins = DataAccessLayer.ProgramsDA.AddProgram(ad); } catch (Exception) { return 0; } return ins; }
private static List<Programs> AddProgramsToList(DataTable dt) { List<Programs> ls = new List<Programs>(); try { for (int i = 0; i < dt.Rows.Count; i++) { Programs ad = new Programs() { Id = int.Parse(dt.Rows[i]["Id"].ToString()), Name = dt.Rows[i]["Name"].ToString(), Contents = dt.Rows[i]["Contents"].ToString(), Cause = dt.Rows[i]["Description"].ToString(), Status = int.Parse(dt.Rows[i]["Status"].ToString()), CauseId = int.Parse(dt.Rows[i]["CauseId"].ToString()), IsDeleted = int.Parse(dt.Rows[i]["IsDeleted"].ToString()) }; ls.Add(ad); } } catch (Exception) { return new List<Programs>(); } return ls; }
public ActionResult EditProcess(int id, FormCollection frm) { int kt = 0; try { Programs pro = new Programs() { Id = int.Parse(frm["Id"]), Name = frm["Name"], CauseId = int.Parse(frm["CauseId"]), Status = int.Parse(frm["Status"]), Contents = frm["Contents"] }; kt = ProgramsBusiness.EditPrograms(pro); } catch { kt = 0; } if (kt > 0) { return RedirectToAction("ListProgram", "ProgramsAD", new { update = "success" }); } else { return RedirectToAction("ListProgram", "ProgramsAD", new { update = "error" }); } }