Example #1
0
        private ERequestedItem ERequestedItem(RequestedItem requestedItem)
        {
            ERequestedItem returnERequestedItem = new ERequestedItem
            {
                RequestedItemId = requestedItem.RequestedItemId,
                EmployeeId      = requestedItem.EmployeeId,
                DepartmentId    = requestedItem.DepartmentId,
                ImplementedBy   = requestedItem.ImplementedBy,
                RemovedBy       = requestedItem.RemovedBy,
                Comment         = requestedItem.Comment
            };

            return(returnERequestedItem);
        }
Example #2
0
 /// <summary>
 /// Converts requested item to requested item view model
 /// </summary>
 /// <param name="requestedItem">Requested item model</param>
 /// <param name="imagesList">Images list</param>
 /// <returns>Requested item view model</returns>
 private RequestedItemViewModel convertToRequestedItemViewModel(RequestedItem requestedItem, IEnumerable <RequestedImageViewModel> imagesList)
 {
     return(new RequestedItemViewModel
     {
         Id = requestedItem.Id,
         Name = requestedItem.Name,
         Description = requestedItem.Description,
         Status = requestedItem.Status?.StatusName,
         GoodsCategoryId = requestedItem.GoodsCategoryId,
         OrganizationId = requestedItem.OrganizationId,
         GoodsCategory = requestedItem.GoodsCategory?.Name,
         GoodsTypeId = requestedItem.GoodsCategory.GoodsTypeId,
         Images = imagesList
     });
 }
