当前位置: 首页>>代码示例>>C#>>正文


C# KuanMaiEntities.SaveChanges方法代码示例

本文整理汇总了C#中KM.JXC.DBA.KuanMaiEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# KuanMaiEntities.SaveChanges方法的具体用法?C# KuanMaiEntities.SaveChanges怎么用?C# KuanMaiEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KM.JXC.DBA.KuanMaiEntities的用法示例。


在下文中一共展示了KuanMaiEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSupplier

        /// <summary>
        /// Create new supplier
        /// </summary>
        /// <param name="supplier"></param>
        /// <returns></returns>
        public bool CreateSupplier(Supplier supplier)
        {
            bool result = false;

            if (this.CurrentUserPermission.ADD_SUPPLIER == 0)
            {
                throw new KMJXCException("没有权限添加新供应商");
            }

            if (string.IsNullOrEmpty(supplier.Name))
            {
                throw new KMJXCException("供应商名称不能为空");
            }

            if (supplier.User_ID == 0 && this.CurrentUser!=null)
            {
                supplier.User_ID = this.CurrentUser.ID;
            }

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var obj = (from sp in db.Supplier where (sp.Shop_ID == this.Shop.Shop_ID || sp.Shop_ID == this.Main_Shop.Shop_ID) && supplier.Name.Contains(sp.Name) select sp);
                if (obj.ToList<Supplier>().Count > 0)
                {
                    throw new KMJXCException("供应商名称已经存在");
                }
                db.Supplier.Add(supplier);
                db.SaveChanges();
                result = true;
            }

            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:38,代码来源:SupplierManager.cs

示例2: AddProductProperties

        /// <summary>
        /// Add properties for parent product or child product
        /// </summary>
        /// <param name="product_id"></param>
        /// <param name="props"></param>
        /// <returns></returns>
        public bool AddProductProperties(int product_id, List<BProductProperty> props)
        {
            Product dbProduct = this.GetProduct(product_id);
            if (dbProduct == null)
            {
                throw new KMJXCException("产品不存在");
            }

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                if (props != null && props.Count > 0)
                {
                    List<Product_Specifications> specs = (from ps in db.Product_Specifications where ps.Product_ID == dbProduct.Product_ID select ps).ToList<Product_Specifications>();
                    foreach (BProductProperty prop in props)
                    {
                        Product_Specifications ps = (from sp in specs where sp.Product_Spec_ID == prop.PID && sp.Product_Spec_Value_ID == prop.PVID && sp.Product_ID==product_id select sp).FirstOrDefault<Product_Specifications>();
                        if (ps == null)
                        {
                            ps = new Product_Specifications();
                            ps.Product_Spec_Value_ID = prop.PVID;
                            ps.Product_Spec_ID = prop.PID;
                            ps.Product_ID = product_id;
                            db.Product_Specifications.Add(ps);
                        }
                    }
                    db.SaveChanges();
                }
            }

            return true;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:37,代码来源:ProductManager.cs

示例3: CreateNewBug

 /// <summary>
 /// 
 /// </summary>
 /// <param name="bug"></param>
 /// <returns></returns>
 public bool CreateNewBug(BBug bug)
 {
     if (bug.Created_By == null)
     {
         throw new KMJXCException("创建Bug时必须有创建人");
     }
     bool result = false;
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         Bug dbBug = new Bug();
         dbBug.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
         if (bug.Created_By != null)
         {
             dbBug.Created_By = bug.Created_By.ID;
         }
         dbBug.Description = bug.Description;
         if (bug.Feature != null)
         {
             dbBug.Feature = bug.Feature.ID;
         }
         dbBug.Function = 0;
         dbBug.Modified = dbBug.Created;
         dbBug.Modified_By = dbBug.Created_By;
         dbBug.Resolved = 0;
         dbBug.Resolved_By = 0;
         dbBug.Status = 1;
         dbBug.Title = bug.Title;
         db.Bug.Add(dbBug);
         db.SaveChanges();
         result = true;
     }
     return result;
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:38,代码来源:BugManager.cs

示例4: CreateImage

 /// <summary>
 /// 
 /// </summary>
 /// <param name="image"></param>
 /// <returns></returns>
 public bool CreateImage(KM.JXC.DBA.Image image)
 {
     bool result = false;
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         db.Image.Add(image);
         db.SaveChanges();
         result = true;
     }
     return result;
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:16,代码来源:ImageManager.cs

示例5: CreateActionLog

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        public void CreateActionLog(BUserActionLog action)
        {
            if (action == null || action.Shop==null)
            {
                return;
            }
            KuanMaiEntities db = null;
            try
            {
                db = new KuanMaiEntities();
                User_Action_Log log = new User_Action_Log();

                log.Action = action.Action.Action_ID;

                log.Description = action.Description;
                if (action.User != null && action.User.ID > 0)
                {
                    log.User_ID = action.User.ID;
                }
                else
                {
                    log.User_ID = this.CurrentUser.ID;
                }

                log.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                if (string.IsNullOrEmpty(log.Description))
                {
                    log.Description = "";
                }
                log.Shop_ID = action.Shop.ID;
                db.User_Action_Log.Add(log);
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {

            }
            catch (Exception ex)
            {

            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:53,代码来源:UserActionLogManager.cs

示例6: CreateBuyPrice

        /// <summary>
        /// 
        /// </summary>
        /// <param name="buyPrice"></param>
        /// <returns></returns>
        public bool CreateBuyPrice(BBuyPrice buyPrice)
        {
            bool result = false;

            if (this.CurrentUserPermission.CREATE_BUY_PRICE == 0)
            {
                throw new KMJXCException("没有权限创建采购询价单");
            }

            if (buyPrice == null)
            {
                throw new KMJXCException("输入不正确");
            }

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                Buy_Price dbBuyPrice = new Buy_Price();
                if (buyPrice.Created <= 0)
                {
                    dbBuyPrice.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                }

                dbBuyPrice.Shop_ID = this.Shop.Shop_ID;
                if (buyPrice.Shop != null && buyPrice.Shop.ID > 0)
                {
                    dbBuyPrice.Shop_ID = buyPrice.Shop.ID;
                }

                dbBuyPrice.User_ID = this.CurrentUser.ID;
                if (buyPrice.User != null && buyPrice.User.ID > 0)
                {
                    dbBuyPrice.User_ID = buyPrice.User.ID;
                }

                dbBuyPrice.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                dbBuyPrice.Title = buyPrice.Title;
                dbBuyPrice.Description = buyPrice.Desc;
                db.Buy_Price.Add(dbBuyPrice);
                db.SaveChanges();
                result = true;
                if (dbBuyPrice.ID > 0 && buyPrice.Details!=null && buyPrice.Details.Count>0)
                {
                    result = result & this.SaveBuyPriceDetails(buyPrice.Details, dbBuyPrice.ID);
                }
            }

            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:53,代码来源:BuyManager.cs

示例7: DeleteProductImage

        /// <summary>
        /// 
        /// </summary>
        /// <param name="image_id"></param>
        /// <returns></returns>
        public bool DeleteProductImage(int product_id)
        {
            bool result = false;
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                List<Image> images = (from img in db.Image where img.ProductID == product_id select img).ToList<Image>();

                foreach (Image img in images)
                {
                    db.Image.Remove(img);
                }
                db.SaveChanges();
                result = true;
            }
            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:21,代码来源:ImageManager.cs

示例8: DeleteImage

        /// <summary>
        /// 
        /// </summary>
        /// <param name="image_id"></param>
        /// <returns></returns>
        public bool DeleteImage(int image_id,out Image image)
        {
            bool result = false;
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                image=(from img in db.Image where img.ID==image_id select img).FirstOrDefault<Image>();
                if (image == null)
                {
                    throw new KMJXCException("图片不存在");
                }

                db.Image.Remove(image);
                db.SaveChanges();
                result = true;
            }
            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:22,代码来源:ImageManager.cs

示例9: AddNewMall

 /// <summary>
 /// Add new mall in local db
 /// </summary>
 /// <param name="mall"></param>
 /// <returns></returns>
 public bool AddNewMall(Mall_Type mall)
 {
     bool result = false;
     if (mall == null)
     {
         return result;
     }
     if (string.IsNullOrEmpty(mall.Name)) {
         return result;
     }
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         db.Mall_Type.Add(mall);
         db.SaveChanges();
         result = true;
     }
     return result;
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:23,代码来源:MallManager.cs

示例10: DisableCategory

        /// <summary>
        /// 
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public bool DisableCategory(int categoryId)
        {
            bool result = false;
            if (this.CurrentUserPermission.DISABLE_CATEGORY == 0)
            {
                throw new KMJXCException("没有权限禁用类目");
            }
            KuanMaiEntities db = new KuanMaiEntities();
            try
            {
                Product_Class cate=(from pc in db.Product_Class where pc.Product_Class_ID==categoryId select pc).FirstOrDefault<Product_Class>();
                if (cate == null)
                {
                    throw new KMJXCException("要操作的类目不存在");
                }

                cate.Enabled = false;
                db.SaveChanges();
                result = true;
            }
            catch (KMJXCException kex)
            {
                throw kex;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }

            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:42,代码来源:ShopCategoryManager.cs

示例11: AddNewPropValue

        /// <summary>
        /// 
        /// </summary>
        /// <param name="propertyId"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public bool AddNewPropValue(int propertyId, List<string> values)
        {
            bool result = false;
            KuanMaiEntities db = new KuanMaiEntities();

            try
            {
                int[] child_shops = (from c in this.DBChildShops select c.Shop_ID).ToArray<int>();
                Product_Spec ps = (from pc in db.Product_Spec where pc.Product_Spec_ID == propertyId select pc).FirstOrDefault<Product_Spec>();
                if (ps == null)
                {
                    throw new KMJXCException("属性丢失,不能添加属性值");
                }

                if (this.Shop.Shop_ID != this.Main_Shop.Shop_ID)
                {
                    if (ps.Shop_ID == this.Main_Shop.Shop_ID)
                    {
                        throw new KMJXCException("您不能修改主店铺产品库存属性");
                    }

                    if (ps.Shop_ID == this.Shop.Shop_ID)
                    {
                        throw new KMJXCException("您不能其他主店铺产品库存属性");
                    }
                }
                else
                {
                    if (ps.Shop_ID != this.Main_Shop.Shop_ID && !child_shops.Contains(ps.Shop_ID))
                    {
                        throw new KMJXCException("您不能修改其他店铺的产品库存属性,只能修改主店铺或者子店铺产品库存属性");
                    }
                }

                StringBuilder error = new StringBuilder();
                if (values != null && values.Count > 0)
                {

                    foreach (string value in values)
                    {
                        Product_Spec_Value pv = (from psv in db.Product_Spec_Value where psv.Product_Spec_ID == propertyId && psv.Name == value select psv).FirstOrDefault<Product_Spec_Value>();
                        if (pv != null)
                        {
                            error.Append("属性值:"+value+" 已经存在<br/>");
                            continue;
                        }
                        pv = new Product_Spec_Value();
                        pv.Product_Spec_ID = propertyId;
                        pv.Name = value;
                        pv.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                        pv.User_ID = this.CurrentUser.ID;
                        db.Product_Spec_Value.Add(pv);
                    }

                    db.SaveChanges();
                    result = true;
                    if (!string.IsNullOrEmpty(error.ToString()))
                    {
                        result = false;
                        throw new KMJXCException(error.ToString());
                    }
                }

                base.CreateActionLog(new BUserActionLog() { Shop = new BShop { ID = this.Shop.Shop_ID }, Action = new BUserAction() { Action_ID = UserLogAction.CREATE_PRODUCT_PROPERTY }, Description = "" });
            }
            catch (KMJXCException ex)
            {
                throw ex;
            }
            catch (Exception nex)
            {

            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }

            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:89,代码来源:ShopCategoryManager.cs

示例12: CreateCategory

        /// <summary>
        /// Create new category
        /// </summary>
        /// <param name="category">Product_Class object</param>
        /// <returns></returns>
        public bool CreateCategory(BCategory category)
        {
            bool result = false;
            if (category == null)
            {
                throw new KMJXCException("输入错误");
            }

            if (string.IsNullOrEmpty(category.Name))
            {
                throw new KMJXCException("类目名不能为空");
            }

            if (this.CurrentUserPermission.ADD_PRODUCT_CLASS == 0)
            {
                throw new KMJXCException("没有权限添加类目");
            }

            using (KuanMaiEntities db = new KuanMaiEntities())
            {

                Product_Class pc = new Product_Class();
                pc.Create_Time = category.Created;
                pc.Create_User_ID = this.CurrentUser.ID;
                pc.Enabled = true;
                pc.Mall_CID = category.Mall_ID;
                pc.Mall_PCID = category.Mall_PID;
                pc.Name = category.Name;
                pc.Order = category.Order;
                if (category.Shop == null || category.Shop.ID == 0)
                {
                    pc.Shop_ID = this.Shop.Shop_ID;
                }
                else
                {
                    pc.Shop_ID = category.Shop.ID;
                }
                if (category.Parent == null || category.Parent.ID <= 0)
                {
                    pc.Parent_ID = 0;
                }
                else {
                    pc.Parent_ID = category.Parent.ID;
                }

                Product_Class existed = (from ca in db.Product_Class where ca.Name.ToLower() == category.Name.ToLower() && ca.Shop_ID == pc.Shop_ID && ca.Parent_ID==pc.Parent_ID select ca).FirstOrDefault<Product_Class>();
                if (existed != null)
                {
                    if (pc.Parent_ID > 0)
                    {
                        throw new KMJXCException("名为" + category.Name + "的子类目已经存在");
                    }
                    else
                    {
                        throw new KMJXCException("名为" + category.Name + "的类目已经存在");
                    }
                }

                db.Product_Class.Add(pc);
                db.SaveChanges();
                category.ID = pc.Product_Class_ID;
                result = true;
                base.CreateActionLog(new BUserActionLog() { Shop = new BShop { ID = this.Shop.Shop_ID }, Action = new BUserAction() { Action_ID = UserLogAction.CREATE_PRODUCT_CATEGORY }, Description = "" });
            }
            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:71,代码来源:ShopCategoryManager.cs

示例13: CreateProperty

        /// <summary>
        /// 
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="propName"></param>
        /// <param name="propValues"></param>
        /// <returns></returns>
        public BProperty CreateProperty(int categoryId,string propName,List<string> propValues,int shop_id=0)
        {
            BProperty bproperty = null;
            if (string.IsNullOrEmpty(propName))
            {
                throw new KMJXCException("属性名称不能为空");
            }
            KuanMaiEntities db = new KuanMaiEntities();
            try
            {
                var existed = from props in db.Product_Spec where props.Name==propName select props;

                if (categoryId > 0)
                {
                    //existed = existed.Where(a=>a.Product_Class_ID==categoryId);
                }

                if (this.Shop.Parent_Shop_ID > 0)
                {
                    var pexisted = existed.Where(a=>a.Shop_ID==this.Main_Shop.Shop_ID);
                    if (pexisted.FirstOrDefault<Product_Spec>() != null)
                    {
                        throw new KMJXCException("主店铺已经有此属性,不能重复创建,请使用现有主店铺的属性");
                    }
                }

                existed = existed.Where(a => a.Shop_ID == this.Shop.Shop_ID);
                if (existed.FirstOrDefault<Product_Spec>() != null)
                {
                    throw new KMJXCException("此属性已经存在,不能重复创建");
                }

                Product_Spec property = new Product_Spec();
                property.Product_Class_ID = categoryId;
                property.Name = propName;
                property.User_ID = this.CurrentUser.ID;
                property.Shop_ID = this.Shop.Shop_ID;
                if (shop_id > 0)
                {
                    property.Shop_ID = shop_id;
                }
                property.Mall_PID = "";
                property.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                db.Product_Spec.Add(property);
                db.SaveChanges();
                if (property.Product_Spec_ID <= 0)
                {
                    throw new KMJXCException("属性创建失败");
                }
                bproperty = new BProperty();
                bproperty.ID = property.Product_Spec_ID;
                bproperty.Created_By = this.CurrentUser;
                bproperty.Created = (int)property.Created;
                bproperty.CategoryId = categoryId;
                bproperty.MID = "";
                bproperty.Name = propName;

                if (propValues != null)
                {
                    if (bproperty.Values == null)
                    {
                        bproperty.Values = new List<Product_Spec_Value>();
                    }
                    foreach (string v in propValues)
                    {
                        Product_Spec_Value psv = new Product_Spec_Value();
                        psv.Mall_PVID = "";
                        psv.Name = v;
                        psv.Product_Spec_ID = property.Product_Spec_ID;
                        psv.Product_Spec_Value_ID = 0;
                        psv.User_ID = this.CurrentUser.ID;
                        psv.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                        db.Product_Spec_Value.Add(psv);
                    }
                    db.SaveChanges();
                    bproperty.Values=(from pv in db.Product_Spec_Value where pv.Product_Spec_ID==property.Product_Spec_ID select pv).ToList<Product_Spec_Value>();
                }
            }
            catch(KMJXCException ex)
            {
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }
            return bproperty;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:98,代码来源:ShopCategoryManager.cs

示例14: UpdateStatus

        public void UpdateStatus(int bug_id, int status)
        {
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                Bug bug=(from b in db.Bug where b.ID==bug_id select b).FirstOrDefault<Bug>();
                if (bug == null)
                {
                    throw new KMJXCException("编号为:"+bug_id+" 的问题不存在");
                }

                Bug_Status dbStatus=(from s in db.Bug_Status where s.ID==status select s).FirstOrDefault<Bug_Status>();
                if (dbStatus == null)
                {
                    throw new KMJXCException("状态数据:"+status+" 为无效数据");
                }

                if (bug.Status == status)
                {
                    throw new KMJXCException("当前的状态为:"+dbStatus.Status+", 选择其他状态进行设置");
                }

                bug.Status = status;
                db.SaveChanges();
            }
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:25,代码来源:BugManager.cs

示例15: BatchUpdatePropertiesCategory

        /// <summary>
        /// 
        /// </summary>
        /// <param name="property_ids"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public bool BatchUpdatePropertiesCategory(int[] property_ids, int category)
        {
            bool result = false;
            if (this.CurrentUserPermission.UPDATE_PORPERTY==0)
            {
                throw new KMJXCException("没有权限修改属性");
            }

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                List<Product_Spec> properties=(from p in db.Product_Spec where property_ids.Contains(p.Product_Spec_ID) select p).ToList<Product_Spec>();
                foreach (Product_Spec prop in properties)
                {
                    prop.Product_Class_ID = category;
                }

                db.SaveChanges();
                result = true;
            }
            return result;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:27,代码来源:ShopCategoryManager.cs


注:本文中的KM.JXC.DBA.KuanMaiEntities.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。