public void ListenAction()
        {
            //////////////////////////////////////////////////////////////////////////////
            ///главное окно///////////////////////////////////////////////////////////////
            mainWindowView.CreateOrder += () =>
            {
                orderParametersView.SaveOrderAction += SaveNewOrder;
                int countOfOrder  = ordersModel.GetOrdersCount();  //получили количество заказов
                int currentNumber = countOfOrder++;                //создали новый номер
                currentOrder.Id = currentNumber;                   //присвоили номер новому заказу
                orderParametersView.SetDefaultValues();            //установка значений по умолчанию в полях формы
                orderParametersView.SetOrderNumber(currentNumber); //передали номер в форму заказа
                orderParametersView.ShowDialog();                  //вызвали форму нового заказа
                orderParametersView.SaveOrderAction -= SaveNewOrder;
            };

            mainWindowView.ShowWorkers += () =>
            {
                workersView.ShowDialog();
            };

            mainWindowView.ShowClients += () =>
            {
                clientController.ClientsView.ShowDialog();
                //clientsView.ShowDialog();
            };

            mainWindowView.EditeOrders += () =>
            {
                ordersView.RefreshList(ordersModel.GetAll());
                ordersView.ShowDialog();
            };



            /////////////////////////////////////////////////////////////////////////////////////////
            ///новый заказ//////////////////////////////////////////////////////////////

            ///выбор клиента
            orderParametersView.SelectClientAction += () =>
            {
                clientController.ClientsView.SelectClient += SelectClient; //подписываемся на событие только если выбор клиента происходит для добавления в зaказ
                clientController.ClientsView.ShowDialog();
                clientController.ClientsView.SelectClient -= SelectClient; //отписываемся
            };

            orderParametersView.SelectRemonterAction += () =>
            {
                workersView.SelectWorker += SelectWorker;
                workersView.ShowDialog();
                workersView.SelectWorker -= SelectWorker;
            };



            ////////////////////////////////////////////////////////////////////////////////////////////////////
            ///заказов///////
            ordersView.ModifyOrder += (id) =>
            {
                orderParametersView.SaveOrderAction += SaveExistingOrder;
                Order or = ordersModel.GetOrderById(id);
                orderParametersView.ShowView(or);
                orderParametersView.SaveOrderAction -= SaveExistingOrder;
                ordersView.RefreshList(ordersModel.GetAll());
            };


            ////////////////////////////////////////////////////////////////////////////////////////////////////
            ///список клиентов///////////////////////////////////////////////////////////////////////////////////



            ////создать
            //clientsView.CreateClient += () =>
            //{
            //    clientParametersView.SaveClientAction += SaveNewClient;
            //    clientParametersView.ShowDialog();
            //    clientParametersView.SaveClientAction -= SaveNewClient;
            //};

            /////удалить
            //clientsView.DeleteClient += (id) =>
            //{
            //    clientsModel.RemoveClient(id);
            //    SaveClientsModel();
            //    clientsView.RefreshList(clientsModel.GetAll());
            //};

            ////изменить клиенta
            //clientsView.ModifyClient += (id) =>
            //{
            //    clientParametersView.SaveClientAction += SaveExistingClient;
            //    Client cl = clientsModel.GetClientById(id);
            //    clientParametersView.ShowView(cl);
            //    clientParametersView.SaveClientAction -= SaveExistingClient;
            //};



            ///////////////////////////////////////////////////////////////////////////////////////
            ///список сотрудников//////////////////////////////////////////////////////////////////

            //создать
            workersView.CreateWorker += () =>
            {
                workerParametersView.SaveWorker += SaveNewWorker;
                workerParametersView.ShowDialog();
                workerParametersView.SaveWorker -= SaveNewWorker;
            };


            ///удалить
            workersView.DeleteWorker += (id) =>
            {
                workersModel.RemoveWorker(id);
                SaveworkersModel();
                workersView.RefreshList(workersModel.GetAll());
            };


            //изменить
            workersView.ModifyWorker += (id) =>
            {
                workerParametersView.SaveWorker += SaveExistingWorker;
                Worker w = workersModel.GetWorkerById(id);
                workerParametersView.ShowView(w);
                workerParametersView.SaveWorker -= SaveExistingWorker;
            };
        }
Beispiel #2
0
        public void ShowCountOfOrders()
        {
            int count = oModel.GetOrdersCount();

            textBoxCountOfOrders.Text = count.ToString();
        }