Пример #1
0
 private void itemTxt_Leave(object sender, EventArgs e)
 {
     try
     {
         amountTxt.Text = Supplies.List("SELECT * from supplies WHERE supplier='" + itemTxt.Text + "' AND week = '" + weekLbl.Text + "' AND date = '" + Convert.ToDateTime(dateTxt.Text).Year.ToString() + "'").First().Amount.ToString();
     }
     catch (Exception y)
     {
         // Helper.Exceptions(y.Message, "on adding inventory auto fill the category list selected item");
     }
     try
     {
         month = Supplies.List("SELECT * from supplies WHERE supplier='" + itemTxt.Text + "' AND week = '" + weekLbl.Text + "' AND date = '" + Convert.ToDateTime(dateTxt.Text).Year.ToString() + "'").First().Month;
     }
     catch (Exception y)
     {
         // Helper.Exceptions(y.Message, "on adding inventory auto fill the category list selected item");
     }
     try
     {
         existingID = Supplies.List("SELECT * from supplies WHERE supplier='" + itemTxt.Text + "' AND week = '" + weekLbl.Text + "' AND date = '" + Convert.ToDateTime(dateTxt.Text).Year.ToString() + "'").First().Id.ToString();
     }
     catch (Exception y)
     {
         // Helper.Exceptions(y.Message, "on adding inventory auto fill the category list selected item");
     }
 }
Пример #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(amountTxt.Text))
            {
                amountTxt.BackColor = Color.Red;
                return;
            }
            if (string.IsNullOrEmpty(itemTxt.Text))
            {
                itemTxt.BackColor = Color.Red;
                return;
            }
            if (!string.IsNullOrEmpty(existingID))
            {
                if (MessageBox.Show("YES or No?", "Are you sure you want to update the current existing information  ? ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    Supplies j = new Supplies(existingID, Convert.ToDateTime(dateTxt.Text).Year.ToString(), Convert.ToInt32(weekLbl.Text), startLbl.Text, endLbl.Text, itemTxt.Text, Convert.ToDouble(amountTxt.Text), month);
                    DBConnect.Update(j, existingID);
                    existingID = "";
                }
                return;
            }
            existingID = "";

            string   ID = Guid.NewGuid().ToString();
            Supplies i  = new Supplies(ID, Convert.ToDateTime(dateTxt.Text).Year.ToString(), Convert.ToInt32(weekLbl.Text), startLbl.Text, endLbl.Text, itemTxt.Text, Convert.ToDouble(amountTxt.Text), month);

            DBConnect.Insert(i);
            MessageBox.Show("Information Saved ");
            itemTxt.Text   = "";
            amountTxt.Text = "";
            autocomplete();
        }
Пример #3
0
        public void FillTest(int n)
        {
            n = Math.Min(n, 100);
            Items.Clear();
            Users.Clear();
            Supplies.Clear();
            var defImg = new Bitmap(Path.GetFullPath("item.png"));

            for (int i = 0; i < n; i++)
            {
                Items.Add(new Item($"Product_{i}", i % 2 == 0 ? "l" : "kg", i + 1, 10000, defImg));
                Users.Add(new User($"User_{i}", "1234"));
            }

            for (int i = 0; i < n; i++)
            {
                var k = new List <Portion>(10);
                for (int j = 0; j < 10; j++)
                {
                    k.Add(new Portion {
                        Item = Items[(i + j) % n], Amount = 1 + (i + j) % 100
                    });
                    Items[i % n].Sold += 1 + (i + j) % 100;
                }
                Users[i].History = k;
                Supplies.Add(new Supply(k, DateTime.Now - TimeSpan.FromDays(n - i)));
            }
            Supplies.Reverse();
            UpdateSupplies();
        }
        public ActionResult ActiveCarrier([FromBody] int id)
        {
            User     user     = CurrentUser();
            Supplies relation = _customerManage.GetSubscribe(user.Id, id);

            if (relation != null)
            {
                if (_carrierManage.Active(id))
                {
                    return(Json(new Request
                    {
                        Msg = "Subscribe",
                        State = RequestState.Success,
                    }));
                }
                return(Json(new Request
                {
                    Msg = "UnSubscribe",
                    State = RequestState.Success,
                }));
            }
            return(Json(new Request
            {
                Msg = "Cannot be activated",
                State = RequestState.Failed,
            }));
        }
