示例#1
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="model"></param>
 public void Insert(ConfigPriceMe model)
 {
     using (MDbBase db = new MDbBase())
     {
         db.GetCollection <ConfigPriceMe>().Insert(model, false);
     }
 }
示例#2
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="name">价格名称</param>
 /// <param name="Price_Plus">加点</param>
 public void Update(ConfigPriceMe model)
 {
     using (MDbBase db = new MDbBase())
     {
         db.GetCollection <ConfigPriceMe>().Update(model, x => x.name == name);
     }
 }
示例#3
0
 public List <ConfigPriceMe> GetAllConfigPriceMe(string authKey)
 {
     if (islogin(authKey))
     {
         BLL.Data_Centre.ConfigPriceMe bll = new BLL.Data_Centre.ConfigPriceMe();
         return(bll.GetList());
     }
     return(null);
 }
示例#4
0
        public bool SetConfigPriceMe(string authKey, DataTable dt)
        {
            if (islogin(authKey))
            {
                BLL.Data_Centre.ConfigPriceMe bll = new BLL.Data_Centre.ConfigPriceMe();

                foreach (DataRow item in dt.Rows)
                {
                    decimal Price_Plus = Convert.ToDecimal(item["Price_Plus"]);
                    string  CateGory   = Convert.ToString(item["CateGory"]);
                    bll.UpdateToSql(CateGory, Price_Plus);
                }
                return(true);
            }
            return(false);
        }
示例#5
0
        public ConfigPriceMe()
        {
            BLL.DbBase            db = new DbBase();
            System.Data.DataTable dt = db.ExecuteDataSet("SELECT DISTINCT category FROM dbo.Price").Tables[0];
            var model = new ConfigPriceMe(0);

            foreach (System.Data.DataRow item in dt.Rows)
            {
                if (!Exist(item["category"].ToString()))
                {
                    model.id         = MongoDB.Oid.NewOid().ToString();
                    model.name       = item["category"].ToString();
                    model.Price_Plus = 1;
                    Insert(model);
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
示例#6
0
        /// <summary>
        /// 修改价格
        /// </summary>
        /// <param name="id"></param>
        /// <param name="category"></param>
        public void Update(string id, string category)
        {
            string sql = string.Format("UPDATE Price SET price=b.price FROM Price a INNER JOIN Price_TEMP b ON a.ID=b.id AND a.category=b.category WHERE b.ID='{0}' AND b.category='{1}'", id, category);

            ExecuteNonQuery(sql);
            //价格含义
            object o   = ExecuteScalar(string.Format("SELECT TOP 1 sum FROM dbo.Link_Mid WHERE id=(SELECT id FROM dbo.Link WHERE t_id='{0}') AND PriceType<>1", id));
            int    sum = 0;

            if (!Library.Lang.DataValidator.isNULL(o))
            {
                sum = (int)o;
            }
            //加点计算
            decimal d = (decimal)ExecuteScalar(string.Format("SELECT Price_Plus FROM dbo.Price WHERE ID='{0}' AND category='{1}'", id, category));

            if (d > 0)
            {
                if (sum != 0)
                {
                    ExecuteNonQuery(string.Format("UPDATE Price SET Price_N=Price/{2}*Price_Plus  WHERE ID='{0}' AND category='{1}'", id, category, sum));
                }
                else
                {
                    ExecuteNonQuery(string.Format("UPDATE Price SET Price_N=Price*Price_Plus  WHERE ID='{0}' AND category='{1}'", id, category));
                }
            }
            else
            {
                decimal Price_Plus = new ConfigPriceMe().GetPrice_Plus(category);
                if (sum != 0)
                {
                    ExecuteNonQuery(string.Format("UPDATE Price SET Price_N=Price/{2}*{3}  WHERE ID='{0}' AND category='{1}'", id, category, sum, Price_Plus));
                }
                else
                {
                    ExecuteNonQuery(string.Format("UPDATE Price SET Price_N=Price*{2}  WHERE ID='{0}' AND category='{1}'", id, category, Price_Plus));
                }
            }
            InitPriceCache(id);
        }