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

            strSql.Append("update ServSys set ");
            strSql.Append("SysName=@SysName,");
            strSql.Append("SysCode=@SysCode,");
            strSql.Append("SysUrl=@SysUrl");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SysName", SqlDbType.NVarChar,  50),
                new SqlParameter("@SysCode", SqlDbType.VarChar,   10),
                new SqlParameter("@SysUrl",  SqlDbType.VarChar,  300),
                new SqlParameter("@AutoId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SysName;
            parameters[1].Value = model.SysCode;
            parameters[2].Value = model.SysUrl;
            parameters[3].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 int Add(SchSystem.Model.ServSys model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ServSys(");
            strSql.Append("SysName,SysCode,SysUrl)");
            strSql.Append(" values (");
            strSql.Append("@SysName,@SysCode,@SysUrl)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SysName", SqlDbType.NVarChar, 50),
                new SqlParameter("@SysCode", SqlDbType.VarChar,  10),
                new SqlParameter("@SysUrl",  SqlDbType.VarChar, 300)
            };
            parameters[0].Value = model.SysName;
            parameters[1].Value = model.SysCode;
            parameters[2].Value = model.SysUrl;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.ServSys DataRowToModel(DataRow row)
 {
     SchSystem.Model.ServSys model = new SchSystem.Model.ServSys();
     if (row != null)
     {
         if (row["AutoId"] != null && row["AutoId"].ToString() != "")
         {
             model.AutoId = int.Parse(row["AutoId"].ToString());
         }
         if (row["SysName"] != null)
         {
             model.SysName = row["SysName"].ToString();
         }
         if (row["SysCode"] != null)
         {
             model.SysCode = row["SysCode"].ToString();
         }
         if (row["SysUrl"] != null)
         {
             model.SysUrl = row["SysUrl"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.ServSys GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AutoId,SysName,SysCode,SysUrl from ServSys ");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AutoId;

            SchSystem.Model.ServSys model = new SchSystem.Model.ServSys();
            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> ServSysAddSave(List <string> arr)
 {
     Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
     if (Com.Session.userid == null)
     {
         rsp.code = "expire";
         rsp.msg  = "你现在登录已过期,请重新登录!";
     }
     else
     {
         try
         {
             SchSystem.BLL.ServSys   ssBll   = new SchSystem.BLL.ServSys();
             SchSystem.Model.ServSys ssModel = new SchSystem.Model.ServSys();
             foreach (string str in arr)
             {
                 string[] strarr = str.Split('#');
                 //if (strarr[0] == "schid") { schid = int.Parse(strarr[1]); }
                 if (strarr[0] == "code")
                 {
                     ssModel.SysCode = strarr[1].Trim();
                 }
                 if (strarr[0] == "type")
                 {
                     ssModel.SysName = strarr[1].Trim();
                 }
                 if (strarr[0] == "url")
                 {
                     ssModel.SysUrl = strarr[1].Trim();
                 }
             }
             if (ssModel.SysCode == "" || ssModel.SysName == "" || ssModel.SysUrl == "")
             {
                 rsp.code = "error";
                 rsp.msg  = "操作失败!不允许输入空格";
             }
             else
             {
                 if (getStringLength(ssModel.SysUrl) > 300)
                 {
                     rsp.code = "error";
                     rsp.msg  = "平台域名不允许超过30个字符";
                 }
                 else
                 {
                     bool resbool = ssBll.Exists(ssModel.SysCode);
                     if (!resbool)
                     {
                         int result = ssBll.Add(ssModel);
                         if (result > 0)
                         {
                             rsp.code = "success";
                             rsp.msg  = "操作成功";
                         }
                         else
                         {
                             rsp.code = "error";
                             rsp.msg  = "操作失败";
                         }
                     }
                     else
                     {
                         rsp.code = "PlatCodeRepeat";
                         rsp.msg  = "平台代码不允许重复";
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             rsp.code = "ExcepError";
             rsp.msg  = ex.Message;
         }
     }
     return(rsp);
 }