Ejemplo n.º 1
0
    private void ClickBtAddCoin()
    {
        LShop shop = (LShop)UILayerController.Instance.ShowLayer(UILayerKey.LShop, DataResourceLobby.instance.listObjLayer[0]);

        shop.listToggleMenu[(int)IndexViewShop.CHANGE_COIN].isOn = true;
        AudioAssistant.Instance.Shot(StringHelper.SOUND_GATE_BT);
    }
Ejemplo n.º 2
0
 public void OpenSend(string nameGame)
 {
     Close();
     LShop lshop = (LShop)UILayerController.Instance.GetLayer(UILayerKey.LShop);
     ViewTransfer transfer = (ViewTransfer)lshop.listViewTypeShop[(int)IndexViewShop.TRANSFER];
     lshop.listToggleMenu[(int)IndexViewShop.TRANSFER].isOn = true;
     transfer.inputFieldNameDisplay.text = nameGame;
     transfer.inputFieldNameDisplayAgain.text = nameGame;
 }
Ejemplo n.º 3
0
 private void GetUserById(int user_id)
 {
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         var cu = from us in db.User
                  join mtype in db.Mall_Type on us.Mall_Type equals mtype.Mall_Type_ID into lMtype
                  from l_mtype in lMtype.DefaultIfEmpty()
                  join shop in db.Shop on us.Shop_ID equals shop.Shop_ID into LShop
                  from l_shop in LShop.DefaultIfEmpty()
                  where us.User_ID == user_id
                  select new BUser
         {
             //EmployeeInfo = (from employee in db.Employee
             //                where employee.User_ID == us.User_ID
             //                select new BEmployee
             //                {
             //                    ID = employee.Employee_ID,
             //                    Name = employee.Name
             //                }).FirstOrDefault<BEmployee>(),
             ID        = us.User_ID,
             Mall_ID   = us.Mall_ID,
             Mall_Name = us.Mall_Name,
             Name      = us.Name,
             Parent_ID = (int)us.Parent_User_ID,
             Password  = us.Password,
             Type      = new BMallType
             {
                 ID   = l_mtype.Mall_Type_ID,
                 Name = l_mtype.Name
             },
             Shop = l_shop != null ?
                    new BShop {
                 ID    = l_shop.Shop_ID,
                 Title = l_shop.Name
             }
                      : new BShop {
                 ID    = 0,
                 Title = ""
             },
             IsSystemUser = us.IsSystemUser
         };
         this.CurrentUser = cu.ToList <BUser>()[0];
         if (this.CurrentUser != null && this.CurrentUser.Parent_ID > 0 && !string.IsNullOrEmpty(this.CurrentUser.Parent.Mall_ID))
         {
             this.MainUser = (from us in db.User
                              where us.User_ID == this.CurrentUser.Parent_ID
                              select new BUser
             {
                 EmployeeInfo = (from employee in db.Employee
                                 where employee.User_ID == us.User_ID
                                 select new BEmployee
                 {
                     ID = employee.Employee_ID,
                     Name = employee.Name
                 }).FirstOrDefault <BEmployee>(),
                 ID = us.User_ID,
                 Mall_ID = us.Mall_ID,
                 Mall_Name = us.Mall_Name,
                 Name = us.Name,
                 Parent = null,
                 Parent_ID = (int)us.Parent_User_ID,
                 Password = us.Password,
                 Type = (from mtype in db.Mall_Type
                         where mtype.Mall_Type_ID == us.Mall_Type
                         select new BMallType
                 {
                     ID = mtype.Mall_Type_ID,
                     Name = mtype.Name,
                     Description = mtype.Description
                 }).FirstOrDefault <BMallType>(),
                 IsSystemUser = us.IsSystemUser
             }).FirstOrDefault <BUser>();
         }
         else
         {
             this.MainUser = this.CurrentUser;
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Get supplier detail information include products
        /// </summary>
        /// <param name="supplier_id">supplier id</param>
        /// <returns>Instance of BSupplier object</returns>
        public BSupplier GetSupplierFullInfo(int supplier_id, bool getProduct = false)
        {
            BSupplier supplier = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                supplier = (from s in db.Supplier
                            join user in db.User on s.User_ID equals user.User_ID into LUser
                            from l_user in LUser.DefaultIfEmpty()
                            join shop in db.Shop on s.Shop_ID equals shop.Shop_ID into LShop
                            from l_shop in LShop.DefaultIfEmpty()
                            join city in db.Common_District on s.City_ID equals city.id into LCity
                            from l_city in LCity.DefaultIfEmpty()
                            join province in db.Common_District on s.Province_ID equals province.id into LProvince
                            from l_province in LProvince.DefaultIfEmpty()
                            where s.Supplier_ID == supplier_id
                            select new BSupplier
                {
                    ID = s.Supplier_ID,
                    Name = s.Name,
                    Address = s.Address,
                    City = l_city != null ? new BArea {
                        ID = l_city.id, Name = l_city.name
                    } : new BArea {
                        ID = 0, Name = ""
                    },
                    ContactPerson = s.Contact_Person,
                    Created = s.Create_Time,
                    Created_By = l_user != null ? new BUser
                    {
                        ID = l_user.User_ID,
                        Name = l_user.Name,
                        Mall_ID = l_user.Mall_ID,
                        Mall_Name = l_user.Mall_Name
                    } : new BUser
                    {
                        ID = 0,
                        Name = "",
                        Mall_ID = "",
                        Mall_Name = ""
                    },
                    Enable = (bool)s.Enabled,
                    Fax = s.Fax,
                    Phone = s.Phone,
                    Province = l_province != null ? new BArea {
                        ID = l_province.id, Name = l_province.name
                    } : new BArea {
                        ID = 0, Name = ""
                    },
                    Remark = s.Remark,
                    Shop = l_shop != null ? new BShop
                    {
                        ID = l_shop.Shop_ID,
                        Title = l_shop.Name
                    } : new BShop
                    {
                        ID = 0,
                        Title = ""
                    }
                }).FirstOrDefault <BSupplier>();

                if (supplier != null && getProduct)
                {
                    List <BProduct> products   = null;
                    var             productIds = from s in db.Product_Supplier
                                                 where s.Supplier_ID == supplier.ID && s.Enabled == true
                                                 select s.Product_ID;

                    products = (from p in db.Product
                                where p.Parent_ID == 0 && productIds.Contains(p.Product_ID)
                                select new BProduct
                    {
                        ID = p.Product_ID,
                        Title = p.Name
                    }).ToList <BProduct>();

                    supplier.Products = products;
                }
            }
            return(supplier);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="action"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public List <BUserActionLog> SearchUserActionLog(int user_id, int action, long date1, long date2, int page, int pageSize, out int total)
        {
            total = 0;
            List <BUserActionLog> actions = new List <BUserActionLog>();

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var tmp = from log in db.User_Action_Log
                          select log;

                if (user_id > 0)
                {
                    tmp = tmp.Where(l => l.User_ID == user_id);
                }

                if (action > 0)
                {
                    tmp = tmp.Where(l => l.Action == action);
                }

                if (page <= 0)
                {
                    page = 1;
                }

                if (pageSize <= 0)
                {
                    pageSize = 30;
                }

                if (date1 > 0)
                {
                    tmp = tmp.Where(l => l.Created >= date1);
                }

                if (date2 > 0)
                {
                    tmp = tmp.Where(l => l.Created <= date2);
                }

                total   = tmp.Count();
                actions = (from log in tmp
                           join ac in db.User_Action on log.Action equals ac.Action_ID into LAction
                           from l_ac in LAction.DefaultIfEmpty()
                           join user in db.User on log.User_ID equals user.User_ID into LUser
                           from l_user in LUser.DefaultIfEmpty()
                           join shop in db.Shop on log.Shop_ID equals shop.Shop_ID into LShop
                           from l_shop in LShop.DefaultIfEmpty()
                           select new BUserActionLog
                {
                    Action = new BUserAction
                    {
                        Action_Desc = l_ac.Action_Description,
                        Action_ID = log.Action,
                        Action_Name = l_ac.Action_Name,
                        Created = l_ac.Created,
                        ID = l_ac.ID
                    },
                    Created = log.Created,
                    Description = log.Description,
                    ID = log.ID,
                    User = new BUser
                    {
                        ID = log.User_ID,
                        Name = l_user.Name,
                        Mall_ID = l_user.Mall_ID,
                        Mall_Name = l_user.Mall_Name
                    },
                    Shop = l_shop != null ?
                           new BShop
                    {
                        ID = log.Shop_ID,
                        Title = l_shop.Name
                    } : new BShop
                    {
                        ID = 0,
                        Title = ""
                    }
                }).OrderByDescending(a => a.ID).Skip((page - 1) * pageSize).Take(pageSize).ToList <BUserActionLog>();
            }

            return(actions);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets buy orders report in json format
        /// </summary>
        /// <param name="startDate">Buy order start date</param>
        /// <param name="endDate">Buy order end date</param>
        /// <param name="product_id">A array of product ids</param>
        /// <param name="page">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <param name="totalProducts">Total records according to the conditions</param>
        /// <param name="paging">Paging(true/false)</param>
        /// <returns></returns>
        public JToken[] GetBuyReport(long startDate, long endDate, int[] product_id, int page, int pageSize, out int totalProducts, bool paging = true)
        {
            string json = "";

            totalProducts = 0;
            if (this.CurrentUserPermission.VIEW_BUY_REPORT == 0)
            {
                throw new KMJXCException("没有权限查看采购报表");
            }
            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 20;
            }
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                int[]           childShops  = (from c in this.DBChildShops select c.Shop_ID).ToArray <int>();
                List <BProduct> products    = null;
                var             tmpProducts = from p in db.Product
                                              join shop in db.Shop on p.Shop_ID equals shop.Shop_ID into LShop
                                              from l_shop in LShop.DefaultIfEmpty()
                                              where p.Parent_ID == 0
                                              select new BProduct
                {
                    ID    = p.Product_ID,
                    BShop = new BShop {
                        ID = p.Shop_ID, Title = l_shop.Name
                    },
                    Title = p.Name
                };

                if (this.Shop.Shop_ID == this.Main_Shop.Shop_ID)
                {
                    tmpProducts = tmpProducts.Where(p => (p.BShop.ID == this.Shop.Shop_ID || childShops.Contains(p.BShop.ID)));
                }
                else
                {
                    tmpProducts = tmpProducts.Where(p => p.BShop.ID == this.Shop.Shop_ID);
                }

                if (product_id != null && product_id.Length > 0)
                {
                    tmpProducts = tmpProducts.Where(p => product_id.Contains(p.ID));
                }

                var tmpBuyOrders = from bo in db.Buy_Order
                                   select bo;

                if (this.Shop.Shop_ID == this.Main_Shop.Shop_ID)
                {
                    tmpBuyOrders = tmpBuyOrders.Where(o => (o.Shop_ID == this.Shop.Shop_ID || childShops.Contains(o.Shop_ID)));
                }
                else
                {
                    tmpBuyOrders = tmpBuyOrders.Where(o => o.Shop_ID == this.Shop.Shop_ID);
                }

                if (startDate > 0)
                {
                    tmpBuyOrders = tmpBuyOrders.Where(o => o.Create_Date > startDate);
                }
                if (endDate > 0)
                {
                    tmpBuyOrders = tmpBuyOrders.Where(o => o.Create_Date <= endDate);
                }

                var tmpBuyOrderIds = from o in tmpBuyOrders select o.Buy_Order_ID;

                var tmpBuyOrderDetails = from bd in db.Buy_Order_Detail
                                         where tmpBuyOrderIds.Contains(bd.Buy_Order_ID)
                                         select bd;

                var orderProductIds = from o in tmpBuyOrderDetails select o.Parent_Product_ID;
                tmpProducts = tmpProducts.Where(p => orderProductIds.Contains(p.ID));
                if (paging)
                {
                    products = tmpProducts.OrderBy(p => p.ID).Skip((page - 1) * page).Take(pageSize).ToList <BProduct>();
                }
                else
                {
                    products = tmpProducts.OrderBy(p => p.ID).ToList <BProduct>();
                }
                int[]                   parent_pIds      = (from p in products select p.ID).ToArray <int>();
                List <Product>          childrenProducts = (from p in db.Product where parent_pIds.Contains(p.Parent_ID) select p).ToList <Product>();
                int[]                   child_pIds       = (from p in childrenProducts select p.Product_ID).ToArray <int>();
                List <BProductProperty> properties       = (from pv in db.Product_Specifications
                                                            join prop in db.Product_Spec on pv.Product_Spec_ID equals prop.Product_Spec_ID into LProp
                                                            from l_prop in LProp.DefaultIfEmpty()
                                                            join propV in db.Product_Spec_Value on pv.Product_Spec_Value_ID equals propV.Product_Spec_Value_ID into LPropv
                                                            from l_propv in LPropv.DefaultIfEmpty()
                                                            where child_pIds.Contains(pv.Product_ID)
                                                            select new BProductProperty
                {
                    PID = pv.Product_Spec_ID,
                    PName = l_prop.Name,
                    ProductID = pv.Product_ID,
                    PValue = l_propv.Name,
                    PVID = pv.Product_Spec_Value_ID
                }).OrderBy(p => p.PID).ToList <BProductProperty>();

                List <Buy_Order>       orders  = (from o in tmpBuyOrders select o).ToList <Buy_Order>();
                List <BBuyOrderDetail> details = (from detail in tmpBuyOrderDetails
                                                  join order in tmpBuyOrders on detail.Buy_Order_ID equals order.Buy_Order_ID into LOrder
                                                  from l_order in LOrder.DefaultIfEmpty()
                                                  select new BBuyOrderDetail
                {
                    Product = new BProduct {
                        ID = detail.Product_ID
                    },
                    Parent_Product_ID = detail.Parent_Product_ID,
                    BuyDate = l_order.Insure_Date != null && l_order.Insure_Date > 0 ? (long)l_order.Insure_Date : l_order.Create_Date,
                    Quantity = detail.Quantity,
                    Price = detail.Price
                }).OrderBy(d => d.BuyDate).ToList <BBuyOrderDetail>();
                foreach (BProduct product in products)
                {
                    string         productName = product.ID + " " + product.Title;
                    string         shopName    = product.BShop.Title;
                    List <Product> children    = (from c in childrenProducts where c.Parent_ID == product.ID select c).ToList <Product>();
                    if (children == null || children.Count <= 0)
                    {
                        var vdetails = from d in details where d.Parent_Product_ID == product.ID select d;
                        foreach (var detail in vdetails)
                        {
                            string month = DateTimeUtil.ConvertToDateTime(detail.BuyDate).ToString("yyyy-M");
                            if (json == "")
                            {
                                json = "[{\"product_name\":\"" + productName + "\",\"prop_name\":\"--\",\"shop_name\":\"" + shopName + "\",\"month\":\"" + month + "\",\"quantity\":\"" + detail.Quantity + "\",\"amount\":" + (detail.Quantity * detail.Price).ToString("0.00") + "}";
                            }
                            else
                            {
                                json += ",{\"product_name\":\"" + productName + "\",\"prop_name\":\"--\",\"shop_name\":\"" + shopName + "\",\"month\":\"" + month + "\",\"quantity\":\"" + detail.Quantity + "\",\"amount\":" + (detail.Quantity * detail.Price).ToString("0.00") + "}";
                            }
                        }
                    }
                    else
                    {
                        int[] childrenIds = (from c in children select c.Product_ID).ToArray <int>();
                        var   vdetails    = from d in details where childrenIds.Contains(d.Product.ID) select d;
                        foreach (var detail in vdetails)
                        {
                            string pNames = "";
                            List <BProductProperty> props = (from p in properties where p.ProductID == detail.Product.ID select p).ToList <BProductProperty>();
                            foreach (BProductProperty prop in props)
                            {
                                if (pNames == "")
                                {
                                    pNames = prop.PName + ":" + prop.PValue;
                                }
                                else
                                {
                                    pNames += "," + prop.PName + ":" + prop.PValue;
                                }
                            }
                            string month = DateTimeUtil.ConvertToDateTime(detail.BuyDate).ToString("yyyy-M");
                            if (json == "")
                            {
                                json = "[{\"product_name\":\"" + productName + "\",\"prop_name\":\"" + detail.Product.ID + " " + pNames + "\",\"shop_name\":\"" + shopName + "\",\"month\":\"" + month + "\",\"quantity\":\"" + detail.Quantity + "\",\"amount\":" + (detail.Quantity * detail.Price).ToString("0.00") + "}";
                            }
                            else
                            {
                                json += ",{\"product_name\":\"" + productName + "\",\"prop_name\":\"" + detail.Product.ID + " " + pNames + "\",\"shop_name\":\"" + shopName + "\",\"month\":\"" + month + "\",\"quantity\":\"" + detail.Quantity + "\",\"amount\":" + (detail.Quantity * detail.Price).ToString("0.00") + "}";
                            }
                        }
                    }
                }
            }
            if (json != "")
            {
                json += "]";
            }

            JArray ja = JArray.Parse(json);

            JToken[] jac = (from j in ja orderby j["month"] select j).ToArray <JToken>();

            return(jac);
        }