/// <summary> /// 发送邮件 /// </summary> /// <param name="recid">接受方的uuid</param> /// <param name="sendUid">发送方的UUID</param> /// <param name="title"></param> /// <param name="content"></param> /// <returns></returns> public Boolean InsertChat(string recuid, string sendUid, string title, string content) { string time = DateTime.Now.ToString("yyyy-MM-dd"); //time.Replace('-', '/'); string sql = "insert into Chat (SendUID,RecieveUID,Title,ChatContent,Time,IsRead) values (@sendid,@recid,@title,@content,@time,0)"; //string findsql="select * from tb_User where ID="; //string recUid = ba.ReString(findsql+recid, null, "UUID"); //string sendUid = ba.ReString(findsql + sendid, null, "UUID"); SqlParameter[] pa = { new SqlParameter("@sendid", sendUid), new SqlParameter("@recid", recuid), new SqlParameter("@title", title), new SqlParameter("@content", content), new SqlParameter("@time", time) }; ba.OpenTransaction(); try { ba.ExecNonQuery(sql, pa); ba.Commit(); return(true); } catch { ba.Roback(); return(false); } finally { ba.Close(); } }
public void InsertReservationAndCourse(string tutorid, string stuid, string course, string grade) { string time = DateTime.Now.ToString("yyyy-MM-dd"); string resid; course = course.Substring(0, course.LastIndexOf(',')); string[] courses = course.Split(','); DataSet dscoursename = GetAllCourses(); string gradeid = ""; if (grade.Equals("小学")) { gradeid = "0"; } else if (grade.Equals("初中")) { gradeid = "1"; } else if (grade.Equals("高中")) { gradeid = "2"; } ba.OpenTransaction(); try { resid = this.insertReservation(stuid, tutorid, time, grade); for (int i = 0; i < courses.Length; i++) { string courid = ""; for (int j = 0; j < dscoursename.Tables[0].Rows.Count; j++) { if (courses[i].Equals(dscoursename.Tables[0].Rows[j]["CourseName"].ToString())) { courid = dscoursename.Tables[0].Rows[j]["CourseID"].ToString(); break; } } this.insertCourse(resid, courid, gradeid); } ba.Commit(); } catch (Exception e) { ba.Roback(); throw e; } }
public string InsertTutorInfo(string mail, string psd, string qq, string sex, string name, string uni, string phone, string backtime , string leavetime, string course, string senir, string intro, string photo) { string[] cou = course.Split(','); string[] se = senir.Split(','); ba.OpenTransaction(); try { //string id=ba.ExecStoredProcedure("TutorRegister",pa); string id = InsertTutor(mail, qq, sex, name, uni, phone, backtime, leavetime, intro, photo); InsertUser(mail, psd, 1, id); InsertCourse(cou, se, 50, id); ba.Commit(); return(id); } catch (Exception e) { ba.Roback(); throw e; } }
public void RollBack() { ba.Roback(); }