Exemple #1
0
        public void Add_post()
        {
            var departure = new Departure
            {
                DepartureId = 4
            };

            var controller = new DepartureController(
                new DepartureBLL(new DepartureRepositoryStab()),
                new LineBLL(new LineRepositoryStab())
                );

            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var actionResult = (RedirectToRouteResult)controller.Add(departure, 4);

            Assert.IsNotNull(actionResult, "Not a redirect result");
            Assert.IsFalse(actionResult.Permanent);
            Assert.AreEqual("Index", actionResult.RouteValues["Action"]);
            Assert.AreEqual(2, actionResult.RouteValues.Count());
        }
Exemple #2
0
        private void editDepartureButton_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow = departuresDataGridView.SelectedRows[0];
            int             departureId = (int)selectedRow.Cells["departureidDataGridViewTextBoxColumn"].Value;

            DataRow[] rows = departuresDataTable.Select(String.Format("departure_id = {0}", departureId));

            int maxDepartureId = dataController.GetMaxId(departuresDataTable, "departure_id");
            int maxCrewId      = dataController.GetMaxId(crewsDataTable, "crew_id");
            int maxContractId  = dataController.GetMaxId(contractsDataTable, "contract_id");

            DepartureForm departureForm = new DepartureForm(rows[0], true, maxDepartureId, maxCrewId, maxContractId);

            if (departureForm.ShowDialog() == DialogResult.OK)
            {
                DepartureController departureController = new DepartureController(departureForm.Row);
                int result = departureController.Update();

                if (result == 0)
                {
                    MessageBox.Show("Ошибка выполнения редактирования");
                }

                FillTables();
                ShowRowsCountEverywhere();
            }
        }
Exemple #3
0
        private void SelectDepartures()
        {
            DateTime startDate  = startDepartureDateTimePicker.Value;
            DateTime finishDate = finishDepartureDateTimePicker.Value;

            DataTable dataTable = DepartureController.SelectDepartures(startDate, finishDate);

            departuresDataGridView.DataSource = dataTable;
            ShowRowsCount(departuresDataGridView, departuresCountLabel);
        }
Exemple #4
0
        private void addDepartureButton_Click(object sender, EventArgs e)
        {
            int maxDepartureId = dataController.GetMaxId(departuresDataTable, "departure_id");
            int maxCrewId      = dataController.GetMaxId(crewsDataTable, "crew_id");
            int maxContractId  = dataController.GetMaxId(contractsDataTable, "contract_id");

            DepartureForm departureForm = new DepartureForm(departuresDataTable.NewRow(), false, maxDepartureId, maxCrewId, maxContractId);

            if (departureForm.ShowDialog() == DialogResult.OK)
            {
                DepartureController departureController = new DepartureController(departureForm.Row);
                int result = departureController.Insert();

                if (result == 0)
                {
                    MessageBox.Show("Ошибка выполнения вставки");
                }

                FillTables();
                ShowRowsCountEverywhere();
            }
        }
Exemple #5
0
        public void Add()
        {
            var controller = new DepartureController(
                new DepartureBLL(new DepartureRepositoryStab()),
                new LineBLL(new LineRepositoryStab())
                );

            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var actionResult = (ViewResult)controller.Add(4);
            var data         = (Departure)actionResult.Model;

            Assert.AreEqual("", actionResult.ViewName);
            Assert.IsNotNull(data);
            Assert.IsNotNull(data.Line);
        }