Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.SchAppRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SchAppRole set ");
            //strSql.Append("SchId=@SchId,");
            strSql.Append("AppStr=@AppStr,");
            //strSql.Append("RecTime=@RecTime,");
            //strSql.Append("RecUser=@RecUser,");
            strSql.Append("LastRecTime=@LastRecTime,");
            strSql.Append("LastRecUser=@LastRecUser");
            strSql.Append(" where SchId=@SchId");
            SqlParameter[] parameters =
            {
                //new SqlParameter("@SchId", SqlDbType.Int,4),
                new SqlParameter("@AppStr",      SqlDbType.VarChar,   100),
                //new SqlParameter("@RecTime", SqlDbType.SmallDateTime),
                //new SqlParameter("@RecUser", SqlDbType.VarChar,50),
                new SqlParameter("@LastRecTime", SqlDbType.DateTime),
                new SqlParameter("@LastRecUser", SqlDbType.VarChar,    20),
                new SqlParameter("@SchId",       SqlDbType.Int, 6)
            };
            //parameters[0].Value = model.SchId;
            parameters[0].Value = model.AppStr;
            //parameters[1].Value = model.RecTime;
            //parameters[2].Value = model.RecUser;
            parameters[1].Value = model.LastRecTime;
            parameters[2].Value = model.LastRecUser;
            parameters[3].Value = model.SchId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加子系统
 /// </summary>
 /// <param name="sonsys"></param>
 /// <param name="schid"></param>
 public static void SonSysAdd(string sonsys, int schid)
 {
     if (sonsys != "")
     {
         SchSystem.BLL.SchAppRole   sarBll   = new SchSystem.BLL.SchAppRole();
         SchSystem.Model.SchAppRole sarModel = new SchSystem.Model.SchAppRole();
         sarModel.SchId  = schid;
         sarModel.AppStr = sonsys;
         if (sarBll.SchAppExists(schid))
         {
             sarModel.LastRecTime = DateTime.Now;
             sarModel.LastRecUser = Com.Session.userid;
             sarBll.Update(sarModel);
         }
         else
         {
             sarModel.RecTime = DateTime.Now;
             sarModel.RecUser = Com.Session.userid;
             sarBll.Add(sarModel);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchAppRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SchAppRole(");
            strSql.Append("SchId,AppStr,RecTime,RecUser)");
            strSql.Append(" values (");
            strSql.Append("@SchId,@AppStr,@RecTime,@RecUser)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchId",   SqlDbType.Int,              6),
                new SqlParameter("@AppStr",  SqlDbType.VarChar,        100),
                new SqlParameter("@RecTime", SqlDbType.SmallDateTime),
                new SqlParameter("@RecUser", SqlDbType.VarChar, 50)                       //,
                //new SqlParameter("@LastRecTime", SqlDbType.DateTime),
                //new SqlParameter("@LastRecUser", SqlDbType.VarChar,20)
            };
            parameters[0].Value = model.SchId;
            parameters[1].Value = model.AppStr;
            parameters[2].Value = model.RecTime;
            parameters[3].Value = model.RecUser;
            //parameters[4].Value = model.LastRecTime;
            //parameters[5].Value = model.LastRecUser;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchAppRole DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchAppRole model = new SchSystem.Model.SchAppRole();
     if (row != null)
     {
         if (row["AutoId"] != null && row["AutoId"].ToString() != "")
         {
             model.AutoId = int.Parse(row["AutoId"].ToString());
         }
         if (row["SchId"] != null && row["SchId"].ToString() != "")
         {
             model.SchId = int.Parse(row["SchId"].ToString());
         }
         if (row["AppStr"] != null)
         {
             model.AppStr = row["AppStr"].ToString();
         }
         if (row["RecTime"] != null && row["RecTime"].ToString() != "")
         {
             model.RecTime = DateTime.Parse(row["RecTime"].ToString());
         }
         if (row["RecUser"] != null)
         {
             model.RecUser = row["RecUser"].ToString();
         }
         if (row["LastRecTime"] != null && row["LastRecTime"].ToString() != "")
         {
             model.LastRecTime = DateTime.Parse(row["LastRecTime"].ToString());
         }
         if (row["LastRecUser"] != null)
         {
             model.LastRecUser = row["LastRecUser"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SchAppRole GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AutoId,SchId,AppStr,RecTime,RecUser,LastRecTime,LastRecUser from SchAppRole ");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AutoId;

            SchSystem.Model.SchAppRole model = new SchSystem.Model.SchAppRole();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }