예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Garfield.Model.CRM_product_category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CRM_product_category set ");
            strSql.Append("product_category=@product_category,");
            strSql.Append("parentid=@parentid,");
            strSql.Append("product_icon=@product_icon");

            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@product_category", SqlDbType.VarChar, 250),
                new SqlParameter("@parentid",         SqlDbType.Int,       4),
                new SqlParameter("@product_icon",     SqlDbType.VarChar, 250),
                new SqlParameter("@id",               SqlDbType.Int, 4)
            };
            parameters[0].Value = model.product_category;
            parameters[1].Value = model.parentid;
            parameters[2].Value = model.product_icon;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Garfield.Model.CRM_product_category GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,product_category,parentid,product_icon,isDelete,Delete_id,Delete_time from CRM_product_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["product_category"] != null && ds.Tables[0].Rows[0]["product_category"].ToString() != "")
                {
                    model.product_category = ds.Tables[0].Rows[0]["product_category"].ToString();
                }
                if (ds.Tables[0].Rows[0]["parentid"] != null && ds.Tables[0].Rows[0]["parentid"].ToString() != "")
                {
                    model.parentid = int.Parse(ds.Tables[0].Rows[0]["parentid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["product_icon"] != null && ds.Tables[0].Rows[0]["product_icon"].ToString() != "")
                {
                    model.product_icon = ds.Tables[0].Rows[0]["product_icon"].ToString();
                }
                if (ds.Tables[0].Rows[0]["isDelete"] != null && ds.Tables[0].Rows[0]["isDelete"].ToString() != "")
                {
                    model.isDelete = int.Parse(ds.Tables[0].Rows[0]["isDelete"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Delete_id"] != null && ds.Tables[0].Rows[0]["Delete_id"].ToString() != "")
                {
                    model.Delete_id = int.Parse(ds.Tables[0].Rows[0]["Delete_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Delete_time"] != null && ds.Tables[0].Rows[0]["Delete_time"].ToString() != "")
                {
                    model.Delete_time = DateTime.Parse(ds.Tables[0].Rows[0]["Delete_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Garfield.Model.CRM_product_category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CRM_product_category(");
            strSql.Append("product_category,parentid,product_icon,isDelete,Delete_id,Delete_time)");
            strSql.Append(" values (");
            strSql.Append("@product_category,@parentid,@product_icon,@isDelete,@Delete_id,@Delete_time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@product_category", SqlDbType.VarChar, 250),
                new SqlParameter("@parentid",         SqlDbType.Int,       4),
                new SqlParameter("@product_icon",     SqlDbType.VarChar, 250),
                new SqlParameter("@isDelete",         SqlDbType.Int,       4),
                new SqlParameter("@Delete_id",        SqlDbType.Int,       4),
                new SqlParameter("@Delete_time",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.product_category;
            parameters[1].Value = model.parentid;
            parameters[2].Value = model.product_icon;
            parameters[3].Value = model.isDelete;
            parameters[4].Value = model.Delete_id;
            parameters[5].Value = model.Delete_time;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }