private List <Employee_train_record> contains(int courseId, int employeeId) { train_courseDataContext kkdb = new train_courseDataContext(); List <Employee_train_record> userList = new List <Employee_train_record>(); var UserArray = kkdb.GetTable <Employee_train_record>(); var users = from t in UserArray where t.Course_id == courseId where t.Employee_id == employeeId select t; foreach (var i in users) { userList.Add(i); } return(userList); }
protected bool isGradeRight(int id) { //List<Employee_train_record> res = new List<Employee_train_record>(); train_courseDataContext kkdb = new train_courseDataContext(); var UserArray = kkdb.GetTable <Employee_train_record>(); var users = from t in UserArray where t.Course_id == id select t; foreach (var i in users) { if (i.Grade == null && i.Remark == null) { return(false); } } return(true); }
protected void ASPxButton2_Click(object sender, EventArgs e) { string course_id = HiddenField1.Value; string employee_id = Hidden2.Value; train_courseDataContext db = new train_courseDataContext(); if (course_id != null) { List <Employee_train_record> list = contains(Convert.ToInt32(course_id), Convert.ToInt32(employee_id)); if (list == null || list.Count == 0) { Response.Write("未选择该课程!"); return; } Employee_train_record info = db.Employee_train_record.Single(i => i.Id == list[0].Id);; db.Employee_train_record.DeleteOnSubmit(info); db.SubmitChanges(); Response.Write("<script language=javascript>window.location.href=document.URL;</script>"); } else { Response.Write("请您进行选课!"); } }