Example #1
0
 /// <summary>
 /// 批量更新数据
 /// </summary>
 /// <param name="list"></param>
 public void Update(List <Config> list)
 {
     using (MDbBase db = new MDbBase())
     {
         foreach (var item in list)
         {
             if (db.GetCollection <Config>().Count(x => x.id == item.id) > 0)
             {
                 var model = GetModel(item.id);
                 //这里不修改加点设置
                 item.discountRate = model.discountRate;
                 db.GetCollection <Config>().Update(item, x => x.id == item.id);
             }
             else
             {
                 db.GetCollection <Config>().Insert(item);
             }
         }
         var all = GetAllList();
         foreach (var item in all)
         {
             if (list.Find(x => x.id == item.id) == null)
             {
                 db.GetCollection <Config>().Remove(x => x.id == item.id);
             }
         }
     }
 }
Example #2
0
 public GlobalConfig GetModle()
 {
     using (MDbBase db = new MDbBase())
     {
         if (db.GetCollection <GlobalConfig>().Linq().Count() == 0)
         {
             var m = new GlobalConfig();
             m.Stocklimit = 30;
             return(m);
         }
         return(db.GetCollection <GlobalConfig>().Linq().Where(x => x.id == "1").FirstOrDefault());
     }
 }
Example #3
0
 public void Update(Config model)
 {
     using (MDbBase db = new MDbBase())
     {
         if (db.GetCollection <Config>().Linq().Where(x => x.id == model.id).Count() == 0)
         {
             db.GetCollection <Config>().Insert(model);
         }
         else
         {
             db.GetCollection <Config>().Update(model, x => x.id == model.id);
         }
     }
 }
Example #4
0
 /// <summary>
 /// 更新配置
 /// </summary>
 /// <param name="mode"></param>
 public void Update(GlobalConfig mode)
 {
     mode.id = "1";
     using (MDbBase db = new MDbBase())
     {
         if (db.GetCollection <GlobalConfig>().Count() == 0)
         {
             db.GetCollection <GlobalConfig>().Insert(mode);
         }
         else
         {
             db.GetCollection <GlobalConfig>().Update(mode);
         }
     }
 }
Example #5
0
 /// <summary>
 /// 取得采购员
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public string GetCgy(string id)
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <Config>().FindOne(x => x.id == id).cgy);
     }
 }
Example #6
0
 public List <Config> GetAllList()
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <Config>().FindAll().Documents.OrderBy(x => x.id).ToList());
     }
 }
Example #7
0
 public Config GetModel(string iden)
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <Config>().Linq().Where(x => x.id == iden).FirstOrDefault());
     }
 }
Example #8
0
 /// <summary>
 /// 取得所有加点数据
 /// </summary>
 /// <returns></returns>
 public List <ConfigPriceMe> GetList()
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <ConfigPriceMe>().FindAll().Documents.ToList());
     }
 }
Example #9
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="model"></param>
 public void Insert(ConfigPriceMe model)
 {
     using (MDbBase db = new MDbBase())
     {
         db.GetCollection <ConfigPriceMe>().Insert(model, false);
     }
 }
Example #10
0
        public void UpdateToSql(string category, decimal price_plus)
        {
            BLL.DbBase db     = new DbBase();
            string     SqlStr = string.Format("SELECT ID FROM Price WHERE category='{0}' AND Price_Plus=0", category);
            DataTable  dt     = db.ExecuteTable(SqlStr);

            if (dt != null && dt.Rows.Count > 0)
            {
                //更新MongoDatabase
                var UpdateObj = GetList().Find(o => o.name == category);
                UpdateObj.Price_Plus = (float)price_plus;
                using (MDbBase mdb = new MDbBase())
                {
                    mdb.GetCollection <ConfigPriceMe>().Update(UpdateObj, o => o.id == UpdateObj.id);
                }
                //阻塞500毫秒(预防)
                Thread.Sleep(500);

                Price price = null;
                foreach (DataRow item in dt.Rows)
                {
                    string ID = item["ID"].ToString();
                    price = new Price();
                    //价格更新
                    price.Update(ID, category);
                }
            }
        }
Example #11
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);
     }
 }
Example #12
0
 /// <summary>
 /// 判断是否可以执行
 /// </summary>
 /// <param name="mark"></param>
 /// <returns></returns>
 public bool IsExcu(int h)
 {
     using (MDbBase db = new MDbBase())
     {
         int c = db.GetCollection <AutoSupplySwitchLog>().Linq().Where(x => x.mark == DateTime.Now.ToString("yyyy-MM-dd") + ":" + h).Count();
         return(c == 0);
     }
 }
Example #13
0
 public void insert(int h)
 {
     using (MDbBase db = new MDbBase())
     {
         this.mark = DateTime.Now.ToString("yyyy-MM-dd") + ":" + h;
         id        = MongoDB.Oid.NewOid().ToString();
         db.GetCollection <AutoSupplySwitchLog>().Insert(this);
     }
 }
Example #14
0
 /// <summary>
 /// 是否存在
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public bool Exist(string name)
 {
     using (MDbBase db = new MDbBase())
     {
         try
         {
             return(db.GetCollection <ConfigPriceMe>().Linq().Where(x => x.name == name).Count() > 0);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }