private void OnButtonSaveClick(object sender, EventArgs e)
        {
            currentOrder.Id       = int.Parse(textBoxOrderId.Text);
            currentOrder.MyStatus = (OrderStatus)comboBoxStatus.SelectedIndex;

            if (!String.IsNullOrEmpty(textBoxClientId.Text))
            {
                currentOrder.MyClient = clientController.GetClient((int.Parse(textBoxClientId.Text)));
                //currentOrder.MyClient = clientsModel.GetClientById((int.Parse(textBoxClientId.Text)));
            }

            currentOrder.MyDevice         = new Device();
            currentOrder.MyDevice.Mark    = textBoxDeviceMark.Text;
            currentOrder.MyDevice.Model   = textBoxDeviceModel.Text;
            currentOrder.Description      = textBoxMulfunctionDescription.Text;
            currentOrder.TimeOfAcceptance = new DateTime();

            if (!String.IsNullOrEmpty(textBoxTimeOfAcceptance.Text))
            {
                currentOrder.TimeOfAcceptance = DateTime.Parse(textBoxTimeOfAcceptance.Text);
            }
            else
            {
                currentOrder.TimeOfAcceptance = DateTime.Now;
            }
            if (!String.IsNullOrEmpty(textBoxTimeOfReturn.Text))
            {
                currentOrder.TimeOfReturn = DateTime.Parse(textBoxTimeOfReturn.Text);
            }

            if (!String.IsNullOrEmpty(textBoxWorkerId.Text))
            {
                currentOrder.Repairer = workersModel.GetWorkerById((int.Parse(textBoxWorkerId.Text)));
            }
            currentOrder.RepairmansComment = textBoxComment.Text;
            if (!String.IsNullOrEmpty(textBoxCostOfRepair.Text))
            {
                currentOrder.CostOfRepair = int.Parse(textBoxCostOfRepair.Text);
            }


            if (SaveOrderAction != null)
            {
                SaveOrderAction(currentOrder);
                currentOrder = new Order();
                //так как мыпередаем объект класса как параметр события
                //мы получаем копию ссылки на него и в дальнейшем используя этот метод
                //это влечет за собой изменение не одного объекта всех ранее переданных сюда
                //чтобы этого измежать пересоздаем этот объект
                currentOrder = new Order();
            }
        }
        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;
            };
        }