コード例 #1
0
        public static decimal GetretiredAmountByRequisitionId(long ExpenseRequisitionId)
        {
            try
            {
                #region Current Session Check
                var user     = System.Web.HttpContext.Current.User.Identity.Name;
                var userData = MvcApplication.GetUserData(user);
                if (userData == null || userData.UserId < 1)
                {
                    return(decimal.Zero);
                }


                #endregion
                var searchObj = new RetirementSearchObj
                {
                    AdminUserId  = userData.UserId,
                    RetirementId = 0,
                    StartDate    = "",
                    StopDate     = "",
                    VoucheNumber = "",
                    Status       = -1000
                };
                var retVal = RetirementServices.LoadRetirements(searchObj, userData.Username);
                if (retVal?.Status == null)
                {
                    return(decimal.Zero);
                }
                if (retVal.Retirements == null || !retVal.Retirements.Any())
                {
                    return(decimal.Zero);
                }
                var retirement = retVal.Retirements.SingleOrDefault(x => x.ExpenseRequisitionId == ExpenseRequisitionId);
                if (retirement == null)
                {
                    return(decimal.Zero);
                }
                return(retirement.AmountRetired);
            }
            catch (Exception ex)
            {
                return(decimal.Zero);
            }
        }
コード例 #2
0
        public ActionResult _Receipt(int ExpenseRequisitionId)
        {
            try
            {
                #region Client Product productItem Session Check

                var userClientSession = (AppSession)Session["_UserClientSession_"];
                if (userClientSession == null || userClientSession.ClientId < 1 || userClientSession.ProductId < 1 || userClientSession.ProductItemId < 1)
                {
                    return(RedirectToAction("Index", "Dashboard"));
                }
                var ClientId      = userClientSession.ClientId;
                var ProductId     = userClientSession.ProductId;
                var ProductItemId = userClientSession.ProductItemId;

                #endregion

                #region Current Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <RegReceiptObj>()));
                }


                #endregion

                #region current Id check

                if (ExpenseRequisitionId < 1)
                {
                    ViewBag.Error = "Invalid selection";
                    return(View(new List <RegReceiptObj>()));
                }

                #endregion

                #region Request and response validations


                var searchObj = new RetirementSearchObj
                {
                    AdminUserId  = userData.UserId,
                    RetirementId = 0,
                    StartDate    = "",
                    StopDate     = "",
                    VoucheNumber = "",
                    Status       = -1000
                };
                var retVal = RetirementServices.LoadRetirements(searchObj, userData.Username);
                if (retVal?.Status == null)
                {
                    ViewBag.Error = "Error Occurred! Please try again later";
                    return(View(new List <RegReceiptObj>()));
                }
                if (retVal.Retirements == null || !retVal.Retirements.Any())
                {
                    return(View(new List <RegReceiptObj>()));
                }
                var ReqReceipt = retVal.Retirements.SelectMany(x => x.Receipts).Where(c => c.ExpenseRequisitionId == ExpenseRequisitionId);
                if (ReqReceipt == null)
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(View(new List <RegReceiptObj>()));
                }

                Session["_ReqReceipt_"] = ReqReceipt;

                return(View(ReqReceipt));

                #endregion
            }
            catch (Exception)
            {
                throw;
            }
        }