Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(CardCenter.Entity.Stock_Commodity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stock_Commodity set ");
            strSql.Append("CommodityName=@CommodityName,");
            strSql.Append("CommodityType=@CommodityType,");
            strSql.Append("AdditionalAttributes=@AdditionalAttributes,");
            strSql.Append("SellingPrice=@SellingPrice,");
            strSql.Append("CostPrice=@CostPrice,");
            strSql.Append("StockDesplay=@StockDesplay,");
            strSql.Append("StockActual=@StockActual");
            strSql.Append(" where Guid=@Guid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CommodityName",        SqlDbType.NVarChar, 128),
                new SqlParameter("@CommodityType",        SqlDbType.NVarChar, 128),
                new SqlParameter("@AdditionalAttributes", SqlDbType.NVarChar, 128),
                new SqlParameter("@SellingPrice",         SqlDbType.Decimal,    9),
                new SqlParameter("@CostPrice",            SqlDbType.Decimal,    9),
                new SqlParameter("@StockDesplay",         SqlDbType.Int,        4),
                new SqlParameter("@StockActual",          SqlDbType.Int,        4),
                new SqlParameter("@Guid",                 SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = model.CommodityName;
            parameters[1].Value = model.CommodityType;
            parameters[2].Value = model.AdditionalAttributes;
            parameters[3].Value = model.SellingPrice;
            parameters[4].Value = model.CostPrice;
            parameters[5].Value = model.StockDesplay;
            parameters[6].Value = model.StockActual;
            parameters[7].Value = model.Guid;

            TranHelper.AddTran(strSql, parameters);
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(CardCenter.Entity.Stock_Commodity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Stock_Commodity(");
            strSql.Append("Guid,CommodityName,CommodityType,AdditionalAttributes,SellingPrice,CostPrice,StockDesplay,StockActual)");
            strSql.Append(" values (");
            strSql.Append("@Guid,@CommodityName,@CommodityType,@AdditionalAttributes,@SellingPrice,@CostPrice,@StockDesplay,@StockActual)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Guid",                 SqlDbType.NVarChar,  64),
                new SqlParameter("@CommodityName",        SqlDbType.NVarChar, 128),
                new SqlParameter("@CommodityType",        SqlDbType.NVarChar, 128),
                new SqlParameter("@AdditionalAttributes", SqlDbType.NVarChar, 128),
                new SqlParameter("@SellingPrice",         SqlDbType.Decimal,    9),
                new SqlParameter("@CostPrice",            SqlDbType.Decimal,    9),
                new SqlParameter("@StockDesplay",         SqlDbType.Int,        4),
                new SqlParameter("@StockActual",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Guid;
            parameters[1].Value = model.CommodityName;
            parameters[2].Value = model.CommodityType;
            parameters[3].Value = model.AdditionalAttributes;
            parameters[4].Value = model.SellingPrice;
            parameters[5].Value = model.CostPrice;
            parameters[6].Value = model.StockDesplay;
            parameters[7].Value = model.StockActual;

            TranHelper.AddTran(strSql, parameters);
        }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateEx(CardCenter.Entity.Stock_Commodity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stock_Commodity set ");
            strSql.Append("CommodityName=@CommodityName,");
            strSql.Append("CommodityType=@CommodityType,");
            strSql.Append("AdditionalAttributes=@AdditionalAttributes,");
            strSql.Append("SellingPrice=@SellingPrice,");
            strSql.Append("CostPrice=@CostPrice,");
            strSql.Append("StockDesplay=@StockDesplay,");
            strSql.Append("StockActual=@StockActual");
            strSql.Append(" where Guid=@Guid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CommodityName",        SqlDbType.NVarChar, 128),
                new SqlParameter("@CommodityType",        SqlDbType.NVarChar, 128),
                new SqlParameter("@AdditionalAttributes", SqlDbType.NVarChar, 128),
                new SqlParameter("@SellingPrice",         SqlDbType.Decimal,    9),
                new SqlParameter("@CostPrice",            SqlDbType.Decimal,    9),
                new SqlParameter("@StockDesplay",         SqlDbType.Int,        4),
                new SqlParameter("@StockActual",          SqlDbType.Int,        4),
                new SqlParameter("@Guid",                 SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = model.CommodityName;
            parameters[1].Value = model.CommodityType;
            parameters[2].Value = model.AdditionalAttributes;
            parameters[3].Value = model.SellingPrice;
            parameters[4].Value = model.CostPrice;
            parameters[5].Value = model.StockDesplay;
            parameters[6].Value = model.StockActual;
            parameters[7].Value = model.Guid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CardCenter.Entity.Stock_Commodity DataRowToEntity(DataRow row)
 {
     CardCenter.Entity.Stock_Commodity model = new CardCenter.Entity.Stock_Commodity();
     if (row != null)
     {
         if (row["Guid"] != null)
         {
             model.Guid = row["Guid"].ToString();
         }
         if (row["CommodityName"] != null)
         {
             model.CommodityName = row["CommodityName"].ToString();
         }
         if (row["CommodityType"] != null)
         {
             model.CommodityType = row["CommodityType"].ToString();
         }
         if (row["AdditionalAttributes"] != null)
         {
             model.AdditionalAttributes = row["AdditionalAttributes"].ToString();
         }
         if (row["SellingPrice"] != null && row["SellingPrice"].ToString() != "")
         {
             model.SellingPrice = decimal.Parse(row["SellingPrice"].ToString());
         }
         if (row["CostPrice"] != null && row["CostPrice"].ToString() != "")
         {
             model.CostPrice = decimal.Parse(row["CostPrice"].ToString());
         }
         if (row["StockDesplay"] != null && row["StockDesplay"].ToString() != "")
         {
             model.StockDesplay = int.Parse(row["StockDesplay"].ToString());
         }
         if (row["StockActual"] != null && row["StockActual"].ToString() != "")
         {
             model.StockActual = int.Parse(row["StockActual"].ToString());
         }
     }
     return(model);
 }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CardCenter.Entity.Stock_Commodity GetEntity(string Guid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Guid,CommodityName,CommodityType,AdditionalAttributes,SellingPrice,CostPrice,StockDesplay,StockActual from Stock_Commodity ");
            strSql.Append(" where Guid=@Guid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Guid", SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = Guid;

            CardCenter.Entity.Stock_Commodity model = new CardCenter.Entity.Stock_Commodity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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