Пример #5
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textLevelDesired.errorProvider1.GetError(textLevelDesired) != "" ||
         textPrice.errorProvider1.GetError(textPrice) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDescript.Text == "")
     {
         MsgBox.Show(this, "Please enter a description.");
         return;
     }
     Supp.Category      = DefC.Short[(int)DefCat.SupplyCats][comboCategory.SelectedIndex].DefNum;
     Supp.CatalogNumber = textCatalogNumber.Text;
     Supp.Descript      = textDescript.Text;
     Supp.LevelDesired  = PIn.Float(textLevelDesired.Text);
     Supp.Price         = PIn.Double(textPrice.Text);
     Supp.IsHidden      = checkIsHidden.Checked;
     if (Supp.Category != categoryInitialVal)
     {
         Supp.ItemOrder = int.MaxValue;              //changed categories, new or existing, move to bottom of new category.
     }
     if (Supp.IsNew)
     {
         Supp = Supplies.GetSupply(Supplies.Insert(Supp, Supp.ItemOrder));             //insert Supp and update with PK and item order from DB.
     }
     else
     {
         Supplies.Update(SuppOriginal, Supp);
     }
     DialogResult = DialogResult.OK;
 }
Пример #6
0
        public async Task <ActionResult <ApiSupplies> > PostApiSupplies(ApiSupplies apiSupplies)
        {
            var currentUserId = _httpContextAccessor.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            if (apiSupplies.UserId != currentUserId)
            {
                return(Unauthorized());
            }

            var supplies = Supplies.FromApiSupplies(apiSupplies);
            await _context.Supplies.AddAsync(supplies);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SuppliesExists(supplies))
                {
                    return(Conflict());
                }

                throw;
            }

            return(CreatedAtAction("GetSuppliedIngredients", new { id = apiSupplies.IngrName }, apiSupplies));
        }
Пример #7
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            SelectedGridItems.Clear();
            foreach (int index in gridMain.SelectedIndices)
            {
                SelectedGridItems.Add(ListSupply[index].SupplyNum);
            }
            if (IsSelectMode)
            {
                SelectedSupply = Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);
                ListSelectedSupplies.Clear();                //just in case
                for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
                {
                    ListSelectedSupplies.Add(ListSupply[gridMain.SelectedIndices[i]]);
                }
                DialogResult = DialogResult.OK;
                return;
            }
            //Supply supplyCached=Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);  //works with sorting
            FormS.ListSupplier = ListSupplier;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            ListSupplyAll = Supplies.GetAll();
            int scroll = gridMain.ScrollValue;

            FillGrid();
            gridMain.ScrollValue = scroll;
        }
Пример #8
0
 public CollectorComponent(Supplies produceType, Supplies consumeType, Vector3Int pos, CollectorEntity collect = default(CollectorEntity))
 {
     Position     = pos;
     _produceType = produceType;
     _consumeType = consumeType;
     _collector   = collect ?? NewCollector();
 }
        public async Task <IActionResult> Edit(int id, [Bind("IdSupple,IdProvider,Price,DateSupple,IdMaterial")] Supplies supplies)
        {
            if (id != supplies.IdSupple)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplies);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SuppliesExists(supplies.IdSupple))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdMaterial"] = new SelectList(_context.Materials, "IdMaterial", "IdMaterial", supplies.IdMaterial);
            ViewData["IdProvider"] = new SelectList(_context.Providers, "IdProvider", "IdProvider", supplies.IdProvider);
            return(View(supplies));
        }
Пример #10
0
    void Start()
    {
        Zombie a = new Zombie();
        Zombie b = new Zombie();

        Debug.Log(a.damage);
        Debug.Log(b.damage);
        Zombie c = a + b;

        Debug.Log(c.damage);
        Supplies supplyA    = new Supplies(3);
        Supplies supplyB    = new Supplies(9);
        Supplies combinedAB = supplyA + supplyB;

        Debug.Log(combinedAB.weight);
        Supplies sm = new Supplies(5);

        Debug.Log(sm.weight);
        sm = sm * 3;
        Debug.Log(sm.weight);
        a.damage = 9;
        if (a < b)
        {
            Debug.Log("a has less damage!");
        }
    }
