/// <summary> /// 更新一条数据 /// </summary> public bool Update(Student.Model.STU_WORKFLOW model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update STU_WORKFLOW set "); strSql.Append("GUIDANCENO=@GUIDANCENO,"); strSql.Append("NODENO=@NODENO,"); strSql.Append("GRADE=@GRADE"); strSql.Append(" where EXECNO=@EXECNO"); SqlParameter[] parameters = { new SqlParameter("@GUIDANCENO", SqlDbType.Decimal, 9), new SqlParameter("@NODENO", SqlDbType.Int, 4), new SqlParameter("@GRADE", SqlDbType.Float, 8), new SqlParameter("@EXECNO", SqlDbType.Decimal, 9) }; parameters[0].Value = model.GUIDANCENO; parameters[1].Value = model.NODENO; parameters[2].Value = model.GRADE; parameters[3].Value = model.EXECNO; int rows = SqlHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Student.Model.STU_WORKFLOW model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into STU_WORKFLOW("); strSql.Append("GUIDANCENO,NODENO,GRADE)"); strSql.Append(" values ("); strSql.Append("@GUIDANCENO,@NODENO,@GRADE)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@GUIDANCENO", SqlDbType.Decimal, 9), new SqlParameter("@NODENO", SqlDbType.Int, 4), new SqlParameter("@GRADE", SqlDbType.Float, 8) }; parameters[0].Value = model.GUIDANCENO; parameters[1].Value = model.NODENO; parameters[2].Value = model.GRADE; object obj = SqlHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Student.Model.STU_WORKFLOW GetModel(decimal EXECNO) { StringBuilder strSql = new StringBuilder(); strSql.Append("select B.EXECNO,TERMNAME,A.STUNO,C.NAME as STUNAME,D.NAME as TEANAME, "); strSql.Append(" F.WORKFLOWNAME,G.NODENAME,B.GRADE "); strSql.Append(" from TEA_STU A,STU_WORKFLOW B,STUDENT_INFO C,TEACHER_INFO D, "); strSql.Append(" TERM_INFO E,WORKFLOW F,WORKNODE G,CLASS_INFO H "); strSql.Append(" where A.GUIDANCENO = B.GUIDANCENO "); strSql.Append(" and A.STUNO = C.STUNO "); strSql.Append(" and A.TEACHERNO = D.TEACHERNO "); strSql.Append(" and A.TERMNO = E.TERMNO "); strSql.Append(" and A.WORKFLOWNO = F.WORKFLOWNO "); strSql.Append(" and B.NODENO = G.NODENO "); strSql.Append("and C.CLASSNO = H.CLASSNO "); strSql.Append(" and B.EXECNO=@EXECNO"); SqlParameter[] parameters = { new SqlParameter("@EXECNO", SqlDbType.Decimal) }; parameters[0].Value = EXECNO; Student.Model.STU_WORKFLOW model = new Student.Model.STU_WORKFLOW(); DataSet ds = SqlHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Student.Model.STU_WORKFLOW DataRowToModel(DataRow row) { Student.Model.STU_WORKFLOW model = new Student.Model.STU_WORKFLOW(); if (row != null) { if (row["EXECNO"] != null && row["EXECNO"].ToString() != "") { model.EXECNO = decimal.Parse(row["EXECNO"].ToString()); } if (row["GUIDANCENO"] != null && row["GUIDANCENO"].ToString() != "") { model.GUIDANCENO = decimal.Parse(row["GUIDANCENO"].ToString()); } if (row["NODENO"] != null && row["NODENO"].ToString() != "") { model.NODENO = int.Parse(row["NODENO"].ToString()); } if (row["GRADE"] != null && row["GRADE"].ToString() != "") { model.GRADE = decimal.Parse(row["GRADE"].ToString()); } } return(model); }