public ActionResult Add(ClaimFigure CF, string InvoiceType)
        {
            if (CF != null)
            {
                UserAccount u = (UserAccount)Session["UserAccount"];

                if (_claimDao.ValidateBudgetAmount(CF.AccountCode, CF.ProgramType != null ? CF.ProgramType.Id : 0, CF.InvoiceAmount))
                {
                    if (_claimDao.ValidateAccountCode(CF.AccountCode))
                    {
                        CF.SystemIp  = GetRemoteIp.GetIPAddress(HttpContext);
                        CF.CreatedBy = u.Id;
                        if (_claimFigureDao.SaveClaimFigure(CF) > 0)
                        {
                            return(RedirectToRoute("Claim_Index"));
                        }
                    }
                    else
                    {
                        ViewBag.Error = "Please Enter valid Account Code";
                    }
                }
                else
                {
                    ViewBag.Error = "The Distributor didn't have enough budget";
                }
            }
            else
            {
                ViewBag.Error = "Error occured.";
            }

            ViewBag.ProgramTypes = _distributorDao.GetProgramTypeList();

            return(View(CF));
        }
        public ActionResult Add(Claim C, string InvoiceType, string Quarter)
        {
            if (C != null && C.files != null)
            {
                UserAccount u            = (UserAccount)Session["UserAccount"];
                bool        Amountresult = _claimDao.ValidateBudgetAmount(C != null ? C.AccountCode : "", C.ProgramType != null ? C.ProgramType.Id : 0, C.InvoiceAmount);
                if (Amountresult)
                {
                    bool result = _claimDao.ValidateAccountCode(C != null ? C.AccountCode : "");
                    if (result)
                    {
                        C.InvoiceDocuments = new List <InvoiceDocument>();
                        foreach (HttpPostedFileBase d in C.files)
                        {
                            InvoiceDocument IVD = new InvoiceDocument();
                            if (d != null && d.FileName != null)
                            {
                                IVD.Name      = d.FileName;
                                IVD.GUID      = Guid.NewGuid().ToString();
                                IVD.Extension = System.IO.Path.GetExtension(IVD.Name);
                                IVD.ReAttach  = true;
                                string location = Path.Combine(Server.MapPath("~/Resources/InvoiceDocuments/"), IVD.GUID + IVD.Extension);
                                d.SaveAs(location);
                            }
                            C.InvoiceDocuments.Add(IVD);
                        }

                        C.SystemIp      = GetRemoteIp.GetIPAddress(HttpContext);
                        C.CreatedBy     = u.Id;
                        C.Quarter       = Quarter;
                        C.InvoiceTypeId = string.IsNullOrEmpty(InvoiceType) ? 0 : Security.Decrypt <Int64>(InvoiceType);
                        long Id = _claimDao.SaveClaim(C);
                        if (Id > 0)
                        {
                            return(RedirectToRoute("Claim_Index"));
                        }
                        else
                        {
                            ViewBag.Error = "Incorrect Date";
                        }
                    }
                    else
                    {
                        ViewBag.Error = "Please Enter valid Account Code";
                        // ModelState.AddModelError("Id", "Please Enter valid Account Code");
                    }
                }
                else
                {
                    ViewBag.Error = "The Distributor didn't have enough budget";
                    //ModelState.AddModelError("Id", "The Distributor didn't have enough budget");
                }
            }
            else
            {
                ViewBag.Error = "Incorrect Date";
                //ModelState.AddModelError("Id", "Incorrect Date");
            }
            List <SelectListItem> listItems = new List <SelectListItem>();

            listItems.Add(new SelectListItem
            {
                Text  = "服务费",
                Value = Security.Encrypt <string>("1")
            });
            listItems.Add(new SelectListItem
            {
                Text  = "礼品费用",
                Value = Security.Encrypt <string>("2")
            });
            ViewBag.InvoiceTypeList = listItems;
            ViewBag.ProgramTypes    = _distributorDao.GetProgramTypeList();
            return(View());
        }