Пример #11
0
    //Function called externally. Gives the target inventory object as many supplies as possible from this inventory
    public void FillInventory(Supplies supplyType_, Inventory objectToReceive_)
    {
        switch (supplyType_)
        {
        //Gives the other object as much energy as possible
        case Supplies.Energy:
            this.currentEnergy -= objectToReceive_.AddEnergy(this.currentEnergy);
            break;

        //Gives the other object as many minerals as possible
        case Supplies.Minerals:
            this.currentMinerals -= objectToReceive_.AddMinerals(this.currentMinerals);
            break;

        //Gives the other object as many colonies as possible
        case Supplies.Colonies:
            this.currentColonies -= objectToReceive_.AddColonies(this.currentColonies);
            break;

        //Gives the other object as many resources as possible
        case Supplies.All:
            this.currentEnergy   -= objectToReceive_.AddEnergy(this.currentEnergy);
            this.currentMinerals -= objectToReceive_.AddMinerals(this.currentMinerals);
            this.currentColonies -= objectToReceive_.AddColonies(this.currentColonies);
            break;
        }
    }
Пример #12
0
        public async Task <IActionResult> DeleteSupplies(ApiSupplies apiSupplies)
        {
            var currentUserId = _httpContextAccessor.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            if (apiSupplies.UserId != currentUserId)
            {
                return(Unauthorized());
            }

            var deletedSupplies = Supplies.FromApiSupplies(apiSupplies);

            _context.Entry(deletedSupplies).State = EntityState.Deleted;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SuppliesExists(deletedSupplies))
                {
                    return(NotFound());
                }

                throw;
            }

            return(NoContent());
        }
Пример #13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Itemname,ItemClass,ItemQuantity")] Supplies supplies)
        {
            if (id != supplies.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplies);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SuppliesExists(supplies.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplies));
        }
Пример #14
0
 protected override void InicializeFields(WindVane windVane)
 {
     ShipCrew     = new ShipCrew(10, 24, 16, 8);
     Name         = "Corvette";
     ShipWeight   = 1000;
     Health       = 2000f;
     ShipSupplies = new Supplies(new Cannons(4, 4, 2, 2), new ShipHold(), new Sails(), windVane);
 }
Пример #15
0
        public ActionResult DeleteConfirmed(int id)
        {
            Supplies supplies = db.Supplies.Find(id);

            db.Supplies.Remove(supplies);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #16
0
        public void PackConstructor_HoldsInstanceOfSupplies_Pack()
        {
            string   description = "this is something you eat";
            Supplies supply      = new Supplies("food", description, 2, 100);

            string nameTest = "food";
            int    priceTest = 2, idTest = 100;
        }
Пример #17
0
 public Supplies(Supplies other)
 {
     wood            = other.wood;
     stone           = other.stone;
     bamboo          = other.bamboo;
     food            = other.food;
     OnAmountChanged = new UnityEvent();
 }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        tickRate = 100;
        noFood   = false;

        supplies = GameObject.Find("Manager").GetComponent <Supplies>();

        CreateWorkers(3, WorkSite.Farm);
    }
Пример #19
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Supplies supplies = await _context.Supplies.FindAsync(id);

            _context.Supplies.Remove(supplies);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Пример #20
0
    /// <summary>
    /// Updates all text value
    /// </summary>
    public void OnAmountChange()
    {
        Supplies supplies = UIManager.Instance.Town.Supplies;

        foodAmount.text   = supplies.Food.ToString();
        stoneAmount.text  = supplies.Stone.ToString();
        bambooAmount.text = supplies.Bamboo.ToString();
        woodAmount.text   = supplies.Wood.ToString();
    }
Пример #21
0
 public ActionResult Edit([Bind(Include = "Id,Material,Size,Quantity,Cost,UsePrice,Notes")] Supplies supplies)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplies).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplies));
 }
 public bool DeleteSubscribe(Supplies relation)
 {
     Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry <Supplies> subs = Context.Supplies.Remove(relation);
     if (subs != null)
     {
         Context.SaveChanges();
         return(true);
     }
     return(false);
 }
Пример #23
0
 private void FormSupplyOrderItemEdit_Load(object sender, EventArgs e)
 {
     Supp = Supplies.GetSupply(ItemCur.SupplyNum);
     textSupplier.Text      = Suppliers.GetName(ListSupplier, Supp.SupplierNum);
     textCategory.Text      = DefC.GetName(DefCat.SupplyCats, Supp.Category);
     textCatalogNumber.Text = Supp.CatalogNumber;
     textDescript.Text      = Supp.Descript;
     textQty.Text           = ItemCur.Qty.ToString();
     textPrice.Text         = ItemCur.Price.ToString("n");
 }
