Example #1
0
        public async Task <IActionResult> PutWaste(int id, Waste waste)
        {
            if (id != waste.WasteId)
            {
                return(BadRequest());
            }

            var local = _context.Wastes.FirstOrDefault(entry => entry.WasteId.Equals(waste.WasteId));

            _context.Entry(local).State = EntityState.Detached;
            _context.Entry(waste).State = EntityState.Modified;


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WasteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <ActionResult <Waste> > PostWaste(Waste waste)
        {
            _context.Wastes.Add(waste);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWaste", new { id = waste.WasteId }, waste));
        }
Example #3
0
 public Waste(Waste _goal) // Constructeur
 {
     // Par : copie d’un élément existant (mais avec une taille initiale de 1).
     PosX = _goal.PosX;
     PosY = _goal.PosY;
     type = _goal.type;
 }
Example #4
0
        /// <summary>
        /// Tries the move all cards to appropriate foundations.
        /// </summary>
        public void TryMoveAllCardsToAppropriateFoundations()
        {
            //  Go through the top card in each tableau - keeping
            //  track of whether we moved one.
            var keepTrying = true;

            while (keepTrying)
            {
                var movedACard = false;
                if (Waste.Count > 0)
                {
                    if (TryMoveCardToAppropriateFoundation(Waste.Last()))
                    {
                        movedACard = true;
                    }
                }

                foreach (var tableau in _tableaus.Where(tableau => tableau.Count > 0)
                         .Where(tableau => TryMoveCardToAppropriateFoundation(tableau.Last())))
                {
                    movedACard = true;
                }

                //  We'll keep trying if we moved a card.
                keepTrying = movedACard;
            }
        }
Example #5
0
        public bool RecordNewWaste(Waste newWaste)
        {
            bool result = false;

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(sqlRecordNewWaste, conn);
                    cmd.Parameters.AddWithValue("@inventoryId", newWaste.inventoryId);
                    cmd.Parameters.AddWithValue("@dateWasted", newWaste.dateWasted);
                    cmd.Parameters.AddWithValue("@amountWasted", newWaste.amountWasted);
                    cmd.Parameters.AddWithValue("@wasteDescription", newWaste.wasteDescription);

                    cmd.ExecuteNonQuery();
                }

                result = true;
            }

            catch
            {
                result = false;
            }

            return(result);
        }
Example #6
0
    public void SpawnObject(int wasteType)
    {
        int   i = Random.Range(0, spawnPoint.Length);
        Waste t = Instantiate(WasteObjects[wasteType], spawnPoint[i].transform.position, WasteObjects[wasteType].transform.rotation).GetComponent <Waste>();

        t.StartingPippe = spawnPoint[i].GetComponent <PipeInfo>().pipe;
    }
Example #7
0
 public LifeSupportSystem(List <OxygenBottle> bottles, FoodContainer container, Waste waste, List <Human> crew)
 {
     this.oxygenBottles = bottles;
     this.FoodContainer = container;
     this.waste         = waste;
     this.crew          = crew;
 }
Example #8
0
        public List <Waste> GetAllWastes()
        {
            List <Waste> wasteList = new List <Waste>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                SqlCommand    cmd    = new SqlCommand(sqlSelectAllWastes, conn);
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read() == true)
                {
                    Waste currentWaste = new Waste();

                    currentWaste.wasteId          = Convert.ToInt32(reader["waste_id"]);
                    currentWaste.inventoryId      = Convert.ToInt32(reader["inventory_id"]);
                    currentWaste.cropName         = Convert.ToString(reader["crop_name"]);
                    currentWaste.dateAdded        = Convert.ToDateTime(reader["date_added"]);
                    currentWaste.dateWasted       = Convert.ToDateTime(reader["date_wasted"]);
                    currentWaste.amountWasted     = Convert.ToDecimal(reader["amount_wasted"]);
                    currentWaste.wasteDescription = Convert.ToString(reader["waste_description"]);

                    wasteList.Add(currentWaste);
                }

                return(wasteList);
            }
        }
Example #9
0
        public ActionResult CreateWaste(WasteVM wasteVM)
        {
            //Db Model
            Waste wasteDb = new Waste();

            //Fills the dbModel with the passed data
            wasteDb.Number           = wasteVM.Number;
            wasteDb.Quantity         = wasteVM.Quantity;
            wasteDb.TypeId           = int.Parse(wasteVM.TypeId);
            wasteDb.PrimaryStorageId = int.Parse(wasteVM.PrimaryStorageId);
            wasteDb.StorageId        = int.Parse(wasteVM.PrimaryStorageId);
            //WasteStatusId = 1 is the start point of the waste
            wasteDb.WasteStatusId = 1;

            if (ModelState.IsValid)
            {
                db.Wastes.Add(wasteDb);
                db.SaveChanges();
                ViewBag.SuccessMessage = "Успешен запис!";
                return(View("~/Views/Shared/SuccessPage.cshtml"));
            }

            wasteVM.Types    = GetWasteTypesLI();
            wasteVM.Storages = GetStoragesLI();
            return(View(wasteVM));
        }
