Ejemplo n.º 1
0
        public static string GenerateQuery(VendorPage vendor)
        {
            if (vendor.npcTb.Text == "")
            {
                throw new Exception("Please enter NPC ID.");
            }
            else if (vendor.itemTb.Text == "")
            {
                throw new Exception("Please enter item ID.");
            }

            return(SelectedEmulator.GenerateQuery(vendor));
        }
Ejemplo n.º 2
0
        public Dictionary <string, string> Vendor(VendorPage vendor)
        {
            var kvplist = new Dictionary <string, string>
            {
                { "entry", vendor.npcTb.Text },
                { "slot", vendor.slotTb.Text },
                { "item", vendor.itemTb.Text },
                { "maxcount", vendor.maxcountTb.Text },
                { "incrtime", vendor.incrTimeTb.Text },
                { "extendedcost", vendor.extendedCostTb.Text },
            };

            return(kvplist);
        }
Ejemplo n.º 3
0
        // Vendor is dynamic, loop through the UI elements
        public static string Vendor(VendorPage vendor)
        {
            Logger.Log($"Export: Called Vendor with profile: '{Profile.Active.Name}' - Revision {Profile.Active.Revision}");
            string sql = String.Empty;

            int NpcEntry;

            if (!int.TryParse(vendor.npcTb.Text, out NpcEntry))
            {
                Logger.Log("NPC ID was not numeric. Query was not saved.", Logger.Status.Error, true);
                return("");
            }


            foreach (VendorEntryControl row in vendor.vendorEntriesWp.Children)
            {
                int Item, Slot, MaxCount, IncrTime, ExtendedCost;
                if (!int.TryParse(row.itemTb.Text, out Item) ||
                    !int.TryParse(row.slotTb.Text, out Slot) ||
                    !int.TryParse(row.maxcountTb.Text, out MaxCount) ||
                    !int.TryParse(row.incrTimeTb.Text, out IncrTime) ||
                    !int.TryParse(row.extendedCostTb.Text, out ExtendedCost))
                {
                    Logger.Log("All values in Vendor must be numeric. Query was not saved.", Logger.Status.Error, true);
                    return("");
                }

                // Default values
                var vendorEntry = new List <ExpKvp>()
                {
                    new ExpKvp("NpcEntry", NpcEntry, C.Vendor),
                    new ExpKvp("Item", Item, C.Vendor),
                    new ExpKvp("Slot", Slot, C.Vendor),
                    new ExpKvp("MaxCount", MaxCount, C.Vendor),
                    new ExpKvp("IncrTime", IncrTime, C.Vendor),
                    new ExpKvp("ExtendedCost", ExtendedCost, C.Vendor),
                };

                // Add Custom fields
                IncludeCustomFields(ref vendorEntry, C.Vendor, row);

                // Generate vendor entry
                sql += GenerateSql(vendorEntry) + Environment.NewLine;
            }

            return(sql);
        }