Example #3
0
 public void CreateRequestedItems(List <Client_DemandedItemPK_RequestedQuantity> list, int requestPK)
 {
     try
     {
         foreach (var item in list)
         {
             RequestedItem requestedItem = new RequestedItem(item.RequestedQuantity, requestPK, item.DemandedItemPK);
             db.RequestedItems.Add(requestedItem);
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        /// <summary>
        /// Updates requested item in database
        /// </summary>
        /// <param name="requestedItemViewModel">Requested item view model</param>
        /// <returns>Requested item view model</returns>
        public RequestedItemViewModel UpdateRequestedItem(RequestedItemViewModel requestedItemViewModel)
        {
            try
            {
                RequestedItem requestedItem = this.convertRequestedItem(requestedItemViewModel);
                SetRequestedItemImage(requestedItemViewModel.Images, requestedItem);

                this._unitOfWork.RequestedItemRepository.Update(requestedItem);
                this._unitOfWork.SaveChanges();

                return(requestedItemViewModel);
            }
            catch (Exception ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }
Example #5
0
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        RequestedItem objAsPart = obj as RequestedItem;

        if (objAsPart == null)
        {
            return(false);
        }
        else
        {
            return(Equals(objAsPart));
        }
    }
Example #6
0
    protected void BtnAdd_Click(object sender, EventArgs e)
    {
        //reqItem = new ArrayList();
        des = ddlItem.SelectedItem.ToString();
        int qty = Convert.ToInt32(txtQuantity.Text);

        if (gvItemList.Rows.Count <= 0)
        {
            ri    = new RequestedItem(code, des, qty, lblUom.Text);
            rItem = (List <RequestedItem>)ViewState["list"];
            rItem.Add(ri);
            //reqItem.Add(ri);
            ViewState["list"] = rItem;
        }

        else
        {
            bool isEqual = false;
            foreach (GridViewRow row in gvItemList.Rows)
            {
                System.Web.UI.WebControls.Label labelDes = (System.Web.UI.WebControls.Label)row.FindControl("lblCode");
                string item = labelDes.Text;

                if (code.Equals(item))
                {
                    isEqual = true;
                }
            }
            if (isEqual)
            {
                Response.Write("<script>alert('Item is already in the form.');</script>");
            }
            else
            {
                ri    = new RequestedItem(code, des, qty, lblUom.Text);
                rItem = (List <RequestedItem>)ViewState["list"];
                rItem.Add(ri);
                ViewState["list"] = rItem;
            }
        }
        BindGrid();
    }
Example #7
0
    protected void ReqRow_Updating(object sender, GridViewUpdateEventArgs e)
    {
        vsQuantity.Enabled = true;
        System.Web.UI.WebControls.TextBox qtyText = (System.Web.UI.WebControls.TextBox)gvItemList.Rows[e.RowIndex].FindControl("txtQty");
        int newQty = Convert.ToInt32(qtyText.Text);

        System.Web.UI.WebControls.Label itemDescLabel = (System.Web.UI.WebControls.Label)gvItemList.Rows[e.RowIndex].FindControl("lblCode");
        string code = itemDescLabel.Text;

        RequestedItem i = rItem.Find(r => r.Code.Equals(code));

        rItem = (List <RequestedItem>)ViewState["list"];

        i.Quantity = Convert.ToInt32(newQty);
        rItem[e.RowIndex].Quantity = i.Quantity;
        ViewState["list"]          = rItem;

        gvItemList.EditIndex = -1;
        BindGrid();
    }
Example #8
0
 /// <summary>
 /// Configures model creation
 /// </summary>
 /// <param name="modelBuilder">modelBuilder to configure Model Creation</param>
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     User.Configure(modelBuilder);
     Phone.Configure(modelBuilder);
     Address.Configure(modelBuilder);
     UserAddress.Configure(modelBuilder);
     Role.Configure(modelBuilder);
     Organization.Configure(modelBuilder);
     OrgAddress.Configure(modelBuilder);
     ExternalContact.Configure(modelBuilder);
     Membership.Configure(modelBuilder);
     Currency.Configure(modelBuilder);
     BankAccount.Configure(modelBuilder);
     OrgAccount.Configure(modelBuilder);
     Balance.Configure(modelBuilder);
     Target.Configure(modelBuilder);
     FinOp.Configure(modelBuilder);
     Tag.Configure(modelBuilder);
     TagFinOp.Configure(modelBuilder);
     Event.Configure(modelBuilder);
     EventImage.Configure(modelBuilder);
     Complaint.Configure(modelBuilder);
     GoodsType.Configure(modelBuilder);
     GoodsCategory.Configure(modelBuilder);
     OfferedItem.Configure(modelBuilder);
     RequestedItem.Configure(modelBuilder);
     BankImport.Configure(modelBuilder);
     BankImportDetail.Configure(modelBuilder);
     PasswordReset.Configure(modelBuilder);
     BannedUser.Configure(modelBuilder);
     BannedOrganization.Configure(modelBuilder);
     SubscribeOrganization.Configure(modelBuilder);
     Status.Configure(modelBuilder);
     OfferedItemImage.Configure(modelBuilder);
     RequestedItemImage.Configure(modelBuilder);
     UserResponse.Configure(modelBuilder);
     OrganizationResponse.Configure(modelBuilder);
     Donation.Configure(modelBuilder);
     Bank.Configure(modelBuilder);
     AutoImportIntervals.Configure(modelBuilder);
 }
Example #9
0
        public int SaveDeliveredRequestedItem(RequestedItem item, string createdBy)
        {
            int objID = 0;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_REQUEST_ORDER_ITEM_IN") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", item.RequestOrderID);
                DBClass.AddSimpleParameter(cmd, "@ProductId", item.ProductID);
                DBClass.AddSimpleParameter(cmd, "@Qty", item.Qty);
                DBClass.AddSimpleParameter(cmd, "@DeliveredDate", item.DeliveredDate);
                DBClass.AddSimpleParameter(cmd, "@Note", item.Note);
                DBClass.AddSimpleParameter(cmd, "@CreatedBy", createdBy);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    objID = int.Parse(reader[0].ToString());
                }
            }
            return(objID);
        }
Example #10
0
        public RequestedItem GetRequestedItemOutById(int requestOrderInID)
        {
            var item = new RequestedItem();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_REQUEST_ORDER_ITEM_OUT_BY_ID") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderOutId", requestOrderInID);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    item.LogObject = new StockLogObject
                    {
                        DepartementID  = int.Parse(reader[0].ToString()),
                        ProductID      = int.Parse(reader[1].ToString()),
                        RequestVoucher = reader[2].ToString()
                    };
                }
            }
            return(item);
        }
