Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.SysUType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SysUType set ");
            strSql.Append("UTypeName=@UTypeName,");

            strSql.Append("Stat=@Stat");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UTypeName", SqlDbType.NVarChar, 10),
                new SqlParameter("@Stat",      SqlDbType.TinyInt,   1),
                new SqlParameter("@AutoId",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UTypeName;
            parameters[1].Value = model.Stat;
            parameters[2].Value = model.AutoId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SysUType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SysUType(");
            strSql.Append("UTypeName,UTypeCode,Stat)");
            strSql.Append(" values (");
            strSql.Append("@UTypeName,@UTypeCode,@Stat)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UTypeName", SqlDbType.NVarChar, 10),
                new SqlParameter("@UTypeCode", SqlDbType.VarChar,  10),
                new SqlParameter("@Stat",      SqlDbType.TinyInt, 1)
            };
            parameters[0].Value = model.UTypeName;
            parameters[1].Value = model.UTypeCode;
            parameters[2].Value = model.Stat;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string SysType = Request.Params["systype"].ToString();

            if (SysType == "e")//修改,不能修改用户的类型及学校参数
            {
                btname = "修改";
                id     = Request.Params["autoid"].ToString();
                //先得到操作类型
                SchSystem.BLL.SysUType   bll   = new SchSystem.BLL.SysUType();
                SchSystem.Model.SysUType model = bll.GetModel(int.Parse(id));
                if (model != null && model.AutoId > 0)
                {
                    code = model.UTypeCode;
                    name = model.UTypeName;
                    stat = model.Stat.ToString();
                }
                else
                {
                    Response.Write("无该名称!");
                    Response.End();
                }
            }
            else//不在添加及修改之内,则返回
            {
            }
        }
Пример #4
0
 public static Com.DataPack.DataRsp <string> save(string Name, string stat, string AutoId)
 {
     Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
     if (Com.Session.userid == null)
     {
         rsp.code = "expire";
         rsp.msg  = "页面已经过期,请重新登录";
     }
     else
     {
         try
         {
             SchSystem.BLL.SysUType   SysUType_bll   = new SchSystem.BLL.SysUType();
             SchSystem.Model.SysUType SysUType_model = new SchSystem.Model.SysUType();
             SysUType_model.UTypeName = Com.Public.SqlEncStr(Name.Trim()).ToString();
             SysUType_model.Stat      = Convert.ToInt32(Com.Public.SqlEncStr(stat));
             if (AutoId != "")
             {
                 SysUType_model.AutoId = Convert.ToInt32(AutoId);
                 if (SysUType_bll.Update(SysUType_model))
                 {
                     rsp.code = "success";
                     rsp.msg  = "修改成功";
                 }
             }
             else
             {
                 DataTable dt = SysUType_bll.GetList("top 1 UTypeCode", " 1=1 order by UTypeCode DESC").Tables[0];
                 if (dt != null && dt.Rows.Count > 0)
                 {
                     string Code = dt.Rows[0]["UTypeCode"].ToString();
                     SysUType_model.UTypeCode = (int.Parse(Code) + 1).ToString("00");
                 }
                 else
                 {
                     SysUType_model.UTypeCode = "01";
                 }
                 if (SysUType_bll.Add(SysUType_model) != 0)
                 {
                     rsp.code = "success";
                     rsp.msg  = "添加成功";
                 }
             }
         }
         catch (Exception ex)
         {
             rsp.code = "error";
             rsp.msg  = ex.Message;
         }
     }
     return(rsp);
 }
Пример #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SysUType DataRowToModel(DataRow row)
 {
     SchSystem.Model.SysUType model = new SchSystem.Model.SysUType();
     if (row != null)
     {
         if (row["AutoId"] != null && row["AutoId"].ToString() != "")
         {
             model.AutoId = int.Parse(row["AutoId"].ToString());
         }
         if (row["UTypeName"] != null)
         {
             model.UTypeName = row["UTypeName"].ToString();
         }
         if (row["UTypeCode"] != null)
         {
             model.UTypeCode = row["UTypeCode"].ToString();
         }
         if (row["Stat"] != null && row["Stat"].ToString() != "")
         {
             model.Stat = int.Parse(row["Stat"].ToString());
         }
     }
     return(model);
 }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SysUType GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AutoId,UTypeName,UTypeCode,Stat from SysUType ");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AutoId;

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

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