Example #10
0
        /// <summary>
        /// Tries the move the card to its appropriate foundation.
        /// </summary>
        /// <param name="cardViewModel">The card.</param>
        /// <returns>True if card moved.</returns>
        public bool TryMoveCardToAppropriateFoundation(PlayingCardViewModel cardViewModel)
        {
            //  Try the top of the waste first.
            if (Waste.LastOrDefault() == cardViewModel)
            {
                if (_foundations.Any(foundation => MoveCard(Waste, foundation, cardViewModel, false)))
                {
                    return(true);
                }
            }

            //  Is the card in a tableau?
            var inTableau = false;
            var i         = 0;

            for (; i < _tableaus.Count && inTableau == false; i++)
            {
                inTableau = _tableaus[i].Contains(cardViewModel);
            }

            //  It's if its not in a tablea and it's not the top
            //  of the waste, we cannot move it.
            if (inTableau == false)
            {
                return(false);
            }

            //  Try and move to each foundation.
            return(_foundations.Any(foundation => MoveCard(_tableaus[i - 1], foundation, cardViewModel, false)));
        }
Example #11
0
    public void RandomObstacle(Window _GameWindow)
    {
        double rand = SplashKit.Rnd();

        if (rand < 0.2)
        {
            Obstacle newObstacle = new Shark(_GameWindow, _Player);
            _Obstacles.Add(newObstacle);
        }
        else if (rand < 0.4)
        {
            Obstacle newObstacle = new Turtle(_GameWindow, _Player);
            _Obstacles.Add(newObstacle);
        }
        else if (rand < 0.6)
        {
            Obstacle newObstacle = new BodyBoard(_GameWindow, _Player);

            _Obstacles.Add(newObstacle);
        }
        else
        {
            Obstacle newObstacle = new Waste(_GameWindow, _Player);

            _Obstacles.Add(newObstacle);
        }
    }
Example #12
0
        private void gridViewQLNhapKho_DoubleClick(object sender, EventArgs e)
        {
            int     RowIndex    = gridViewQLNhapKho.FocusedRowHandle;
            string  stockincode = gridViewQLNhapKho.GetRowCellValue(RowIndex, "StockInCode").ToString();
            StockIn si          = dc.StockIns.Where(x => x.StockInCode == stockincode).SingleOrDefault();
            //goi su kien click form(show form) => biding du lieu ra form
            //binding du lieu phien
            NhapKho nhapkho = new NhapKho();

            nhapkho.Show();
            nhapkho.txtMaPN.Text           = stockincode;
            nhapkho.datePN.EditValue       = si.DateIn;
            nhapkho.txtMaNV.Text           = si.EmployeeCode;
            nhapkho.txtUser.Text           = si.UserID;
            nhapkho.txtGhiChuPhien.Text    = si.Note;
            nhapkho.txtTongTrongLuong.Text = si.TotalWeight.ToString();
            nhapkho.txtSoLuong.Text        = si.Quantity.ToString();
            //binding du lieu luoi
            var model = (from sid in dc.StockInDetails
                         join bar in dc.BarcodeDetails on sid.Barcode equals bar.Barcode
                         where (sid.StockInCode == stockincode)
                         select new
            {
                bar.Barcode,
                bar.WasteCode,
                bar.FactoryCode,
                bar.StorageCode,
                bar.Weigh,
                bar.Note,
            }).ToList();
            //tao moi datatable va datarow
            DataTable datatable = new DataTable();
            DataRow   datarow;

            //addcolum
            datatable.Columns.Add("Barcode");
            datatable.Columns.Add("TrongLuong");
            datatable.Columns.Add("Xuong");
            datatable.Columns.Add("Kho");
            datatable.Columns.Add("TenRac");
            datatable.Columns.Add("GhiChu");
            datatable.Columns.Add("DonVi");
            foreach (var item1 in model)
            {
                datarow               = datatable.NewRow();
                datarow["Barcode"]    = item1.Barcode;
                datarow["TrongLuong"] = item1.Weigh;
                datarow["Xuong"]      = item1.FactoryCode;
                datarow["Kho"]        = item1.StorageCode;
                datarow["TenRac"]     = item1.WasteCode;
                datarow["GhiChu"]     = item1.Note;
                Waste var = (from c in dc.Wastes
                             where c.WasteCode == item1.WasteCode
                             select c).FirstOrDefault();
                datarow["DonVi"] = var.Unit;
                datatable.Rows.Add(datarow);
            }
            nhapkho.gridControlBarcode.DataSource = datatable;
        }
