Exemplo n.º 1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(JY.Model.UserType model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.BigInt,    8),
                new SqlParameter("@UserTypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Remark",       SqlDbType.NText),
                new SqlParameter("@IsDelete",     SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.UserTypeName;
            parameters[2].Value = model.Remark;
            parameters[3].Value = model.IsDelete;

            DbHelperSQL.RunProcedure("UserType_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public long Add(JY.Model.UserType model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.BigInt,    8),
                new SqlParameter("@UserTypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Remark",       SqlDbType.NText),
                new SqlParameter("@IsDelete",     SqlDbType.Bit, 1)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.UserTypeName;
            parameters[2].Value     = model.Remark;
            parameters[3].Value     = model.IsDelete;

            DbHelperSQL.RunProcedure("UserType_ADD", parameters, out rowsAffected);
            return((long)parameters[0].Value);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JY.Model.UserType GetModel(long ID)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            JY.Model.UserType model = new JY.Model.UserType();
            DataSet           ds    = DbHelperSQL.RunProcedure("UserType_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserTypeName"] != null && ds.Tables[0].Rows[0]["UserTypeName"].ToString() != "")
                {
                    model.UserTypeName = ds.Tables[0].Rows[0]["UserTypeName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IsDelete"] != null && ds.Tables[0].Rows[0]["IsDelete"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsDelete"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower() == "true"))
                    {
                        model.IsDelete = true;
                    }
                    else
                    {
                        model.IsDelete = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }