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


C# DBA.KuanMaiEntities类代码示例

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


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

示例1: 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

示例2: 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

示例3: BBaseManager

 static BBaseManager()
 {
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         Areas = (from area in db.Common_District select area).ToList<Common_District>();
     }
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:7,代码来源:BBaseManager.cs

示例4: 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

示例5: AddChildShop

        /// <summary>
        /// 
        /// </summary>
        /// <param name="child_shop_id"></param>
        /// <returns></returns>
        public bool AddChildShop(int mall_type,string child_shop_name)
        {
            bool result = false;
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                Shop shop = (from sp in db.Shop where sp.Name == child_shop_name && sp.Mall_Type_ID==mall_type select sp).FirstOrDefault<Shop>();
                if (shop == null)
                {
                    throw new KMJXCException("您要添加的子店铺(" + child_shop_name + ")信息不存在,请先使用子店铺的主账户登录进销存,然后在执行添加子店铺操作");
                }

                if (shop.Parent_Shop_ID > 0)
                {
                    Shop mainshop = (from sp in db.Shop where sp.Shop_ID==shop.Parent_Shop_ID select sp).FirstOrDefault<Shop>();
                    if (mainshop != null)
                    {
                        throw new KMJXCException(child_shop_name+" 已经是 "+mainshop.Name+" 的子店铺,不能重复添加或者添加为别的店铺的子店铺");
                    }
                }

                result = this.AddChildShop(this.Shop, shop);
            }

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

示例6: OnActionExecuting

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            string user_id = filterContext.HttpContext.User.Identity.Name;
            if (string.IsNullOrEmpty(user_id)) {
                filterContext.HttpContext.Response.Redirect("/Home/Login?message=登录信息过期,请重新登录");
            }
            //Verify if the cookie user is a valid user
            UserManager userMgr = new UserManager(int.Parse(user_id),null);
            BUser user = userMgr.CurrentUser;

            if (user == null)
            {
                filterContext.HttpContext.Response.Redirect("/Home/Login?message=登录信息丢失,请重新登录并授权");
            }

            //Verify if logon user already has access token in db
            KuanMaiEntities db = new KuanMaiEntities();

            Access_Token token = (from t in db.Access_Token where t.User_ID == user.ID && t.Mall_Type_ID == user.Type.ID select t).FirstOrDefault<Access_Token>();

            if (token == null) {
                filterContext.HttpContext.Response.Redirect("/Home/Login?message=没有授权信息,请登录并授权");
            }

            //Verify if the existed access token is expired
            long timeNow = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
            if (timeNow >= token.Request_Time + token.Expirse_In)
            {
                filterContext.HttpContext.Response.Redirect("/Home/Login?message=授权信息已经过期,请重新登录并授权");
            }
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:32,代码来源:AccessTokenValidation.cs

示例7: GetCorpInfo

 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public Corp_Info GetCorpInfo()
 {
     Corp_Info info = null;
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         info=(from ci in db.Corp_Info where ci.IsCurrent==true select ci).FirstOrDefault<Corp_Info>();
     }
     return info;
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:13,代码来源:CommonManager.cs

示例8: GetExpresses

 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public List<Express> GetExpresses()
 {
     List<Express> expresses = new List<Express>();
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         expresses=(from express in db.Express orderby express.Express_ID ascending select express).ToList<Express>();
     }
     return expresses;
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:13,代码来源:CommonManager.cs

示例9: GetMallTypes

        public List<Mall_Type> GetMallTypes()
        {
            List<Mall_Type> types = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                types = (from mtype in db.Mall_Type select mtype).ToList<Mall_Type>();
            }

            return types;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:11,代码来源:CommonManager.cs

示例10: GetAreas

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent_id"></param>
        /// <returns></returns>
        public List<Common_District> GetAreas(int parent_id)
        {
            List<Common_District> areas = null;
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var a=(from ass in db.Common_District where ass.upid==parent_id select ass);

                areas = a.ToList<Common_District>();
            }
            return areas;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:16,代码来源:CommonManager.cs

示例11: 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

示例12: GetMallDetail

 /// <summary>
 /// Get mall object by mall id
 /// </summary>
 /// <param name="mall_type_id"></param>
 /// <returns></returns>
 public Mall_Type GetMallDetail(long mall_type_id)
 {
     Mall_Type mall = null;
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         var mt = from malltype in db.Mall_Type where malltype.Mall_Type_ID == mall_type_id select malltype;
         if (mt != null)
         {
             mall = mt.ToList<Mall_Type>()[0];
         }
     }
     return mall;
 }
开发者ID:Bobom,项目名称:kuanmai,代码行数:18,代码来源:MallManager.cs

示例13: GetMallType

        protected Mall_Type GetMallType()
        {
            Mall_Type type = null;
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var t = from tp in db.Mall_Type where tp.Mall_Type_ID == this.Mall_Type_ID select tp;
                if (t.ToList<Mall_Type>().Count == 1)
                {
                    type = t.ToList<Mall_Type>()[0];
                }
            }

            return type;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:14,代码来源:OBaseManager.cs

示例14: 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

示例15: CreateNewUser

        /// <summary>
        /// Create new user
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public BUser CreateNewUser(BUser user)
        {
            if (user == null) {
                throw new UserException("用户实体不能为空引用");
            }

            if (string.IsNullOrEmpty(user.Name)) {
                throw new UserException("用户名不能为空");
            }

            if (this.CurrentUserPermission.ADD_USER == 0)
            {
                throw new UserException("没有权限创建新用户");
            }

            KuanMaiEntities dba = new KuanMaiEntities();
            try
            {
                if (GetUser(user) != null)
                    throw new UserException("用户名已经存在");

                User dbUser = new User();
                dbUser.User_ID = user.ID;
                dbUser.Mall_ID = user.Mall_ID;
                dbUser.Mall_Name = user.Mall_Name;
                dbUser.Name = user.Name;
                dbUser.Mall_Type = user.Type.ID;
                if (user.Parent != null)
                {
                    dbUser.Parent_Mall_ID = user.Parent.Mall_ID;
                    dbUser.Parent_Mall_Name = user.Parent.Mall_Name;
                    dbUser.Parent_User_ID = user.Parent.ID;
                }
                dba.User.Add(dbUser);
                dba.SaveChanges();
                return user;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (dba != null)
                {
                    dba.Dispose();
                }
            }
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:54,代码来源:UserManager.cs


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