Example #13
0
        // GET: Wastes/Delete/5
        public ActionResult Delete(int id)
        {
            var cookie = HttpContext.Request.Cookies["jwt"];

            Waste waste = CallApi.Get(cookie, "Wastes", id.ToString()).Content.ReadAsAsync <Waste>().Result;

            return(View(waste));
        }
Example #14
0
 private void Awake()
 {
     instance = this;
     animationQueueController = FindObjectOfType <AnimationQueueController>();
     stock      = FindObjectOfType <Stock>();
     waste      = FindObjectOfType <Waste>();
     undoHolder = GameObject.FindGameObjectWithTag("UndoHolder").transform;
 }
Example #15
0
        public Waste edit(Waste w)
        {
            Waste waste = _db.Waste.SingleOrDefault(a => a.Id == w.Id);

            waste.Price = w.Price;
            _db.SaveChanges();
            return(waste);
        }
 void Awake()
 {
     root       = GetComponent <UIRoot>();
     camera     = GetComponentInChildren <Camera>();
     background = GetComponentInChildren <UI2DSprite>();
     deck       = GetComponentInChildren <Deck>();
     board      = GetComponentInChildren <Board>();
     waste      = GetComponentInChildren <Waste>();
 }
    private void WasteHandler()
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Waste.transform);
        Waste.AddInteractionPunch();
        if (!_lightsOn || _isSolved)
        {
            return;
        }
        if (Barempty)
        {
            Module.HandleStrike();
            Strike = true;
            Debug.LogFormat("[Waste Management #{0}] Strike given, reset the module", _moduleId);
            Init();
        }
        switch (Stage)
        {
        case 1:
            PaperWaste = Input;
            Audio.PlaySoundAtTransform("PaperAdd", Waste.transform);
            break;

        case 2:
            PlasticWaste = Input;
            Audio.PlaySoundAtTransform("PlasticAdd", Waste.transform);
            break;

        case 3:
            MetalWaste = Input;
            Audio.PlaySoundAtTransform("MetalAdd", Waste.transform);
            break;

        default:
        {
            LeftoverWaste = Input;
            int random = UnityEngine.Random.Range(0, 3);
            switch (random)
            {
            case 0:
                Audio.PlaySoundAtTransform("PaperAdd", Waste.transform);
                break;

            case 1:
                Audio.PlaySoundAtTransform("PlasticAdd", Waste.transform);
                break;

            case 2:
                Audio.PlaySoundAtTransform("MetalAdd", Waste.transform);
                break;
            }

            break;
        }
        }
        Input = 0;
    }
Example #18
0
 private void Awake()
 {
     instance = this;
     stock    = FindObjectOfType <Stock>();
     waste    = FindObjectOfType <Waste>();
     animationQueueController = FindObjectOfType <AnimationQueueController>();
     hintMoves  = new Queue <HintMove>();
     undoHolder = GameObject.FindGameObjectWithTag("UndoHolder").transform;
     dimScreen  = FindObjectOfType <HintDimScreen>();
 }
Example #19
0
 private void Start()
 {
     waste      = FindObjectOfType <Waste>();
     stockImage = GetComponent <Image>();
     animationQueueController = FindObjectOfType <AnimationQueueController>();
     stockGraphics            = transform.parent.Find("Graphics");
     wasteOrderList           = new List <Transform>();
     undoHolder   = GameObject.FindGameObjectWithTag("UndoHolder").transform;
     refreshImage = GameObject.Find("ResetStock");
     ResetState();
 }
Example #20
0
    private void RefreshWaste(Transform wasteTransform)
    {
        Waste waste = wasteTransform.GetComponent <Waste>();

        if (waste)
        {
            //If previous parent is Waste refresh it
            waste.RegisterOnRefreshWasteAction(null);
            waste.RefreshChildren();
            stock.RefreshStockRefreshImage();
        }
    }
Example #21
0
 public bool DeselectWaste(Waste waste)
 {
     for (int i = 0; i < selectedWaste.Length; i++)
     {
         if (selectedWaste[i] == waste)
         {
             selectedWaste[i] = null;
             return(true);
         }
     }
     return(false);
 }
