public static void EditTeachers(TeachersInfo _teacher) { SqlConnection con = ConnectionHelper.GetConnection(); string sp = "USP_Update_Teachers"; SqlCommand cmd = new SqlCommand(sp, con); cmd.Parameters.Add(new SqlParameter("@TeachersID", -_teacher.TeachersID)); cmd.Parameters.Add(new SqlParameter("@Firstname", _teacher.FirstName)); cmd.Parameters.Add(new SqlParameter("@Lastname", _teacher.LastName)); cmd.Parameters.Add(new SqlParameter("@DepartmentID", _teacher.DepartmentID)); cmd.Parameters.Add(new SqlParameter("@EmpID", _teacher.EmpID)); cmd.Parameters.Add(new SqlParameter("@Address", _teacher.Address)); cmd.Parameters.Add(new SqlParameter("@ContactNo", _teacher.ContactNo )); cmd.Parameters.Add(new SqlParameter("@Email", _teacher.Email)); cmd.CommandType = CommandType.StoredProcedure; try { cmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } }
public static TeachersInfo getTeacherByID(int id) { SqlConnection con = ConnectionHelper.GetConnection(); string sp = "USP_GetTeacher_ByID"; SqlCommand cmd = new SqlCommand(sp, con); cmd.Parameters.Add(new SqlParameter("@ID", id)); cmd.CommandType = CommandType.StoredProcedure; try { SqlDataReader _Reader = cmd.ExecuteReader(); _Reader.Read(); TeachersInfo _teacher = new TeachersInfo(); _teacher.TeachersID = int.Parse(_Reader["TeachersID"].ToString()); _teacher.EmpID =int.Parse( _Reader["EmpID"].ToString()); _teacher.FirstName= _Reader["FirstName"].ToString(); _teacher.LastName= _Reader["LastName"].ToString(); _teacher.Address = _Reader["PAddress"].ToString(); _teacher.ContactNo = int.Parse(_Reader["ContactNo"].ToString()); _teacher.DepartmentID = int.Parse(_Reader["DepartmentID"].ToString()); _teacher.Email = _Reader["Email"].ToString(); _teacher.Address = _Reader["Notice"].ToString(); return _teacher; } catch (Exception ex) { throw ex; } }
protected void CreateTeachers() { TeachersInfo _teacher = new TeachersInfo(); _teacher.FirstName = TxtUName.Text; _teacher.LastName = TxtLastName.Text; _teacher.EmpID = int.Parse(TxtEmpID.Text); _teacher.Email = TxtEmail.Text; _teacher.ContactNo = TxtContact.Text; _teacher.Address = TxtAddress.Text; _teacher.DepartmentID = int.Parse(DdlDept.SelectedValue); try { TeacherDAL.CreateTeachers(_teacher); LblCreateMsg.Text = "Successfully Created!!!"; } catch (Exception ex) { LblCreateMsg.Text = ex.Message; } }
/// <summary> /// 添加Teacher表的信息 /// </summary> /// <param name="T"></param> /// <returns></returns> public static bool TeacherAdd(TeachersInfo T) { return(DAL.Teacher_DAL.TeacherAdd(T)); }