Example #11
0
 public void UpdateRequestedItems(List <Client_RequestedItemPK_RequestedQuantity> list, int requestPK)
 {
     try
     {
         foreach (var item in list)
         {
             RequestedItem requestedItem = db.RequestedItems.Find(item.RequestedItemPK);
             if (requestedItem.RequestPK != requestPK)
             {
                 throw new Exception("CÓ ITEM KHÔNG NẰM TRONG YÊU CẦU XUẤT");
             }
             requestedItem.RequestedQuantity = item.RequestedQuantity;
             db.Entry(requestedItem).State   = EntityState.Modified;
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #12
0
        public RequestedItem OnRequest(int itemId, string beginDate, string endDate, int eventId, int userId)
        {
            DateTime dt_1 = Convert.ToDateTime(beginDate);
            DateTime dt_2 = Convert.ToDateTime(endDate);

            var q = (from i in ctx.Items
                     where i.Id == itemId
                     select i).FirstOrDefault();

            var t = (from e in ctx.Events
                     where e.Id == eventId
                     select e).FirstOrDefault();

            var k = (from u in ctx.Users
                     where u.Id == userId
                     select u).FirstOrDefault();

            RequestedItem item = new RequestedItem();

            item.ItemId    = q.Id;
            item.EventId   = t.Id;
            item.UserId    = k.Id;
            item.BeginDate = dt_1;
            item.EndDate   = dt_2;
            item.ItemId    = itemId;
            item.EventId   = eventId;
            item.UserId    = userId;

            ctx.RequestedItems.Add(item);
            ctx.SaveChanges();

            var p = (from i in ctx.Items
                     where i.Id == itemId
                     select i).FirstOrDefault();

            p.Status = 1;
            ctx.SaveChanges();

            return(item);
        }
Example #13
0
        /// <summary>
        /// Updates requested item in database
        /// </summary>
        /// <param name="requestedItemViewModel">Requested item view model</param>
        /// <returns>Requested item view model</returns>
        public RequestedItemViewModel UpdateRequestedItem(RequestedItemViewModel requestedItemViewModel)
        {
            var imagesToUpdate = requestedItemViewModel.Images.Where(e => e.RequestedItemId == 0);
            IEnumerable <RequestedItemImage> imagesList = this.convertViewModelImageList(imagesToUpdate,
                                                                                         requestedItemViewModel.Id);

            try
            {
                RequestedItem requestedItem = this.convertRequestedItem(requestedItemViewModel);

                this._unitOfWork.RequestedItemRepository.Update(requestedItem);
                this._unitOfWork.RequestedItemImageRepository.SaveListOfImages(imagesList);

                this._unitOfWork.SaveChanges();

                return(requestedItemViewModel);
            }
            catch (Exception ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }
Example #14
0
        public IEnumerable <RequestedItem> GetRequestedItemOut(int RequestOrderId, int productID)
        {
            var result = new List <RequestedItem>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_REQUEST_ORDER_ITEM_OUT") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", RequestOrderId);
                DBClass.AddSimpleParameter(cmd, "@ProductId", productID);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var item = new RequestedItem();
                    item.ItemOutID   = int.Parse(reader[0].ToString());
                    item.DeliverQty  = decimal.Parse(reader[1].ToString());
                    item.DeliverDate = DateTime.Parse(reader[2].ToString());
                    item.Note        = reader[3].ToString();
                    result.Add(item);
                }
            }
            return(result);
        }
Example #15
0
    public void RegenerateRequisition(List <WCFRequestedItem> regenList)
    {
        int disbId = 0;

        List <RequestedItem> requItemList = new List <RequestedItem>();

        foreach (WCFRequestedItem r in regenList)
        {
            RequestedItem rItem = new RequestedItem(r.Code, r.Description, Convert.ToInt32(r.ShortfallQty), RequisitionControl.getUOM(r.Code));
            disbId = r.DisbId;
            requItemList.Add(rItem);
        }

        DateTime date    = (disbCon.GetRegenrateDate(disbId));
        string   depName = EFBroker_Disbursement.GetDisbursmentbyDisbID(Convert.ToInt32(disbId)).Department.DeptName;
        string   reqBy   = EFBroker_DeptEmployee.GetDeptRepByDeptCode(depName);
        int      empID   = EFBroker_DeptEmployee.GetDeptRepEmpIDByDeptCode(depName);
        string   depCode = EFBroker_DeptEmployee.GetDepartByEmpID(empID).DeptCode;
        string   status  = "Priority";

        RequisitionControl.addNewRequisitionItem(requItemList, date, status, empID, depCode);
    }
Example #16
0
        /// <summary>
        /// Gets requested item from database
        /// </summary>
        /// <param name="id">Id of requested item</param>
        /// <returns>Requested item view model</returns>
        public RequestedItemViewModel GetItemById(int id)
        {
            try
            {
                RequestedItem requestedItem = this._unitOfWork.RequestedItemRepository.Get(id);

                if (requestedItem == null)
                {
                    throw new BusinessLogicException($"Потреба з ідентифікатором {id} не знайдена");
                }

                IEnumerable <RequestedImageViewModel> imagesList = this.convertRequestItemImageModelList(requestedItem.RequestedItemImages,
                                                                                                         requestedItem.Id);

                RequestedItemViewModel itemViewModel = this.convertToRequestedItemViewModel(requestedItem, imagesList);

                return(itemViewModel);
            }
            catch (Exception ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }
Example #17
0
        /// <summary>
        /// Gets requested item from database
        /// </summary>
        /// <param name="id">Id of requested item</param>
        /// <returns>Requested item view model</returns>
        public RequestedItemViewModel GetItemById(int id)
        {
            try
            {
                RequestedItem requestedItem = this._unitOfWork.RequestedItemRepository.Get(id);

                if (requestedItem == null)
                {
                    throw new BusinessLogicException($"{ErrorMessages.RequstWasnotFoundWithId} {id} ");
                }

                IEnumerable <RequestedImageViewModel> imagesList = this.convertRequestItemImageModelList(requestedItem.RequestedItemImages,
                                                                                                         requestedItem.Id);

                RequestedItemViewModel itemViewModel = this.convertToRequestedItemViewModel(requestedItem, imagesList);

                return(itemViewModel);
            }
            catch (Exception ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }
Example #18
0
 private void SaveRequestedItem(int id, RequestedItem item)
 {
     using (DBClass = new MSSQLDatabase())
     {
         using (DbTransaction txn = DBClass.BeginTransaction())
         {
             try
             {
                 var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_REQUEST_ORDER_ITEM") as SqlCommand;
                 DBClass.AddSimpleParameter(cmd, "@RequestOrderId", id);
                 DBClass.AddSimpleParameter(cmd, "@ProductId", item.ProductID);
                 DBClass.AddSimpleParameter(cmd, "@Qty", item.Qty);
                 DBClass.ExecuteNonQuery(cmd, txn);
                 txn.Commit();
             }
             catch (Exception)
             {
                 txn.Rollback();
                 throw;
             }
         }
     }
 }
Example #19
0
        public async Task MessageReceived(string fromNumber, string toNumber, string text, List <RemoteFile> files)
        {
            _logger.LogInformation($"New Incoming SMS from {fromNumber}: {text}");

            var users = await _beachBuddyRepository.GetUsers(new UserResourceParameters()
            {
                PhoneNumber = fromNumber
            });

            var userWhoSentMessage = users.FirstOrDefault();

            if (userWhoSentMessage == null)
            {
                await _twilioService.SendSms(fromNumber, "Sorry, I don't know who you are.");

                return;
            }

            var words = text.Split(" ");
            var firstWordOfMessage = words[0].ToLower();

            var firstChar = firstWordOfMessage.ToCharArray()[0];

            if (firstChar == '+' || firstChar == '-')
            {
                await ProcessScoreUpdate(text, userWhoSentMessage, fromNumber, toNumber);

                return;
            }

            string secondWordOfMessage = null;

            if (words.Length >= 2)
            {
                secondWordOfMessage = text.Split(" ")[1].ToLower();
            }

            switch (firstWordOfMessage.ToLower())
            {
            case "done":
                _backgroundTaskQueue.QueueSunscreenReminderForUser(userWhoSentMessage.Id);
                await _twilioService.SendSms(fromNumber, "Great! I'll let you know once it's dry and then again when it's time to reapply. ⏱");

                return;

            case "refresh":
                await _notificationService.sendNotification(null, NotificationType.DashboardPulledToRefresh, null, null, true);

                return;

            case "remove":
                await RemoveItems(fromNumber, toNumber, text, firstWordOfMessage);

                // Send data notification so app will update
                await _notificationService.sendNotification(null, NotificationType.RequestedItemRemoved, null, null, true);

                return;

            case "list":
                await ShowAllItems(fromNumber);

                return;

            case "h":
                await ShowHelp(fromNumber);

                return;

            case "nukefromorbit":
                await RemoveItems(fromNumber, toNumber, text, firstWordOfMessage, true);

                // Send data notification so app will update
                await _notificationService.sendNotification(null, NotificationType.RequestedItemRemoved, null, null, true);

                return;

            case "bal":
                await GetBalance(fromNumber);

                return;

            case "add":
                if (secondWordOfMessage != null && secondWordOfMessage == "game")
                {
                    var gameName = text.Substring("add game".Length).Trim();
                    await AddGame(gameName, fromNumber);

                    return;
                }

                break;

            case "leaderboard":
                await ShowLeaderBoard(fromNumber);

                return;
            }

            var requestedItemToSave = new RequestedItem();

            // Check if there is a quantity
            if (int.TryParse(firstWordOfMessage, out var quantity))
            {
                text = text.Substring(firstWordOfMessage.Length).Trim();
            }
            else
            {
                quantity = 1;
            }

            if (string.IsNullOrWhiteSpace(text))
            {
                await _twilioService.SendSms(fromNumber,
                                             $"Sorry, I didn't detect anything to add to the list.");

                return;
            }

            requestedItemToSave.Id                = Guid.NewGuid();
            requestedItemToSave.Count             = quantity;
            requestedItemToSave.CreatedDateTime   = DateTimeOffset.UtcNow;
            requestedItemToSave.RequestedByUserId = userWhoSentMessage.Id;
            requestedItemToSave.RequestedByUser   = userWhoSentMessage;
            requestedItemToSave.Name              = text;

            try
            {
                await _beachBuddyRepository.AddRequestedItem(requestedItemToSave);

                await _beachBuddyRepository.Save();
            }
            catch (Exception e)
            {
                _logger.LogError($"Something did not work when trying to save a requested item via Twilio: {e.Message}",
                                 e);
                await _twilioService.SendSms(fromNumber,
                                             $"Sorry, I couldn't add {text} to the list. Try again.)");

                return;
            }

            await _notificationService.sendNotification(
                await _beachBuddyRepository.GetRequestedItem(requestedItemToSave.Id),
                NotificationType.RequestedItemAdded,
                $"\"{requestedItemToSave.Name}\" added to list", $"{userWhoSentMessage.FirstName} " +
                $"added {requestedItemToSave.Count} {requestedItemToSave.Name} to the Beach List.",
                false);

            await _twilioService.SendSms(fromNumber, $"\"{text}\" was added to the list!");
        }
        /// <summary>
        /// Update requested item in database
        /// </summary>
        /// <param name="item">Requested item model</param>
        /// <returns>Updated requested item entity</returns>
        public RequestedItem Update(RequestedItem item)
        {
            var updatedRequetedItem = this._dbContext.RequestedItems.Update(item);

            return(updatedRequetedItem.Entity);
        }
        /// <summary>
        /// Create requested item in database
        /// </summary>
        /// <param name="item">Requested item model</param>
        /// <returns>Created requested item</returns>
        public RequestedItem Create(RequestedItem item)
        {
            var requestedItem = this._dbContext.RequestedItems.Add(item);

            return(requestedItem.Entity);
        }
Example #22
0
        private void SetRequestedItemImage(IEnumerable <RequestedImageViewModel> incomingImages, RequestedItem offerItem)
        {
            //images in Db
            List <RequestedItemImage> storedImages = _unitOfWork.RequestedItemImageRepository.GetImagesByRequestedItemId(offerItem.Id).ToList();

            //new images user set
            List <RequestedImageViewModel> incomeNewImages = incomingImages.Select(i => i).Where(i => !String.IsNullOrEmpty(i.Base64Data)).ToList();

            if (incomeNewImages.Any(i => i.IsMain))
            {
                storedImages.ForEach(i => i.IsMain = false);
            }

            //in case when only main image was changed
            storedImages.ForEach(si => si.IsMain = incomingImages.
                                                   Select(i => i).
                                                   Where(i => i.Id == si.Id).
                                                   FirstOrDefault()
                                                   ?.IsMain ?? si.IsMain);

            //old images stored in Db
            var incomeOldImages      = incomingImages.Select(i => i).Where(i => String.IsNullOrEmpty(i.Base64Data));
            var incomeOldImagesModel = ConvertToRequestedItemImages(incomeOldImages);

            //old images which we have removed from offerItem.Images
            var uslesImages = storedImages.Where(l2 => !incomeOldImagesModel.Any(l1 => l1.ImageUrl == l2.ImageUrl)).ToList();

            foreach (var stuff in uslesImages)
            {
                _unitOfWork.RequestedItemImageRepository.Delete(stuff.Id);
                storedImages.Remove(stuff);
                _imgService.DeleteImageAsync(AzureStorageConfiguration.GetImageNameFromUrl(stuff.ImageUrl));
            }

            //save new images
            var newImages = UploadImagesToStorage(incomeNewImages, offerItem.Id);

            foreach (var picture in newImages)
            {
                var newImg = _unitOfWork.RequestedItemImageRepository.Create(picture);
                storedImages.Add(newImg);
            }

            offerItem.RequestedItemImages = storedImages;
        }
    protected void btnAck_Click(object sender, EventArgs e)
    {
        int disbId = (int)Session["SelectedDisb"];

        List <DisbursementDetailListItems> retrievedItem = new List <DisbursementDetailListItems>();

        retrievedItem = disbCon.GvDisbursementDetailPopulate(disbId);

        List <RequestedItem>   shortfallItem = new List <RequestedItem>();
        List <int>             actualQtyList = new List <int>();
        List <string>          disbRemark    = new List <string>();
        Dictionary <Item, int> discToUpdate  = new Dictionary <Item, int>();
        RequestedItem          reqItem;
        bool check = true;

        foreach (GridViewRow r in gvDisbDetail.Rows)
        {
            //get disbursement remarks for each items
            string remark;
            try
            {
                remark = (r.FindControl("txtremarks") as TextBox).Text;
            }
            catch
            {
                remark = "";
            }

            //add remarks to list to save to database
            disbRemark.Add(remark);


            //get retrieved item to compare
            int index        = r.RowIndex;
            int retrievedQty = retrievedItem[index].ActualQty;

            //get actual qty to verify
            int reqQty = Convert.ToInt32((r.FindControl("lblreqQty") as Label).Text);

            //get actual qty to verify
            int actualQty = Convert.ToInt32((r.FindControl("txtactualQty") as TextBox).Text);

            //make actual qty list to update database
            actualQtyList.Add(actualQty);

            //check if any shortfall
            if (actualQty < reqQty)
            {
                //make short fall item list
                string iCode        = (r.FindControl("hdnflditemCode") as HiddenField).Value;
                string iDesc        = (r.FindControl("lblitemDesc") as Label).Text;
                int    shortfallQty = reqQty - actualQty;
                string uom          = EFBroker_Item.GetUnitbyItemCode(iCode);
                reqItem = new RequestedItem(iCode, iDesc, shortfallQty, uom);
                shortfallItem.Add(reqItem);

                //check if any discrepancy
                if (actualQty < retrievedQty)
                {
                    //make discrepancy item list
                    int    disQty   = actualQty - retrievedQty;
                    Item   disItem  = EFBroker_Item.GetItembyItemCode(iCode);
                    string finalQty = (disItem.BalanceQty + disQty).ToString();
                    discToUpdate.Add(disItem, disQty);
                }
            }
            else if (actualQty > retrievedQty)
            {
                check = false;
                (r.FindControl("lblActualError") as Label).Text = "Actual cannot be more than retrieved quantity";
            }
        }
        if (check)
        {
            //check access code
            if (disbCon.CheckAccessCode(disbId, txtAccessCode.Text))
            {
                //update Disbursement table (actual qty + status)
                disbCon.UpdateDisbursement(disbId, actualQtyList, disbRemark);

                //redirect to Regenerate Request page if any shortfall
                if (shortfallItem.Count != 0)
                {
                    Session["discrepancyList"] = discToUpdate;
                    Session["RegenerateDate"]  = disbCon.GetRegenrateDate(disbId);
                    Session["RegenerateDep"]   = lblDepartment.Text;
                    Session["RequestedByName"] = EFBroker_DeptEmployee.GetDeptRepByDeptCode(lblDepartment.Text);
                    Session["RegenerateItems"] = shortfallItem;

                    Response.Redirect(LoginController.RegenerateRequestURI);
                }
                //redirect back to Disbursement List page if no shortfall
                else
                {
                    Session["SelectedDisb"]  = null;
                    Session["disbItemsList"] = null;
                    Response.Redirect(LoginController.DisbursementListURI);
                }
            }
            else
            {
                string message = "Incorrect Access Code!";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true);
            }
        }
    }
Example #24
0
        //method DisplayRequestedItems()
        public void DisplayRequestedItems()
        {
            //initial values

            Console.WriteLine("\nREQUESTED ITEMS\n");

            decimal FinalSubTotal              = 0;
            decimal FinalGrossTotal            = 0;
            decimal FinalNetTotal              = 0;
            int     listNumber                 = 0;
            int     ExpectedDeliveryTimeInDays = int.MinValue;

            if (RequestedItems.Count == 0)
            {
                throw new ArgumentException("Requested Items list for this order is empty");
            }
            else
            {
                foreach (OrderItem RequestedItem in RequestedItems)
                {
                    //The polymorphism implemented in the GetSubTotal(), GetGrossTotal(), GetNetTotal() and GetDeliveryDetails() methods
                    //will output the results according to the conditions set for each derivative class

                    //GetSubTotal()
                    RequestedItem.GetSubTotal();
                    FinalSubTotal += RequestedItem.SubTotal;

                    //GetGrossTotal()
                    RequestedItem.GetGrossTotal();
                    FinalGrossTotal += RequestedItem.GrossTotal;

                    //GetNetTotal();
                    RequestedItem.GetNetTotal();
                    FinalNetTotal += RequestedItem.NetTotal;

                    //Increment the list number
                    ++listNumber;
                    Console.WriteLine($"{listNumber}.");

                    //Set the default value of Requested Item.Continent for each Requested Item
                    //to the value of the Recipient Continent
                    RequestedItem.Continent = DestinationDetails.Continent;

                    //Retrieve each Requested Item's Delivery Details according to the above value for Continent
                    RequestedItem.GetDeliveryDetails();

                    //determines the maximum of all delivery times of the Requested Items and sets the maximum as the overall expected delivery time
                    if (RequestedItem.IndicativeDeliveryTimeInDays > ExpectedDeliveryTimeInDays)
                    {
                        ExpectedDeliveryTimeInDays = RequestedItem.IndicativeDeliveryTimeInDays;
                    }

                    //Display each Requested Item
                    Console.WriteLine(RequestedItem.ToString());
                }
            }
            Console.WriteLine("\nTOTAL\n");
            Console.Write($"Expected Delivery Time (Days):\t\t{ExpectedDeliveryTimeInDays}{Environment.NewLine}" +
                          $"\nFinal Sub Total:\t\t\t{FinalSubTotal:C}{Environment.NewLine}" +
                          $"\nFinal Gross Total:\t\t\t{FinalGrossTotal:C}{Environment.NewLine}" +
                          $"\nFinal Net Total:\t\t\t{FinalNetTotal:C}{Environment.NewLine}");
        } //end DisplayRequestedItems()