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

            strSql.Append("update SchThdInfo set ");
            strSql.Append("SchId=@SchId,");
            strSql.Append("SysName=@SysName,");
            strSql.Append("SysUrl=@SysUrl,");
            strSql.Append("SysUserNameTips=@SysUserNameTips,");
            strSql.Append("SysUserPwTips=@SysUserPwTips,");
            strSql.Append("SysLoginUrl=@SysLoginUrl,");
            strSql.Append("RecTime=@RecTime,");
            strSql.Append("RecUser=@RecUser,");
            strSql.Append("LastRecTime=@LastRecTime,");
            strSql.Append("LastRecUser=@LastRecUser");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchId",           SqlDbType.Int,              4),
                new SqlParameter("@SysName",         SqlDbType.NVarChar,        50),
                new SqlParameter("@SysUrl",          SqlDbType.VarChar,        500),
                new SqlParameter("@SysUserNameTips", SqlDbType.VarChar,         50),
                new SqlParameter("@SysUserPwTips",   SqlDbType.NVarChar,        50),
                new SqlParameter("@SysLoginUrl",     SqlDbType.VarChar,        500),
                new SqlParameter("@RecTime",         SqlDbType.SmallDateTime),
                new SqlParameter("@RecUser",         SqlDbType.VarChar,         50),
                new SqlParameter("@LastRecTime",     SqlDbType.DateTime),
                new SqlParameter("@LastRecUser",     SqlDbType.VarChar,         20),
                new SqlParameter("@AutoId",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.SchId;
            parameters[1].Value  = model.SysName;
            parameters[2].Value  = model.SysUrl;
            parameters[3].Value  = model.SysUserNameTips;
            parameters[4].Value  = model.SysUserPwTips;
            parameters[5].Value  = model.SysLoginUrl;
            parameters[6].Value  = model.RecTime;
            parameters[7].Value  = model.RecUser;
            parameters[8].Value  = model.LastRecTime;
            parameters[9].Value  = model.LastRecUser;
            parameters[10].Value = model.AutoId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchThdInfo DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchThdInfo model = new SchSystem.Model.SchThdInfo();
     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["SysName"] != null)
         {
             model.SysName = row["SysName"].ToString();
         }
         if (row["SysUrl"] != null)
         {
             model.SysUrl = row["SysUrl"].ToString();
         }
         if (row["SysUserNameTips"] != null)
         {
             model.SysUserNameTips = row["SysUserNameTips"].ToString();
         }
         if (row["SysUserPwTips"] != null)
         {
             model.SysUserPwTips = row["SysUserPwTips"].ToString();
         }
         if (row["SysLoginUrl"] != null)
         {
             model.SysLoginUrl = row["SysLoginUrl"].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);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchThdInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SchThdInfo(");
            strSql.Append("SchId,SysName,SysUrl,SysUserNameTips,SysUserPwTips,SysLoginUrl,RecTime,RecUser,LastRecTime,LastRecUser)");
            strSql.Append(" values (");
            strSql.Append("@SchId,@SysName,@SysUrl,@SysUserNameTips,@SysUserPwTips,@SysLoginUrl,@RecTime,@RecUser,@LastRecTime,@LastRecUser)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchId",           SqlDbType.Int,              4),
                new SqlParameter("@SysName",         SqlDbType.NVarChar,        50),
                new SqlParameter("@SysUrl",          SqlDbType.VarChar,        500),
                new SqlParameter("@SysUserNameTips", SqlDbType.VarChar,         50),
                new SqlParameter("@SysUserPwTips",   SqlDbType.NVarChar,        50),
                new SqlParameter("@SysLoginUrl",     SqlDbType.VarChar,        500),
                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.SysName;
            parameters[2].Value = model.SysUrl;
            parameters[3].Value = model.SysUserNameTips;
            parameters[4].Value = model.SysUserPwTips;
            parameters[5].Value = model.SysLoginUrl;
            parameters[6].Value = model.RecTime;
            parameters[7].Value = model.RecUser;
            parameters[8].Value = model.LastRecTime;
            parameters[9].Value = model.LastRecUser;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SchThdInfo GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 public static Com.DataPack.DataRsp <string> Save(string sendstr, string delAutoId, string schid)
 {
     Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
     if (Com.Session.userid == null)
     {
         rsp.code = "expire";
         rsp.msg  = "页面已经过期,请重新登录";
     }
     else
     {
         try
         {
             SchSystem.BLL.SchThdInfo   bll_th   = new SchSystem.BLL.SchThdInfo();
             SchSystem.Model.SchThdInfo model_th = new SchSystem.Model.SchThdInfo();
             sendstr = Com.Public.SqlEncStr(sendstr);
             if (delAutoId != "")//要删除的AutoId
             {
                 string[] aid = delAutoId.Split(',');
                 if (aid.Length > 0)
                 {
                     for (int i = 0; i < aid.Length; i++)
                     {
                         bll_th.Delete(Convert.ToInt32(aid[i]));
                     }
                 }
             }
             sendstr = sendstr.Replace("u_", "");//UID,UTNAME,SUB,ISMS
             string[] uss = sendstr.Split('|');
             if (uss.Length > 0)
             {
                 foreach (string item in uss)
                 {
                     string[] its = item.Split(',');
                     if (its.Length == 7)
                     {
                         if (its[0] == "0")//its[0]为AutoId 0添加 否则编辑
                         {
                             model_th.SysName         = its[1];
                             model_th.SysUrl          = its[2];
                             model_th.SysUserNameTips = its[3];
                             model_th.SysUserPwTips   = its[4];
                             model_th.SysLoginUrl     = its[5];
                             model_th.RecUser         = Com.Session.userid;
                             model_th.RecTime         = DateTime.Now;
                             model_th.SchId           = Convert.ToInt32(schid);
                             if (bll_th.ExistsSysUrl(its[2].ToString(), Convert.ToInt32(schid)))
                             {
                                 continue;
                             }
                             else
                             {
                                 bll_th.Add(model_th);
                             }
                         }
                         else
                         {
                             model_th.AutoId          = Convert.ToInt32(its[0]);
                             model_th.SysName         = its[1];
                             model_th.SysUrl          = its[2];
                             model_th.SysUserNameTips = its[3];
                             model_th.SysUserPwTips   = its[4];
                             model_th.SysLoginUrl     = its[5];
                             model_th.RecTime         = System.DateTime.Now;
                             model_th.RecUser         = Com.Session.userid.ToString();
                             model_th.SchId           = Convert.ToInt32(schid);
                             bll_th.Update(model_th);
                         }
                     }
                 }
             }
             rsp.code = "success";
             rsp.msg  = "操作成功!";
         }
         catch (Exception ex)
         {
             rsp.code = "error";
             rsp.msg  = ex.Message;
         }
     }
     return(rsp);
 }