Example #1
0
 public static int save(subch m)
 {
     using (DAL.root.subchDAL dal = new DAL.root.subchDAL())
     {
         if (m.id > 0)
         {
             return(dal.update(m));
         }
         else
         {
             return(dal.save(m));
         }
     }
 }
Example #2
0
 public int save(subch m)
 {
     SqlParameter[] pars =
     {
         new SqlParameter("@sid",      m.sid),
         new SqlParameter("@title ",   m.title),
         new SqlParameter("@subs ",    m.subs),
         new SqlParameter("@A ",       m.A),
         new SqlParameter("@B ",       m.B),
         new SqlParameter("@C ",       m.C),
         new SqlParameter("@D ",       m.D),
         new SqlParameter("@E ",       m.E),
         new SqlParameter("@explain ", m.explain),
         new SqlParameter("@result ",  m.result),
         new SqlParameter("@instate ", m.instate),
         new SqlParameter("@creator ", m.creator),
         new SqlParameter("@retu",     SqlDbType.Int)
     };
     pars[12].Direction = ParameterDirection.ReturnValue;
     SqlHelper.RunProcedure("[root_instCh]", pars);
     return(Convert.ToInt16(pars[12].Value));
 }
Example #3
0
        public int update(subch m)
        {
            string sql = "update ChooseSubject set Title=@title,Subjects=@subs,A=@A,B=@B,C=@C,D=@D,E=@E,result=@result,SubjectClassID=@sid,mender=@mender,mendTime=GETDATE(),explain=@explain,inputState=@instate where ID=@id";

            SqlParameter[] pars =
            {
                new SqlParameter("@id",       m.id),
                new SqlParameter("@sid",      m.sid),
                new SqlParameter("@title ",   m.title),
                new SqlParameter("@subs ",    m.subs),
                new SqlParameter("@A ",       m.A),
                new SqlParameter("@B ",       m.B),
                new SqlParameter("@C ",       m.C),
                new SqlParameter("@D ",       m.D),
                new SqlParameter("@E ",       SqlDbType.NVarChar),
                new SqlParameter("@explain ", SqlDbType.NVarChar),
                new SqlParameter("@result ",  m.result),
                new SqlParameter("@instate ", m.instate),
                new SqlParameter("@mender ",  m.creator)
            };
            if (m.E != "" && m.E != null)
            {
                pars[8].Value = m.E;
            }
            else
            {
                pars[8].Value = DBNull.Value;
            }
            if (m.explain != "" && m.explain != null)
            {
                pars[9].Value = m.explain;
            }
            else
            {
                pars[9].Value = DBNull.Value;
            }
            return(SqlHelper.ExcuteNonQuery(sql, pars));
        }