protected void btnaddprogramme_Click(object sender, EventArgs e) { DBFunctions db = new DBFunctions(); var checkcourse = db.getcourselist().Where(x => x.CourseCode == CourseCode.Text).FirstOrDefault(); if (checkcourse == null) { //Program_tbl prgram = new Program_tbl { ProgramName = ProgrammeNametxt.Text, SecondChoice = int.Parse(dropdownSecondChoise.SelectedValue), HasCampus = int.Parse(dropdownCampus.SelectedValue), ApplicationFee = txtApplicationFee.Text, FormNumber = txtFormCh.Text, ProgrameType = dropdownPrograms.SelectedValue, HasJambData = int.Parse(dropdownJamb.SelectedValue), HasBioDataSection = int.Parse(dropdownBioData.SelectedValue), HasPreviousRecord = int.Parse(dropdownPreviousRecord.SelectedValue), HasCBTSchedule = int.Parse(dropdownCbtSchedule.SelectedValue), HasOlevelResult = int.Parse(dropdownOlevel.SelectedValue), Enable = true, DeptID = int.Parse(DropDownDept.SelectedValue), CutoffPoints = Cuttofpointstxt.Text, DateCreated = DateTime.Now.Date, AcceptenceFee = txtAcceptenceFee.Text, FormCh = txtFormCh.Text }; Courses_tbl course = new Courses_tbl { Course = coursename.Text, Fee = Feetxt.Text, Marks = Markstxt.Text, Credit_Hours = int.Parse(CreditHours.Text), CourseCode = CourseCode.Text }; int cid = db.addcourse(course); foreach (ListItem chck in CheckBoxPrgramlist.Items) { if (chck.Selected) { ProgrammeCourses_tbl prgcrs = new ProgrammeCourses_tbl { ProgramID = int.Parse(chck.Value), CourseID = cid }; db.addprogrammecourse(prgcrs); } } messagae.Text = "Course Successfully Added"; messagae.Visible = true; // Response.Redirect("ManageCourses.aspx"); } else { messagae.Text = "Course Code Already Exist"; messagae.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { string pagename = Path.GetFileName(Request.PhysicalPath); if (Session["userid"] != null) { if (!IsPostBack) { DBFunctions db = new DBFunctions(); int userid = int.Parse(Session["userid"].ToString()); List <CourseTeacherAssignment_tbl> courses = db.getassigncourses(userid); List <Courses_tbl> crslist = new List <Courses_tbl>(); Courses_tbl tempcours = new Courses_tbl { Course = "Select Course" }; crslist.Add(tempcours); foreach (var crs in courses) { crslist.Add(crs.Courses_tbl); } Dropdowncrs.DataSource = crslist.OrderBy(x => x.ID); Dropdowncrs.DataValueField = "ID"; Dropdowncrs.DataTextField = "Course"; Dropdowncrs.DataBind(); } } else { Response.Redirect("Login.aspx?Redirecturl=" + pagename); } }
protected void Page_Load(object sender, EventArgs e) { string pagename = Path.GetFileName(Request.PhysicalPath); if (Session["userid"] != null) { if (!IsPostBack) { DBFunctions db = new DBFunctions(); int userid = int.Parse(Session["userid"].ToString()); List<CourseTeacherAssignment_tbl> courses= db.getassigncourses(userid); List<Courses_tbl> crslist=new List<Courses_tbl>(); Courses_tbl tempcours = new Courses_tbl { Course = "Select Course" }; crslist.Add(tempcours); foreach(var crs in courses) { crslist.Add(crs.Courses_tbl); } Dropdowncrs.DataSource =crslist.OrderBy(x=>x.ID); Dropdowncrs.DataValueField = "ID"; Dropdowncrs.DataTextField = "Course"; Dropdowncrs.DataBind(); } } else { Response.Redirect("Login.aspx?Redirecturl=" + pagename); } }
protected void Page_Load(object sender, EventArgs e) { string action = Request.QueryString["action"]; string pagename = Path.GetFileName(Request.PhysicalPath); if (Session["admin"] != null) { if (Request.QueryString["Courseid"] != null) { id = int.Parse(Request.QueryString["Courseid"]); if (!IsPostBack) { DBFunctions db = new DBFunctions(); if (action == "update") { checkbocprogamlist.DataSource = db.getprogramslist(); checkbocprogamlist.DataValueField = "ID"; checkbocprogamlist.DataTextField = "ProgramName"; checkbocprogamlist.DataBind(); foreach (ListItem item in checkbocprogamlist.Items) { var check = db.getprogramcours(int.Parse(item.Value), id); if (check != null) { item.Selected = true; } } Courses_tbl course = db.getcourses(id); coursename.Text = course.Course; Feetxt.Text = course.Fee; Markstxt.Text = course.Marks; CourseCode.Text = course.CourseCode; CreditHours.Text = course.Credit_Hours.ToString(); } else { } } } else { Response.Redirect("ManageCourses.aspx"); } } else { if (id != -1) { Response.Redirect("Login.aspx?Redirecturl=" + pagename + "?Courseid=" + id + "&action=update"); } else { Response.Redirect("Login.aspx?Redirecturl=" + pagename); } } }
protected void btnupdatecourse_Click(object sender, EventArgs e) { DBFunctions db = new DBFunctions(); //Program_tbl prgram = new Program_tbl { ID = id, ProgramName = ProgrammeNametxt.Text, SecondChoice = int.Parse(dropdownSecondChoise.SelectedValue), HasCampus = int.Parse(dropdownCampus.SelectedValue), ApplicationFee = txtApplicationFee.Text, FormNumber = txtFormNum.Text, ProgrameType = dropdownPrograms.SelectedValue, HasJambData = int.Parse(dropdownJamb.SelectedValue), HasBioDataSection = int.Parse(dropdownBioData.SelectedValue), HasPreviousRecord = int.Parse(dropdownPreviousRecord.SelectedValue), HasCBTSchedule = int.Parse(dropdownCbtSchedule.SelectedValue), HasOlevelResult = int.Parse(dropdownOlevel.SelectedValue), Enable = true, DeptID = int.Parse(DropDownDept.SelectedValue), CutoffPoints = Cuttofpointstxt.Text, DateCreated = DateTime.Now.Date, AcceptenceFee = txtAcceptenceFee.Text, FormCh = txtFormCh.Text }; Courses_tbl course = new Courses_tbl { ID = int.Parse(Request.QueryString["Courseid"]), Course = coursename.Text, Fee = Feetxt.Text, Marks = Markstxt.Text, CourseCode = CourseCode.Text, Credit_Hours = int.Parse(CreditHours.Text) }; db.updatecourse(course); db.clearprogramcourses(int.Parse(Request.QueryString["Courseid"])); foreach (ListItem item in checkbocprogamlist.Items) { if (item.Selected) { ProgrammeCourses_tbl programcourse = new ProgrammeCourses_tbl { CourseID = int.Parse(Request.QueryString["Courseid"]), ProgramID = int.Parse(item.Value) }; db.addprogrammecourse(programcourse); } } Response.Redirect("ManageCourses.aspx"); }
protected void btnupdatecourse_Click(object sender, EventArgs e) { DBFunctions db = new DBFunctions(); //Program_tbl prgram = new Program_tbl { ID = id, ProgramName = ProgrammeNametxt.Text, SecondChoice = int.Parse(dropdownSecondChoise.SelectedValue), HasCampus = int.Parse(dropdownCampus.SelectedValue), ApplicationFee = txtApplicationFee.Text, FormNumber = txtFormNum.Text, ProgrameType = dropdownPrograms.SelectedValue, HasJambData = int.Parse(dropdownJamb.SelectedValue), HasBioDataSection = int.Parse(dropdownBioData.SelectedValue), HasPreviousRecord = int.Parse(dropdownPreviousRecord.SelectedValue), HasCBTSchedule = int.Parse(dropdownCbtSchedule.SelectedValue), HasOlevelResult = int.Parse(dropdownOlevel.SelectedValue), Enable = true, DeptID = int.Parse(DropDownDept.SelectedValue), CutoffPoints = Cuttofpointstxt.Text, DateCreated = DateTime.Now.Date, AcceptenceFee = txtAcceptenceFee.Text, FormCh = txtFormCh.Text }; Courses_tbl course = new Courses_tbl { ID = int.Parse(Request.QueryString["Courseid"]), Course = coursename.Text, Fee = Feetxt.Text, Marks = Markstxt.Text, CourseCode = CourseCode.Text, Credit_Hours = int.Parse(CreditHours.Text) }; db.updatecourse(course); db.clearprogramcourses(int.Parse(Request.QueryString["Courseid"])); foreach (ListItem item in checkbocprogamlist.Items) { if (item.Selected) { ProgrammeCourses_tbl programcourse = new ProgrammeCourses_tbl { CourseID = int.Parse(Request.QueryString["Courseid"]), ProgramID = int.Parse(item.Value) }; db.addprogrammecourse(programcourse); } } Response.Redirect("ManageCourses.aspx"); }
protected void btnaddprogramme_Click(object sender, EventArgs e) { DBFunctions db = new DBFunctions(); var checkcourse= db.getcourselist().Where(x => x.CourseCode == CourseCode.Text).FirstOrDefault(); if (checkcourse == null) { //Program_tbl prgram = new Program_tbl { ProgramName = ProgrammeNametxt.Text, SecondChoice = int.Parse(dropdownSecondChoise.SelectedValue), HasCampus = int.Parse(dropdownCampus.SelectedValue), ApplicationFee = txtApplicationFee.Text, FormNumber = txtFormCh.Text, ProgrameType = dropdownPrograms.SelectedValue, HasJambData = int.Parse(dropdownJamb.SelectedValue), HasBioDataSection = int.Parse(dropdownBioData.SelectedValue), HasPreviousRecord = int.Parse(dropdownPreviousRecord.SelectedValue), HasCBTSchedule = int.Parse(dropdownCbtSchedule.SelectedValue), HasOlevelResult = int.Parse(dropdownOlevel.SelectedValue), Enable = true, DeptID = int.Parse(DropDownDept.SelectedValue), CutoffPoints = Cuttofpointstxt.Text, DateCreated = DateTime.Now.Date, AcceptenceFee = txtAcceptenceFee.Text, FormCh = txtFormCh.Text }; Courses_tbl course = new Courses_tbl { Course = coursename.Text, Fee = Feetxt.Text, Marks = Markstxt.Text, Credit_Hours = int.Parse(CreditHours.Text), CourseCode = CourseCode.Text }; int cid = db.addcourse(course); foreach (ListItem chck in CheckBoxPrgramlist.Items) { if (chck.Selected) { ProgrammeCourses_tbl prgcrs = new ProgrammeCourses_tbl { ProgramID = int.Parse(chck.Value), CourseID = cid }; db.addprogrammecourse(prgcrs); } } messagae.Text = "Course Successfully Added"; messagae.Visible = true; // Response.Redirect("ManageCourses.aspx"); } else { messagae.Text = "Course Code Already Exist"; messagae.Visible = true; } }
public void updatecourse(Courses_tbl updatecrs) { db = new CollegeERPDBEntities(); db.Courses_tbl.Attach(updatecrs); // var progrm = db.Program_tbl.Where(x => x.ID == id).FirstOrDefault(); db.Entry(updatecrs).State = EntityState.Modified; db.SaveChanges(); }
public int addcourse(Courses_tbl course) { using (db = new CollegeERPDBEntities()) { db.Courses_tbl.Add(course); db.SaveChanges(); } return course.ID; }