Example #22
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenRac.Text == "" || txtMaRac.Text == "" || cboLoaiRac.SelectedItem.ToString() == "" || txtDonVi.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Vui lòng điền đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Waste was = new Waste();
                was.WasteCode = txtMaRac.Text;
                was.WasteName = txtTenRac.Text;
                was.Type      = cboLoaiRac.SelectedItem.ToString();
                was.Unit      = txtDonVi.SelectedItem.ToString();
                if (rbtnKichHoat.Checked == true)
                {
                    was.Status = true;
                }
                else
                {
                    was.Status = false;
                }
                was.Note = txtGhiChu.Text;

                Waste var = (from c in dc.Wastes
                             where c.WasteCode == txtMaRac.Text && c.WasteName == txtTenRac.Text
                             select c).FirstOrDefault();
                if (var == null)
                {
                    try
                    {
                        dc.Wastes.InsertOnSubmit(was);
                        MessageBox.Show("Thêm mới loại rác thành công", "Thông báo");
                        dc.SubmitChanges();
                        txtMaRac.Text            = "";
                        txtTenRac.Text           = "";
                        cboLoaiRac.SelectedIndex = -1;
                        txtDonVi.SelectedIndex   = -1;
                        txtGhiChu.Text           = "";
                        rbtnKichHoat.Checked     = true;
                        DisplayData();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Loại rác thêm đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Example #23
0
        public async Task <ActionResult> Create(Waste collection)
        {
            try
            {
                await CallApi.PostAsync(Request.Cookies["jwt"], "Wastes", collection);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #24
0
        public ActionResult PostWaste(Waste wste)//edit price
        {
            if (wste != null)
            {
                _wasteRepo.edit(wste);

                //CreatedAtction To Go To Home Or Logging First its important
                return(Created("successfully Created", wste));
            }
            else
            {
                return(Content("failed To Register Try Again"));
            }
        }
 private void ChangePicture()
 {
     if (!_game.IsExpired)
     {
         SelectedWaste = Wastes.GetRange(0, Wastes.Count)
                         .OrderBy(i => _randomImage.Next()).Take(1).First();
         var path = SelectedWaste.ImagePath;
         pictureBox.ImageLocation = path;
     }
     else
     {
         pictureBox.Image = null;
     }
 }
Example #26
0
        public ActionResult Edit(int id, Waste collection)
        {
            try
            {
                var cookie   = HttpContext.Request.Cookies["jwt"];
                var response = CallApi.Put(cookie, "Wastes", collection, id.ToString());

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #27
0
    private void Start()
    {
        startTimer(timeLeft);
        scoreText = GetComponent <Text>();

        score = 0;

        for (int i = 0; i < allWasteTypes.Count; i++)
        {
            Debug.Log(allWasteTypes[i]);
            Waste w = allWasteTypes[i];
            qrCodes.Add((i + 1), w);
        }
    }
Example #28
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public WebResult <bool> Add_Waste(Waste model)
        {
            using (DbRepository entities = new DbRepository())
            {
                var oilModel = new OilCard();
                model.ID            = Guid.NewGuid().ToString("N");
                model.UpdatedTime   = model.CreatedTime = DateTime.Now;
                model.CreatedUserID = model.UpdaterID = Client.LoginUser.ID;
                model.Flag          = (long)GlobalFlag.Normal;
                entities.Waste.Add(model);
                if (model.Code == WasteCode.Oil)
                {
                    oilModel = entities.OilCard.Find(model.OilID);
                    if (oilModel == null)
                    {
                        return(Result(false, ErrorCode.sys_param_format_error));
                    }
                    if (oilModel.Balance < model.Money)
                    {
                        return(Result(false, ErrorCode.card__no_had_money));
                    }
                    oilModel.Balance -= model.Money;
                }
                if (entities.SaveChanges() > 0)
                {
                    var list = Cache_Get_WasteList();
                    if (model.Code == WasteCode.Oil)
                    {
                        var oilCardList = Cache_Get_OilCardList();
                        var index       = oilCardList.FindIndex(x => x.ID.Equals(model.OilID));
                        if (index > -1)
                        {
                            oilCardList[index] = oilModel;
                        }
                        else
                        {
                            oilCardList.Add(oilModel);
                        }
                    }

                    list.Add(model);
                    return(Result(true));
                }
                else
                {
                    return(Result(false, ErrorCode.sys_fail));
                }
            }
        }
Example #29
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public JsonResult Update(Waste entity)
 {
     ModelState.Remove("UpdaterID");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("CreatedTime");
     ModelState.Remove("CreatedUserID");
     if (ModelState.IsValid)
     {
         var result = WebService.Update_Waste(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
        private static void ImportData(ConfigurationWasteItem[] configuration, Entities edc)
        {
            List <Waste> list = new List <Waste>();

            foreach (ConfigurationWasteItem item in configuration)
            {
                Waste wst = new Waste
                {
                    ProductType = item.ProductType.ParseProductType(),
                    WasteRatio  = item.WasteRatio
                };
                list.Add(wst);
            }
            ;
            edc.Waste.InsertAllOnSubmit(list);
        }