Ejemplo n.º 1
0
        public ActionResult New([Bind(Include = "Id,FirstName,Lastname,CustomerType,CustomerNumber")] AMCustomer aMCustomer, string UnitId, string ProcessId, string ActivityId)
        {
            List <NavViewModel>           Nav = new List <NavViewModel>();
            UnitProcessActObjectViewModel UPA = new UnitProcessActObjectViewModel();

            if (!DmlObj.GetUPAwithNav(UnitId, ProcessId, ActivityId, User.GetAmUser(), out Nav, out UPA))
            {
                return(View("Error"));
            }

            ViewBag.Nav = Nav;
            ViewBag.UPA = UPA;
            var k = DmlObj.GetCustomerByCustomerNumber(aMCustomer.CustomerNumber);

            if (k.Count() > 0)
            {
                ModelState.AddModelError("CustomerNumber", "این شماره مشتری قبلا ثبت شده است");
            }
            if (aMCustomer.CustomerType == 0)
            {
                ModelState.AddModelError("CustomerType", "نوع مشتری انتخاب نشده است");
            }

            if (ModelState.IsValid)
            {
                if (DmlObj.AddNewCustomer(aMCustomer))
                {
                    ViewBag.CustomerNumber = aMCustomer.CustomerNumber;
                    return(View("Success"));
                }
            }
            return(View(aMCustomer));
        }
Ejemplo n.º 2
0
        // GET: Customer/Edit/5
        public ActionResult Edit(string UnitId, string ProcessId, string ActivityId, int?CustomerId)
        {
            if (CustomerId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            List <NavViewModel>           Nav = new List <NavViewModel>();
            UnitProcessActObjectViewModel UPA = new UnitProcessActObjectViewModel();

            if (!DmlObj.GetUPAwithNav(UnitId, ProcessId, ActivityId, User.GetAmUser(), out Nav, out UPA))
            {
                return(View("Error"));
            }

            ViewBag.Nav = Nav;
            ViewBag.UPA = UPA;

            AMCustomer aMCustomer = DmlObj.GetCustomerById(CustomerId);

            if (aMCustomer == null)
            {
                return(HttpNotFound());
            }
            return(View(aMCustomer));
        }
Ejemplo n.º 3
0
        public ActionResult New([Bind(Include = "Id,LoanType,LoanNumber,LoanTotalAmount,LoanDate,TotalInstallments,InstallmentDuration")] LoanRegisterationViewModel AMLoanReg, string UnitId, string ProcessId, string ActivityId, int CustomerId)
        {
            List <NavViewModel>           Nav = new List <NavViewModel>();
            UnitProcessActObjectViewModel UPA = new UnitProcessActObjectViewModel();

            if (!DmlObj.GetUPAwithNav(UnitId, ProcessId, ActivityId, User.GetAmUser(), out Nav, out UPA))
            {
                return(View("Error"));
            }

            ViewBag.Nav = Nav;
            ViewBag.UPA = UPA;
            AMCustomer k = new AMCustomer {
                Id = 0, FirstName = "مشتری شناسایی نشد"
            };

            k = DmlObj.GetCustomerById(CustomerId);
            if (k.Id == 0)
            {
                ModelState.AddModelError("LoanNumber", "مشتری شناسایی نشد");
            }
            if (AMLoanReg.LoanType == 0)
            {
                ModelState.AddModelError("LoanType", "نوع تسهیلات انتخاب نشده است");
            }

            if (AMLoanReg.InstallmentDuration == 0)
            {
                ModelState.AddModelError("InstallmentDuration", "فاصله زمانی اقساط انتخاب نشده است");
            }

            if (AMLoanReg.LoanNumber == null || AMLoanReg.LoanNumber.Length < 6 || AMLoanReg.LoanNumber.Length > 13)
            {
                ModelState.AddModelError("LoanNumber", "شماره تسهیلات نادرست است");
            }

            AMLoanReg.LoanDate = AMLoanReg.LoanDate.PersianDateToDateTime();
            if (AMLoanReg.LoanDate.Year == 1800)
            {
                ModelState.AddModelError("LoanDate", "تاریخ تسهیلات نادرست است");
            }

            if (ModelState.IsValid)
            {
                AMLoanReg.UnitId = UPA.Unit.Id;
                if (DmlObj.AddNewLoan(AMLoanReg, k))
                {
                    ViewBag.Customer = k;
                    return(View("Success"));
                }
            }
            ViewBag.Customer = k;
            return(View(AMLoanReg));
        }