Exemple #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(JY.Model.Product model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",            SqlDbType.BigInt,     8),
                new SqlParameter("@ProductTypeId", SqlDbType.BigInt,     8),
                new SqlParameter("@ProductNo",     SqlDbType.NVarChar,  50),
                new SqlParameter("@ProductName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@ProductPic",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Description",   SqlDbType.NText),
                new SqlParameter("@Brand",         SqlDbType.Int,        4),
                new SqlParameter("@Spec",          SqlDbType.NVarChar,  50),
                new SqlParameter("@MarketPrice",   SqlDbType.Decimal,    9),
                new SqlParameter("@WebsitePrice",  SqlDbType.Decimal,    9),
                new SqlParameter("@ProductClick",  SqlDbType.Int,        4),
                new SqlParameter("@ProductNum",    SqlDbType.Int,        4),
                new SqlParameter("@ProductTotal",  SqlDbType.Decimal,    9),
                new SqlParameter("@SalesVolume",   SqlDbType.Int,        4),
                new SqlParameter("@Sort",          SqlDbType.Int,        4),
                new SqlParameter("@CreateDate",    SqlDbType.DateTime),
                new SqlParameter("@IsDelete",      SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.ProductTypeId;
            parameters[2].Value  = model.ProductNo;
            parameters[3].Value  = model.ProductName;
            parameters[4].Value  = model.ProductPic;
            parameters[5].Value  = model.Description;
            parameters[6].Value  = model.Brand;
            parameters[7].Value  = model.Spec;
            parameters[8].Value  = model.MarketPrice;
            parameters[9].Value  = model.WebsitePrice;
            parameters[10].Value = model.ProductClick;
            parameters[11].Value = model.ProductNum;
            parameters[12].Value = model.ProductTotal;
            parameters[13].Value = model.SalesVolume;
            parameters[14].Value = model.Sort;
            parameters[15].Value = model.CreateDate;
            parameters[16].Value = model.IsDelete;

            DbHelperSQL.RunProcedure("Product_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JY.Model.Product GetModel(long ID)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            JY.Model.Product model = new JY.Model.Product();
            DataSet          ds    = DbHelperSQL.RunProcedure("Product_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]["ProductTypeId"] != null && ds.Tables[0].Rows[0]["ProductTypeId"].ToString() != "")
                {
                    model.ProductTypeId = long.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductNo"] != null && ds.Tables[0].Rows[0]["ProductNo"].ToString() != "")
                {
                    model.ProductNo = ds.Tables[0].Rows[0]["ProductNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "")
                {
                    model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductPic"] != null && ds.Tables[0].Rows[0]["ProductPic"].ToString() != "")
                {
                    model.ProductPic = ds.Tables[0].Rows[0]["ProductPic"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"] != null && ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Brand"] != null && ds.Tables[0].Rows[0]["Brand"].ToString() != "")
                {
                    model.Brand = int.Parse(ds.Tables[0].Rows[0]["Brand"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Spec"] != null && ds.Tables[0].Rows[0]["Spec"].ToString() != "")
                {
                    model.Spec = ds.Tables[0].Rows[0]["Spec"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MarketPrice"] != null && ds.Tables[0].Rows[0]["MarketPrice"].ToString() != "")
                {
                    model.MarketPrice = decimal.Parse(ds.Tables[0].Rows[0]["MarketPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WebsitePrice"] != null && ds.Tables[0].Rows[0]["WebsitePrice"].ToString() != "")
                {
                    model.WebsitePrice = decimal.Parse(ds.Tables[0].Rows[0]["WebsitePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductClick"] != null && ds.Tables[0].Rows[0]["ProductClick"].ToString() != "")
                {
                    model.ProductClick = int.Parse(ds.Tables[0].Rows[0]["ProductClick"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductNum"] != null && ds.Tables[0].Rows[0]["ProductNum"].ToString() != "")
                {
                    model.ProductNum = int.Parse(ds.Tables[0].Rows[0]["ProductNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductTotal"] != null && ds.Tables[0].Rows[0]["ProductTotal"].ToString() != "")
                {
                    model.ProductTotal = decimal.Parse(ds.Tables[0].Rows[0]["ProductTotal"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalesVolume"] != null && ds.Tables[0].Rows[0]["SalesVolume"].ToString() != "")
                {
                    model.SalesVolume = int.Parse(ds.Tables[0].Rows[0]["SalesVolume"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sort"] != null && ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                {
                    model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].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);
            }
        }