Ejemplo n.º 4
0
        // Vendor is dynamic, loop through the UI elements
        public static string Vendor(VendorPage vendor)
        {
            string sql = String.Empty;

            int NpcEntry;

            if (!int.TryParse(vendor.npcTb.Text, out NpcEntry))
            {
                Logger.Log("NPC ID was not numeric. Query was not saved.", Logger.Status.Error, true);
                return("");
            }


            foreach (VendorEntryControl row in vendor.vendorEntriesWp.Children)
            {
                int Item, Slot, MaxCount, IncrTime, ExtendedCost;
                if (!int.TryParse(row.itemTb.Text, out Item) ||
                    !int.TryParse(row.slotTb.Text, out Slot) ||
                    !int.TryParse(row.maxcountTb.Text, out MaxCount) ||
                    !int.TryParse(row.incrTimeTb.Text, out IncrTime) ||
                    !int.TryParse(row.extendedCostTb.Text, out ExtendedCost))
                {
                    Logger.Log("All values in Vendor must be numeric. Query was not saved.", Logger.Status.Error, true);
                    return("");
                }

                sql += GenerateSql(new List <ExpKvp>()
                {
                    new ExpKvp("NpcEntry", NpcEntry, C.Vendor),
                    new ExpKvp("Item", Item, C.Vendor),
                    new ExpKvp("Slot", Slot, C.Vendor),
                    new ExpKvp("MaxCount", MaxCount, C.Vendor),
                    new ExpKvp("IncrTime", IncrTime, C.Vendor),
                    new ExpKvp("ExtendedCost", ExtendedCost, C.Vendor),
                }) + Environment.NewLine;
            }

            // todo: Custom fields not supported for vendor
            return(sql);
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            Users LoggedUser = Login.GetLoggedUser();

            ViewBag.user = LoggedUser;

            if (LoggedUser != null)
            {
                if (LoggedUser.Role == Roles.Usuario)
                {
                    var products  = Products.ListProductsOnUser(LoggedUser).Where(i => i.Amount > 0);
                    var Allocates = ProductsAllocated.Queryable.Where(i => i.Vendor.UserBoss == LoggedUser && i.Amount > 0);

                    double stockValue = 0;
                    foreach (var item in products)
                    {
                        stockValue = stockValue + item.Cost * item.Amount;
                    }
                    var stockAmount = products.Select(i => i.Amount).Sum();

                    var    allAllocatedAmount = Allocates.ToList().Sum(i => i.Amount);
                    double allAllocatedCost   = 0;
                    foreach (var item in Allocates)
                    {
                        allAllocatedCost = allAllocatedCost + (item.Cost * item.Amount);
                    }
                    double allocatedToReceive = 0;
                    foreach (var item in Allocates)
                    {
                        allocatedToReceive = allocatedToReceive + (item.Amount * (item.Price - ((item.Price / 100) * item.Commision)));
                    }

                    var AllBuy  = Charges.Queryable.Where(i => i.Amount > 0 && i.Client == LoggedUser && i.Type == Models.ChargesExtensions.ChargesTypes.Compra).Select(i => i.Value).ToList().Sum();
                    var AllSell = Charges.Queryable.Where(i => i.Amount > 0 && i.Client == LoggedUser && i.Type == Models.ChargesExtensions.ChargesTypes.Venda).Select(i => i.Value).ToList().Sum();

                    var totalVendor = Users.ListVendors(LoggedUser).Count;
                    var vendorWithProductAllocated = Allocates.Select(i => i.Vendor).Distinct().Count();

                    ViewBag.statistic = new HomeStatistics
                    {
                        AllAllocatedAmount           = allAllocatedAmount,
                        AllAllocatedCost             = allAllocatedCost,
                        AllAllocatedToReceive        = allocatedToReceive,
                        AllProductsAmount            = stockAmount,
                        AllProductsValue             = stockValue,
                        TotalVendors                 = totalVendor,
                        VendorsWithAllocatedProducts = vendorWithProductAllocated,
                        TotalGain = AllSell,
                        TotalPayd = AllBuy
                    };
                }
                if (LoggedUser.Role == Roles.Vendedor)
                {
                    VendorPage vendorPage             = new VendorPage();
                    List <ProductsAllocated> products = ProductsAllocated.Queryable.Where(i => i.Vendor == LoggedUser && i.Amount > 0).ToList();

                    vendorPage.Name = LoggedUser.Name + " " + LoggedUser.SurName;
                    foreach (var item in products)
                    {
                        vendorPage.TotalAmountAllocatedProducts += item.Amount;
                        vendorPage.TotalValueInProducts         += Convert.ToDecimal(item.Price);
                        vendorPage.TotalValueToEarnInComission  += Convert.ToDecimal(item.Price - ((item.Price / 100) * item.Commision));
                    }
                    vendorPage.AccontabilityDelayed       = products.Where(i => i.DateAccountability <= DateTime.Now.Date).ToList();
                    vendorPage.NextProductToAccontability = products.Where(i => i.DateAccountability >= DateTime.Now.Date).OrderBy(i => i.DateAccountability).Take(6).ToList();

                    ViewBag.vendorPage = vendorPage;
                    return(View());
                }
            }

            return(View());
        }
Ejemplo n.º 6
0
 public string GenerateQuery(VendorPage vendor)
 {
     return(SqlQuery.GenerateInsert("npc_vendor", Vendor(vendor)));
 }
Ejemplo n.º 7
0
 public string GenerateQuery(VendorPage vendor)
 {
     throw new NotImplementedException();
 }