Exemplo n.º 1
0
        public async Task <IActionResult> AssignActualAmount(int LotId, int LotItemId, int LotActualCost, int ItemUnitCost)
        {
            if (ModelState.IsValid)
            {
                LotItem ObjItem = _context.LotItem.Find(LotItemId);
                ObjItem.ActualUnitRate = ItemUnitCost;
                _context.Update(ObjItem);
                await _context.SaveChangesAsync();

                var CurrentCost = _context.LotItem.Where(a => a.lotId == LotId).Sum(a => (a.ActualUnitRate ?? 0) * a.Quantity);
                if (CurrentCost == LotActualCost)
                {
                    Lot ObjLot = _context.Lot.Find(LotId);
                    ObjLot.IsMatched = true;
                    _context.Update(ObjLot);
                    await _context.SaveChangesAsync();
                }
                //CurrentLot.ContractorID = CID;
                //CurrentLot.ExpiryDate = EDate;
                //try
                //{
                //    _context.Update(CurrentLot);
                //    await _context.SaveChangesAsync();
                //}
                //catch (Exception e)
                //{

                //}
                return(Json(new { success = true, responseText = (CurrentCost == LotActualCost ? "1" : "0") }));
            }
            return(Json(new { success = false, responseText = "0" }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditPopup(int id, [Bind("LotItemId,lotId,ItemName,Quantity,EstimatedUnitRate,ActualUnitRate,UnitId,Description")] LotItem lotItem)
        {
            if (id != lotItem.LotItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lotItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LotItemExists(lotItem.LotItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["lotId"]  = new SelectList(_context.Lot, "lotId", "lotId", lotItem.lotId);
            ViewData["UnitId"] = new SelectList(_context.Unit, "UnitId", "UnitId", lotItem.UnitId);
            return(PartialView(lotItem));
        }
Exemplo n.º 3
0
 private void CBoxLotNums_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
 {
     if (args.ChosenSuggestion != null)
     {
         LotItem chsLotItem = args.ChosenSuggestion as LotItem;
         CBoxLotNums.Text = chsLotItem.Code;
     }
     else
     {
         var matchingLot = LotOptions.ToList().Where(c => c.Code.IndexOf(sender.Text, StringComparison.CurrentCultureIgnoreCase) > -1).OrderByDescending(c => c.Code.StartsWith(sender.Text, StringComparison.CurrentCultureIgnoreCase));
         if (matchingLot.Count() >= 1)
         {
             CBoxLotNums.Text = matchingLot.FirstOrDefault().Code;
         }
     }
 }
Exemplo n.º 4
0
        public void CreateAuction(CreateAuctionViewModel auctionViewModel)
        {
            LotItem lot = new LotItem()
            {
                Id                  = Guid.NewGuid().ToString(),
                Name                = auctionViewModel.LotName,
                Description         = auctionViewModel.LotDescription,
                PublishedDate       = DateTime.Now,
                InitialCost         = auctionViewModel.InitialCost,
                CreatedByEmployeeId = auctionViewModel.CreatedByEmployeeId
            };

            LotItemRepository       lotRepository           = new LotItemRepository();
            LotAttachmentRepository lotAttachmentRepository = new LotAttachmentRepository();

            //using (TransactionScope transactionScope = new TransactionScope())
            //{
            //    try
            //    {
            lotRepository.Add(lot);
            foreach (CreateLotAttachViewModel item in auctionViewModel.LotAttachmentVMs)
            {
                LotAttachment lotAttachment = new LotAttachment();

                lotAttachment.Id        = Guid.NewGuid().ToString();
                lotAttachment.Name      = item.Name;
                lotAttachment.Extension = item.Path.Substring(item.Path.LastIndexOf('.') + 1);
                lotAttachment.Body      = File.ReadAllBytes(item.Path);
                lotAttachment.LotItemId = lot.Id;

                lotAttachmentRepository.Add(lotAttachment);
            }
            //transactionScope.Complete();
            //}
            //catch
            //{
            //    throw new Exception("Transaction failed");
            //}
            //}
        }
Exemplo n.º 5
0
        protected override void StartThread()
        {
            lotfi.Load();
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = lotfi.FindFile(0x856DDBAC, Data.MetaData.LOCAL_GROUP, 0x35CA0002, null);
            bool run = Wait.Running;

            if (!run)
            {
                Wait.Start();
            }
            Wait.SubStart(items.Length);
            try
            {
                int ct   = 0;
                int step = Math.Max(2, Wait.MaxProgress / 100);
                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    if (this.HaveToStop)
                    {
                        break;
                    }


                    SimPe.Interfaces.Files.IPackageFile pkg = item.Package;

                    SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(Data.MetaData.STRING_FILE, 0, Data.MetaData.LOCAL_GROUP, 0x00000A46);
                    string name = SimPe.Localization.GetString("Unknown");
                    if (pfd != null)
                    {
                        SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                        str.ProcessData(pfd, pkg);

                        SimPe.PackedFiles.Wrapper.StrItemList list = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode);
                        if (list.Count > 0)
                        {
                            name = list[0].Title;
                        }
                    }

                    SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
                    pic.ProcessData(item);

                    uint inst = GetInstanceFromFilename(pkg.SaveFileName);

                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] ltxtitems = ngbhfi.FindFile(0x0BF999E7, Data.MetaData.LOCAL_GROUP, inst, null);
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem   ltxt      = null;
                    if (ltxtitems.Length > 0)
                    {
                        ltxt = ltxtitems[0];
                    }

                    LotItem li = new LotItem(inst, name, pic.Image, ltxt);
                    if (LoadingLot != null)
                    {
                        LoadingLot(this, li);
                    }
                    content[li.Instance] = li;
                    ct++;
                    if (ct % step == 0)
                    {
                        Wait.Message  = name;
                        Wait.Progress = ct;
                    }
                }                //foreach
            }
#if !DEBUG
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }
#endif
            finally
            {
                Wait.SubStop();
                if (!run)
                {
                    Wait.Stop();
                }
            }

            ended.Set();
        }
Exemplo n.º 6
0
 private void CBoxLotNums_GettingFocus(UIElement sender, GettingFocusEventArgs args)
 {
     SelectedLot = new LotItem();
 }
Exemplo n.º 7
0
 private void CBoxLotNums_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
 {
     SelectedLot = args.SelectedItem as LotItem;
     sender.Text = SelectedLot.Code;
 }
Exemplo n.º 8
0
        public async Task <IActionResult> Create(int id, [Bind("LotItemId,lotId,ItemName,Quantity,EstimatedUnitRate,ActualUnitRate,UnitId,Description")] LotItem lotItem, IEnumerable <IFormFile> images)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lotItem);
                await _context.SaveChangesAsync();

                IFormFile picture = null;
                foreach (var file in images)
                {
                    LotItemImage ImgObj = new LotItemImage();
                    if (file != null && file.Length > 0)
                    {
                        picture = file;
                        var rootPath = Path.Combine(
                            Directory.GetCurrentDirectory(), "wwwroot\\Documents\\Procurement\\");
                        string fileName = Path.GetFileName(picture.FileName);
                        fileName = fileName.Replace("&", "n");
                        string AName = _context.Lot.Include(a => a.Activity).Where(a => a.lotId == id).Select(a => a.Activity.Name).FirstOrDefault().ToString();
                        AName = AName.Replace("&", "n");
                        string ItemName = lotItem.ItemName.Replace("&", "n");
                        var    PPName   = _context.ProcurementPlan.Find(_context.Activity.Find(_context.Lot.Find(lotItem.lotId).ActivityID).ProcurementPlanID).Name;
                        ImgObj.ImagePath = Path.Combine("/Documents/Procurement/", PPName + "/" + "//" + AName + "//Lot//" + lotItem.lotId.ToString() + "//" + ItemName + "//" + fileName);//Server Path
                        string sPath = Path.Combine(rootPath, PPName + "/" + AName + "//Lot//" + lotItem.lotId.ToString() + "//" + ItemName);
                        if (!System.IO.Directory.Exists(sPath))
                        {
                            System.IO.Directory.CreateDirectory(sPath);
                        }
                        string FullPathWithFileName = Path.Combine(sPath, fileName);
                        using (var stream = new FileStream(FullPathWithFileName, FileMode.Create))
                        {
                            await picture.CopyToAsync(stream);
                        }
                        ImgObj.LotItemId  = _context.LotItem.Max(a => a.LotItemId);
                        ImgObj.Visibility = true;
                        _context.LotItemImage.Add(ImgObj);
                    }
                }
                _context.SaveChanges();
                ViewBag.LId    = lotItem.lotId;
                ViewBag.UnitId = new SelectList(_context.Unit, "UnitId", "Name", lotItem.UnitId);
                return(RedirectToAction(nameof(Create), new { lotItem.lotId }));
            }
            var ActivityID = _context.Lot.Include(a => a.Activity).Where(a => a.lotId == id).FirstOrDefault();

            ViewBag.AID = ActivityID.Activity.ActivityID;
            var result = _context.Lot
                         .Where(a => a.lotId == id)
                         .Select(x => new
            {
                x.lotId,
                lotDescription = "Lot No. " + x.lotno.ToString()
            });

            ViewBag.LotNo           = result.Select(a => a.lotDescription).FirstOrDefault();
            ViewBag.lotId           = new SelectList(result, "lotId", "lotDescription", lotItem.lotId);
            ViewBag.UnitId          = new SelectList(_context.Unit, "UnitId", "Name", lotItem.UnitId);
            ViewBag.LId             = id;
            ViewBag.LotTotalItems   = _context.Lot.Where(a => a.lotId == id).Select(a => a.ItemTotal).FirstOrDefault();
            ViewBag.CurrentLotItems = _context.LotItem.Count(a => a.lotId == id);
            return(View(lotItem));
        }
    public MainViewModel(StockItemEditViewModelFactory editViewModelfactory)
    {
        StockItem stockItem = new LotItem();

        this.ActiveItem = editViewModelFactory.Create(myStockItem);
    }