protected void Button1_Click2(object sender, EventArgs e)
        {
            Model.Score_T   score_T_M   = new Model.Score_T();
            Model.Student_T student_T_M = new Model.Student_T();
            BLL.Score_T     score_T_B   = new BLL.Score_T();
            BLL.Student_T   student_T_B = new BLL.Student_T();
            score_T_M.ScoreNum  = Convert.ToDecimal(ScoreNum.Text);
            score_T_M.StudentID = Convert.ToInt16(student_T_B.GetMaxId());
            student_T_M.Age     = Convert.ToInt16(Age.Text);
            student_T_M.Name    = Name.Text;
            Hashtable ht = new Hashtable();

            SqlParameter[] ScoreParameters =
            {
                new SqlParameter("@StudentID", SqlDbType.Int,     4),
                new SqlParameter("@ScoreNum",  SqlDbType.Decimal, 9)
            };
            ScoreParameters[0].Value = score_T_M.StudentID;
            ScoreParameters[1].Value = score_T_M.ScoreNum;
            SqlParameter[] StudentParameters =
            {
                new SqlParameter("@Name", SqlDbType.NVarChar, 50),
                new SqlParameter("@Age",  SqlDbType.Int, 4)
            };
            StudentParameters[0].Value = student_T_M.Name;
            StudentParameters[1].Value = student_T_M.Age;
            ht.Add("insert into Student_T(Name,Age) values (@Name,@Age)", StudentParameters);
            ht.Add("insert into Score_T(StudentID,ScoreNum) values (@StudentID,@ScoreNum)", ScoreParameters);
            DbHelperSQL.ExecuteSqlTran(ht);//执行sql,实现事务
        }
Exemple #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.Student_T model)
 {
     return(dal.Update(model));
 }
Exemple #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Model.Student_T model)
 {
     return(dal.Add(model));
 }