protected void BtnSumit_Click(object sender, EventArgs e) { mesg.Visible = false; DBFunctions db = new DBFunctions(); int empid = int.Parse(DropDownteacher.SelectedValue); int crsid = int.Parse(DropDownCourse.SelectedValue); CourseTeacherAssignment_tbl assigncourse = new CourseTeacherAssignment_tbl { CourseID = crsid, TeacherID = empid }; int flag= db.assignteachercourse(assigncourse); if (flag==2) { mesg.Visible = true; //<p class="alert alert-danger col-lg-offset-3 col-lg-9" runat="server" id="mesg" visible="false"></p> mesg.Text = "<p class='alert alert-danger col-lg-offset-3 col-lg-6'> The Course of "+DropDownCourse.SelectedItem.Text+" is already assigned to "+DropDownteacher.SelectedItem.Text+"</p>"; } else if(flag==1) { mesg.Visible = true; mesg.Text = "<p class='alert alert-info col-lg-offset-3 col-lg-6'> The Course of " + DropDownCourse.SelectedItem.Text + " is Successfuly assigned to " + DropDownteacher.SelectedItem.Text + "</p>"; } else if (flag == -1) { mesg.Visible = true; mesg.Text = "<p class='alert alert-danger col-lg-offset-3 col-lg-6'> The Course of " + DropDownCourse.SelectedItem.Text + " is already assigned to another teacher</p>"; } }
protected void BtnSumit_Click(object sender, EventArgs e) { mesg.Visible = false; DBFunctions db = new DBFunctions(); int empid = int.Parse(DropDownteacher.SelectedValue); int crsid = int.Parse(DropDownCourse.SelectedValue); CourseTeacherAssignment_tbl assigncourse = new CourseTeacherAssignment_tbl { CourseID = crsid, TeacherID = empid }; int flag = db.assignteachercourse(assigncourse); if (flag == 2) { mesg.Visible = true; //<p class="alert alert-danger col-lg-offset-3 col-lg-9" runat="server" id="mesg" visible="false"></p> mesg.Text = "<p class='alert alert-danger col-lg-offset-3 col-lg-6'> The Course of " + DropDownCourse.SelectedItem.Text + " is already assigned to " + DropDownteacher.SelectedItem.Text + "</p>"; } else if (flag == 1) { mesg.Visible = true; mesg.Text = "<p class='alert alert-info col-lg-offset-3 col-lg-6'> The Course of " + DropDownCourse.SelectedItem.Text + " is Successfuly assigned to " + DropDownteacher.SelectedItem.Text + "</p>"; } else if (flag == -1) { mesg.Visible = true; mesg.Text = "<p class='alert alert-danger col-lg-offset-3 col-lg-6'> The Course of " + DropDownCourse.SelectedItem.Text + " is already assigned to another teacher</p>"; } }
public void updatecourseassignment(CourseTeacherAssignment_tbl ca) { db = new CollegeERPDBEntities(); var crsasgmt = db.CourseTeacherAssignment_tbl.Where(x => x.CourseID == ca.CourseID).FirstOrDefault(); if (crsasgmt == null) { assignteachercourse(ca); return; } crsasgmt.TeacherID = ca.TeacherID; db.SaveChanges(); }
public int assignteachercourse(CourseTeacherAssignment_tbl assigncourse) { db = new CollegeERPDBEntities(); var check = db.CourseTeacherAssignment_tbl.Where(x => x.TeacherID == assigncourse.TeacherID && x.CourseID == assigncourse.CourseID).FirstOrDefault(); if (check != null) return 2; else{ check = db.CourseTeacherAssignment_tbl.Where(x => x.CourseID == assigncourse.CourseID).FirstOrDefault(); if(check!=null) return -1; } db.CourseTeacherAssignment_tbl.Add(assigncourse); db.SaveChanges(); return 1; }