public void CreateTutorInformation(User tutor, ITutor information) { Message = ""; Succeed = false; using (var db = new BaseDbContext()) { var contextUser = db.Users.Find(tutor.Id); if (contextUser == null) { Message = "未能从数据库中找到用户"; return; } var info = new TutorInformation { Tutor = contextUser, Introduction = information.TutorIntroduction, Position = information.TutorPosition, Avatar = information.TutorAvatar }; db.TutorInformations.Add(info); try { db.SaveChanges(); } catch (Exception) { Message = "出现错误"; return; } Succeed = true; return; } }
protected void DL_ItemCommand(object source, DataListCommandEventArgs e) { int reqnum = Convert.ToInt16(e.CommandArgument.ToString()); if (e.CommandName == "select") { TutorDetails_div.Visible = true; t = adb.selafromApptutor(reqnum); TextBox_Name.Text = t.name; TextBox_Age.Text = t.age + ""; TextBox_AlmaMater.Text = t.alma; TextBox_Experience.Text = t.exp + ""; TextBox_gender.Text = t.g + ""; TextBox_Fee.Text = t.fee + ""; TextBox_MobileNo.Text = t.mob; TextBox_EmailId.Text = t.eid; TextBox_tlat.Text = t.tlat + ""; TextBox_tlon.Text = t.tlong + ""; } if (e.CommandName == "delete") { adb.delete("ApplicantTutor", "requestnum", reqnum); filldatalist(); } }
public int addTutor(ITutor t) { try { com.Connection = con; con.Open(); com.CommandType = CommandType.StoredProcedure; com.CommandText = "spInsertintoTutor"; com.Parameters.AddWithValue("@name", t.name); com.Parameters.AddWithValue("@gender", t.g); com.Parameters.AddWithValue("@age", t.age); com.Parameters.AddWithValue("@alma", t.alma); com.Parameters.AddWithValue("@exp", t.exp); com.Parameters.AddWithValue("@fee", t.fee); com.Parameters.AddWithValue("@rating", 0); com.Parameters.AddWithValue("@eid", t.eid); com.Parameters.AddWithValue("@mob", t.mob); com.Parameters.AddWithValue("@pass", t.pass); com.Parameters.AddWithValue("@tid", 0); com.Parameters["@tid"].Direction = ParameterDirection.Output; com.ExecuteNonQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Some exception occured:{0}", ex.Message); } finally { con.Close(); } return(Convert.ToInt16(com.Parameters["@tid"].Value)); }
public void addTeaching(ITutor t, string newstd, string newsub, string newloc, string newlm, string newtype) { com.CommandType = CommandType.StoredProcedure; com.CommandText = "spInsertintoTeaching"; com.Parameters.AddWithValue("@tid", t.id); SetParam(com, "@typename", t.type); SetParam(com, "@newtypename", newtype); SetParam(com, "@subname", t.sub); SetParam(com, "@newsubname", newsub); SetParam(com, "@stdname", t.std); SetParam(com, "@newstdname", newstd); SetParam(com, "@locname", t.loc); SetParam(com, "@newlocname", newloc); SetParam(com, "@lmname", t.lm); SetParam(com, "@newlmname", newlm); com.Parameters.AddWithValue("@type", 0); com.Parameters.AddWithValue("@subid", 0); com.Parameters.AddWithValue("@stdid", 0); com.Parameters.AddWithValue("@lmid", 0); com.Parameters.AddWithValue("@lmlat", t.lmlat); com.Parameters.AddWithValue("@lmlong", t.lmlong); com.Parameters.AddWithValue("@ttlat", t.tlat); com.Parameters.AddWithValue("@ttlong", t.tlong); SetParam(com, "@inlocid", t.pin); try { con.Open(); com.Connection = con; com.ExecuteNonQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Some exception occured:{0}", ex.Message); } finally { con.Close(); } }
public int beTutordetails(ITutor t, string t1, string t2, string t3, string pass) { int reqnum = 0; try { con.Open(); com.Connection = con; com.CommandType = CommandType.StoredProcedure; com.CommandText = "spInsertintoApptutor"; com.Parameters.Add(new SqlParameter("@name", t.name)); com.Parameters.Add(new SqlParameter("@age", t.age)); com.Parameters.Add(new SqlParameter("@gender", t.g)); com.Parameters.Add(new SqlParameter("@exp", t.exp)); com.Parameters.Add(new SqlParameter("@almamater", t.alma)); com.Parameters.Add(new SqlParameter("@fee", t.fee)); com.Parameters.Add(new SqlParameter("@eid", t.eid)); com.Parameters.Add(new SqlParameter("@mob", t.mob)); com.Parameters.Add(new SqlParameter("@pass", pass)); if (t1 == null) { com.Parameters.Add(new SqlParameter("@teachingstr1", DBNull.Value)); } else { com.Parameters.Add(new SqlParameter("@teachingstr1", t1)); } if (t2 == null) { com.Parameters.Add(new SqlParameter("@teachingstr2", DBNull.Value)); } else { com.Parameters.Add(new SqlParameter("@teachingstr2", t2)); } if (t3 == null) { com.Parameters.Add(new SqlParameter("@teachingstr3", DBNull.Value)); } else { com.Parameters.Add(new SqlParameter("@teachingstr3", t1)); } com.Parameters.Add(new SqlParameter("@lat", t.tlat)); com.Parameters.Add(new SqlParameter("@lon", t.tlong)); com.Parameters.Add(new SqlParameter("@type", t.type)); com.Parameters.Add(new SqlParameter("@reqnum", 0)); com.Parameters["@reqnum"].Direction = ParameterDirection.Output; com.ExecuteNonQuery(); return(Convert.ToInt16(com.Parameters["@reqnum"].Value)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Some exception occured:{0}", ex.Message); } finally { con.Close(); } return(reqnum); }
public void AddTutor(ITutor tutorToAdd) { //.... }
public BrowseTutorsController(ITutor tutors, IReserve reserves) { _tutors = tutors; _reserves = reserves; }