コード例 #1
0
        public ActionResult Claims()
        {
            TempData["ReasontoLogin"] = "******";
            if (Session["CustomerId"] == null)
            {
                return(RedirectToAction("loginview", "login"));
            }
            int custID = Convert.ToInt32(Session["CustomerId"]);
            ClaimDetailsViewModel viewModel = new ClaimDetailsViewModel();

            viewModel.AgentCollection  = new HealthInsuranceDB().Agents;
            viewModel.ClaimsCollection = new HealthInsuranceDB().Claims.Where(c => c.CustomerID == custID).ToList();
            return(View(viewModel));
        }
コード例 #2
0
//
        public JsonResult SaveIndiviualMainClaims(ClaimDetailsViewModel pmodel, string pcref)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var emp = ReturnUserNames(pmodel.UserCode);

                    if (!pmodel.RequireUnit)
                    {
                        var saveClaim = new PClaimDetailModel
                        {
                            Amount     = Convert.ToDecimal(pmodel.TotalAmount),
                            PCRef      = pcref,
                            PayAccount = pmodel.PayAccount,
                            Qty        = pmodel.Quantity,
                            Rate       = 1,
                            Units      = ReturnUnitsForClaim(pmodel.ClaimId), //to fetch units from pclaimrated table
                            Notes      = pmodel.Notes
                        };
                        SaveClaimDetails(saveClaim);
                    }


                    if (pmodel.ClaimRequestUnits?.Count > 0)
                    {
                        foreach (var unit in pmodel.ClaimRequestUnits)
                        {
                            var saveUnit =
                                "INSERT INTO [dbo].[PClaimDetail]([PCRef] ,[PayAccount],[Code],[Rate],[Units],[Qty],[Amount],[Notes])VALUES("
                                + "'" + pcref + "','"
                                + pmodel.PayAccount + "','"
                                + unit.Code + "','"
                                + 1 + "','"
                                + unit.Rate + "','"
                                + unit.Quantity + "','"
                                + unit.Total + "','"
                                + +pmodel.ClaimRequestUnits.Count + " unit(s)/added by user'"
                                + ")";
                            _context.Database.ExecuteSqlCommand(saveUnit);
                        }
                    }

                    try
                    {
                        var wcf = new WfdocCentre
                        {
                            Type        = "PART-TIME CLAIM",
                            DocNo       = pcref,
                            Description = "AMOUNT : " + pmodel.TotalAmount + " SESSION : " + pmodel.Semester,
                            UserRef     = pmodel.UserCode,
                            Names       = emp.Names,
                            Department  = emp.Department,
                            Rdate       = DateTime.Now,
                            Rtime       = DateTime.Now.ToLocalTime(),
                            Personnel   = pmodel.UserCode,
                            FinalStatus = "Pending"
                        };
                        _context.WfdocCentre.Add(wcf);

                        _context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(Json(new
                        {
                            status = 0,
                            message = "A server error occured,please contact the administrator : " + ex.Message
                        }));
                    }

                    return(Json(new
                    {
                        status = 1,
                        message = "Claim saved successfully"
                    }));
                }
            }
            catch (Exception e)
            {
                return(Json(new
                {
                    Success = false,
                    Message = "A server error occured,please contact the administrator ",
                    Error = new Error(e)
                }));
            }

            return(Json(new
            {
                status = 0,
                message = "Could not save claim,please try again"
            }));
        }