Пример #24
0
        public ResultModel AddOrder(OrderDTO order)
        {
            ResultModel result = new ResultModel();

            BookDTO book = new BookDTO
            {
                AuthorId = order.Author.Id,
                Title    = order.Book.Title
            };

            int bookId = AddBook(book);

            if (bookId > 0)
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    try
                    {
                        OrderLists item = new OrderLists
                        {
                            Book   = bookId,
                            Cost   = order.Cost,
                            Supply = order.Supply.Id
                        };

                        OrderLists item1 = (OrderLists)order;
                        item.Book = bookId;

                        _context.OrderLists.Add(item);

                        Supplies supply = _context.Supplies.FirstOrDefault(c => c.Id == order.Supply.Id);

                        double oldSumm = supply.Summ.HasValue ? supply.Summ.Value : 0;
                        supply.Summ = oldSumm + order.Cost;
                        _context.Entry(supply).State = EntityState.Modified;

                        _context.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        result.Code    = OperationStatusEnum.UnexpectedError;
                        result.Message = ex.StackTrace;
                        transaction.Rollback();
                    }
                }
            }
            else
            {
                result.Code    = OperationStatusEnum.UnexpectedError;
                result.Message = "Ошибка при добавлении книги";
            }

            return(result);
        }
Пример #25
0
        public ActionResult Edit(int?id, [Bind(Include = "SuppliesID,Name,Value,Number,Available,ClassRoom")] Supplies supplies, HttpPostedFileBase upload)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            // Very long function to detect if a photo exists on this supply id. Delete it then replace it will the supplied photo.
            var updateSupply = db.Supplies.Find(supplies.SuppliesID);

            if (TryUpdateModel(updateSupply, "",
                               new string[] { "SuppliesID", "Name", "Value", "Number", "Available", "ClassRoom" }))
            {
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (upload != null && upload.ContentLength > 0)
                    {
                        if (updateSupply.Files.Any(x => x.FileType == FileType.Photo))
                        {
                            db.Files.Remove(updateSupply.Files.First(x => x.FileType == FileType.Photo));
                        }

                        var photo = new File
                        {
                            FileName    = System.IO.Path.GetFileName(upload.FileName),
                            FileType    = FileType.Photo,
                            ContentType = upload.ContentType
                        };
                        using (var reader = new System.IO.BinaryReader(upload.InputStream))
                        {
                            photo.Content = reader.ReadBytes(upload.ContentLength);
                        }

                        updateSupply.Files = new List <File> {
                            photo
                        };


                        db.Entry(updateSupply).State = EntityState.Modified;
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                }
                catch (RetryLimitExceededException)
                {
                    ModelState.AddModelError("", "Unable to add a profile image.");
                }
            }
            db.Entry(updateSupply).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #26
0
        public async Task <IActionResult> Create([Bind("Id,Itemname,ItemClass,ItemQuantity")] Supplies supplies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supplies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplies));
        }
Пример #27
0
      public ActionResult Create([Bind(Include = "Id,Material,Size,Quantity,Cost,UsePrice,Notes")] Supplies supplies)
      {
          if (ModelState.IsValid)
          {
              db.Inventory.Add(supplies);
              db.SaveChanges();
              return(RedirectToAction("Index"));
          }

          return(View(supplies));
      }
Пример #28
0
 public static Supplies operator *(Supplies a, int b)
 {
     Supplies s = new Supplies(0);
     int sBandages = a.bandages * b;
     int sAmmunition = a.ammunition * b;
     float sWeight = a.weight * b;
     s.bandages = sBandages;
     s.ammunition = sAmmunition;
     s.weight = sWeight;
     return s;
 }
Пример #29
0
 public static Supplies operator +(Supplies a, Supplies b)
 {
     Supplies s = new Supplies(0);
     int sBandanges = a.bandages + b.bandages;
     int sAmmunition = a.ammunition + b.ammunition;
     float sWeight = a.weight + b.weight;
     s.bandages = sBandanges;
     s.ammunition = sAmmunition;
     s.weight = sWeight;
     return s;
 }
