예제 #1
0
        public ActionResult Create()
        {
            ViewBag.BankId       = new SelectList(CombosHelper.GetBanks(), "BankId", "Name");
            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name");
            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(0), "CityId", "Name");
            var projectModel = new Project
            {
                Salary = 0
            };

            return(View(projectModel));
        }
예제 #2
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Project project = db.Projects.Find(id);

            if (project == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BankId       = new SelectList(CombosHelper.GetBanks(), "BankId", "Name", project.BankId);
            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(project.DepartmentId), "CityId", "Name", project.CityId);
            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", project.DepartmentId);
            return(View(project));
        }
예제 #3
0
        public ActionResult Create(Project project)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError(string.Empty, response.Message);
            }

            ViewBag.BankId       = new SelectList(CombosHelper.GetBanks(), "BankId", "Name", project.BankId);
            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(project.DepartmentId), "CityId", "Name", project.CityId);
            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", project.DepartmentId);
            return(View(project));
        }
예제 #4
0
        public ActionResult Index(string account, string personCharge, string bank, string providerFlag, string sortOrder, string startDate, string endDate,
                                  int?projectId, int?page = null)
        {
            ViewBag.BankId               = new SelectList(CombosHelper.GetBanks(), "BankId", "Name");
            ViewBag.ProjectId            = new SelectList(CombosHelper.GetProjects(), "ProjectId", "Name");
            ViewBag.ProjectSelectedId    = projectId;
            ViewBag.PersonChargeSelected = personCharge;
            ViewBag.AccountSelected      = account;
            ViewBag.BankSelected         = bank;
            ViewBag.ProviderSelectedFlag = providerFlag;
            ViewBag.StartDate            = startDate;
            ViewBag.EndDate              = endDate;

            if (Convert.ToInt32(projectId) == 0)
            {
                projectId = null;
            }
            if (Convert.ToBoolean(providerFlag) == false)
            {
                providerFlag = null;
            }

            var providerParameter = Convert.ToBoolean(providerFlag);
            var dtStartDate       = DateTime.MinValue;
            var dtEndDate         = DateTime.MinValue;

            startDate = startDate != null?startDate.ToString() : "";

            endDate = endDate != null?endDate.ToString() : "";

            if (startDate != string.Empty)
            {
                startDate   = startDate + " 00:00:00";
                dtStartDate = Convert.ToDateTime(startDate);
            }
            else
            {
                startDate = null;
            }

            if (endDate != string.Empty)
            {
                endDate   = endDate + " 23:59:00";
                dtEndDate = Convert.ToDateTime(endDate);
            }
            else
            {
                endDate = null;
            }

            page = (page ?? 1);
            var payments = db.Payments.Include(l => l.Project);

            payments = db.Payments.Where(c => (c.Account.Contains(account) || account == null) &&
                                         (c.PersonCharge.Contains(personCharge) || personCharge == null) &&
                                         (c.Bank.Contains(bank) || bank == null) &&
                                         (c.ProjectId == projectId || projectId == null) &&
                                         (c.ProviderFlag.Equals(providerParameter) || providerFlag == null) &&
                                         (c.CreationDate >= dtStartDate || startDate == null) &&
                                         (c.CreationDate <= dtEndDate || endDate == null)
                                         );

            ViewBag.RecordCount = payments.ToList().Count;

            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "PersonCharge" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";
            switch (sortOrder)
            {
            case "account":
                payments = payments.OrderByDescending(s => s.Account);
                break;

            case "Date":
                payments = payments.OrderBy(s => s.CreationDate);
                break;

            case "date_desc":
                payments = payments.OrderByDescending(s => s.CreationDate);
                break;

            default:
                payments = payments.OrderBy(s => s.PersonCharge);
                break;
            }

            return(View(payments.ToPagedList((int)page, 10)));
        }