Пример #30
0
        public string DeleteSubscribe(Supplies relation)
        {
            bool result = _context.DeleteSubscribe(relation);

            if (result != false)
            {
                return("Delete Successfuly");
            }

            return(null);
        }
Пример #31
0
 ///<summary>Fixes all ItemOrders for a category where a duplicate was found.  Includes IsHidden so that it works for both hidden and unhidden.</summary>
 private void FixItemOrders(long category)
 {
     List<long> listCategories=new List<long>();
     listCategories.Add(category);
     List<Supply> listSuppliesCat=Supplies.GetList(null,true,"",listCategories);
     for(int i=0;i<listSuppliesCat.Count;i++){
         if(listSuppliesCat[i].ItemOrder!=i){
             listSuppliesCat[i].ItemOrder=i;
             Supplies.Update(listSuppliesCat[i]);
         }
     }
 }
Пример #32
0
        /*
        private void checkShowShoppingList_Click(object sender,EventArgs e) {
            _listSelectedSupplies.Clear();
            foreach(int index in gridMain.SelectedIndices) {
                _listSelectedSupplies.Add((Supply)gridMain.ListGridRows[index].Tag);
            }
            FillGrid();
        }*/
        private void butUp_Click(object sender,EventArgs e)
        {
            if(textFind.Text!=""){
                MsgBox.Show(this,"Not allowed unless search text is empty.");
                return;
            }
            if(!comboSuppliers.IsAllSelected){
                MsgBox.Show(this,"Not allowed unless All suppliers are selected.");
                return;
            }
            List<int> listSelected=gridMain.SelectedIndices.ToList<int>();
            if(listSelected.Count==0){
                MsgBox.Show(this,"Please select at least one supply, first.");
                return;
            }
            for(int i=1;i<listSelected.Count;i++) {
                if(_listSupplies[listSelected[0]].Category != _listSupplies[listSelected[i]].Category){
                    MsgBox.Show(this,"All selected supplies must be in the same category.");
                    return;
                }
                if(listSelected[i-1]+1 != listSelected[i]){
                    MsgBox.Show(this,"Selection must not have gaps.");//makes my math too hard
                    return;
                }
            }
            if(listSelected[0]==0){
                return;//already at top
            }
            if(_listSupplies[listSelected[0]].Category != _listSupplies[listSelected[0]-1].Category){
                MsgBox.Show(this,"Already at top of category.");
                return;
            }
            //we should only have to move them up one, but there could be hidden supplies that would require moving up more.
            //There can also be hidden supplies that cause gaps in our selected list.
            //After considering many options, the best solution is to move group up one, and then set the item above to the ItemOrder of the bottom in group.

            int countMove=_listSupplies[listSelected[0]].ItemOrder-_listSupplies[listSelected[0]-1].ItemOrder;//example 2-1=1
            //todo: fix gaps caused by hidden supplies

            List<long> listSupplyNums=new List<long>();
            for(int i=0;i<listSelected.Count;i++) {
                listSupplyNums.Add(_listSupplies[listSelected[i]].SupplyNum);
            }
            Supplies.OrderSubtract(listSupplyNums,countMove);
            _listSupplies[listSelected[0]-1].ItemOrder+=listSelected.Count+countMove-1;//Example 0+5+1-1=5, while the 5 selected items moved up to occupy 0 through 4.
            Supplies.Update(_listSupplies[listSelected[0]-1]);
            FillGrid();
            int[] indicesNew=new int[listSelected.Count];
            for(int i=0;i<listSelected.Count;i++){
                indicesNew[i]=listSelected[i]-1;
            }
            gridMain.SetSelected(indicesNew,true);
        }
Пример #33
0
 void Start()
 {
     Zombie a = new Zombie();
     Zombie b = new Zombie();
     Debug.Log(a.damage);
     Debug.Log(b.damage);
     Zombie c = a + b;
     Debug.Log(c.damage);
     Supplies supplyA = new Supplies(3);
     Supplies supplyB = new Supplies(9);
     Supplies combinedAB = supplyA + supplyB;
     Debug.Log(combinedAB.weight);
     Supplies sm = new Supplies(5);
     Debug.Log(sm.weight);
     sm = sm * 3;
     Debug.Log(sm.weight);
     a.damage = 9;
     if (a < b)
     {
         Debug.Log("a has less damage!");
     }
 }