public JsonResult EditClient(AddEditClient clientFromView)
        {
            clientsServices.EditClient(clientFromView, out DefaultError outError);
            ResultHandler <Object> result = new ResultHandler <object>(outError.ErrorMessage);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 public void EditClient(AddEditClient clientFromView, out DefaultError outError)
 {
     if (CheckClient(clientFromView, out outError))
     {
         ClientsRepository.EditClient(SetClientData(clientFromView));
     }
 }
Exemple #3
0
 public void Add()
 {
     if (TableComboBox.Text == "Клиент")
     {
         AddEditClient addEditClient = new AddEditClient(db, datagrid, false);
         addEditClient.Show();
     }
     if (TableComboBox.Text == "Сотрудник")
     {
         AddEditEmployee addEditEmployee = new AddEditEmployee(db, datagrid, false);
         addEditEmployee.Show();
     }
     if (TableComboBox.Text == "Заказ")
     {
         AddEditOrder addEditOrder = new AddEditOrder(db, datagrid, false);
         addEditOrder.Show();
     }
     if (TableComboBox.Text == "Отель")
     {
         AddEditHotel addEditHotel = new AddEditHotel(db, datagrid, false);
         addEditHotel.Show();
     }
     if (TableComboBox.Text == "Точка остановки")
     {
         AddEditTour_point addEditTourPoint = new AddEditTour_point(db, datagrid, false);
         addEditTourPoint.Show();
     }
     if (TableComboBox.Text == "Тур")
     {
         AddEditTour addEditTour = new AddEditTour(db, datagrid, false);
         addEditTour.Show();
     }
 }
        private void addClientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddEditClient addEditClient = new AddEditClient();

            addEditClient.action = "Add";
            addEditClient.ShowDialog();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            AddEditClient addEditClient = new AddEditClient();

            AddEditClient.tempEmployeeId = Convert.ToInt32(dgvr.Cells[0].Value.ToString());
            addEditClient.action         = "Add";
            addEditClient.ShowDialog();
        }
Exemple #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddEditClient dialog = new AddEditClient();

            if (dialog.ShowForm(null) != DialogResult.Cancel)
            {
                refresh();
            }
        }
        private DbClient SetClientData(AddEditClient clientFromView)
        {
            DbClient newClient = new DbClient();

            newClient.DbClientId          = String.IsNullOrEmpty(clientFromView.ClientId) ? GeneratorId.GenerateId() : clientFromView.ClientId;
            newClient.DbClientLastName    = clientFromView.ClientLastName;
            newClient.DbClientFirstName   = clientFromView.ClientFirstName;
            newClient.DbClientMiddleName  = clientFromView.ClientMiddleName;
            newClient.DbClientBirthday    = DateTime.ParseExact(clientFromView.ClientBirthdayString, "yyyy-mm-dd", null);
            newClient.DbClientPhoneNumber = clientFromView.ClientPhoneNumber;
            newClient.DbClientEmail       = clientFromView.ClientEmail;
            return(newClient);
        }
Exemple #8
0
 public void Edit()
 {
     if (TableComboBox.Text == "Клиент")
     {
         if (datagrid.SelectedIndex >= 0 && datagrid.SelectedIndex < db.Clients.Count())
         {
             AddEditClient addEditClient = new AddEditClient(db, datagrid, true);
             addEditClient.Show();
         }
     }
     if (TableComboBox.Text == "Сотрудник")
     {
         if (datagrid.SelectedIndex >= 0 && datagrid.SelectedIndex < db.Employees.Count())
         {
             AddEditEmployee addEditEmployee = new AddEditEmployee(db, datagrid, true);
             addEditEmployee.Show();
         }
     }
     if (TableComboBox.Text == "Заказ")
     {
         if (datagrid.SelectedIndex >= 0 && datagrid.SelectedIndex < db.Orders.Count())
         {
             AddEditOrder addEditOrder = new AddEditOrder(db, datagrid, true);
             addEditOrder.Show();
         }
     }
     if (TableComboBox.Text == "Отель")
     {
         if (datagrid.SelectedIndex >= 0 && datagrid.SelectedIndex < db.Hotels.Count())
         {
             AddEditHotel addEditHotel = new AddEditHotel(db, datagrid, true);
             addEditHotel.Show();
         }
     }
     if (TableComboBox.Text == "Точка остановки")
     {
         if (datagrid.SelectedIndex >= 0 && datagrid.SelectedIndex < db.Tour_point.Count())
         {
             AddEditTour_point addEditTourPoint = new AddEditTour_point(db, datagrid, true);
             addEditTourPoint.Show();
         }
     }
     if (TableComboBox.Text == "Тур")
     {
         if (datagrid.SelectedIndex >= 0 && datagrid.SelectedIndex < db.Tours.Count())
         {
             AddEditTour AddEddSym = new AddEditTour(db, datagrid, true);
             AddEddSym.Show();
         }
     }
 }
        private bool CheckClient(AddEditClient clientFromView, out DefaultError outError)
        {
            outError = new DefaultError();
            if (!String.IsNullOrEmpty(outError.ErrorMessage = CheckClientNull(clientFromView)))
            {
                return(false);
            }

            if (!String.IsNullOrEmpty(outError.ErrorMessage = CheckClientData(clientFromView)))
            {
                return(false);
            }

            return(true);
        }
        private bool СheckUniqEmail(AddEditClient clientFromView)
        {
            if (!String.IsNullOrEmpty(clientFromView.ClientId))
            {
                if (String.Compare(clientFromView.ClientEmail, ClientsRepository.GetClientById(SetClientData(clientFromView).DbClientId).DbClientEmail) == 0)
                {
                    return(true);
                }
            }
            if (ClientsRepository.GetClientByEmail(clientFromView.ClientEmail).DbClientEmail == null)
            {
                return(true);
            }

            return(false);
        }
 private void button3_Click(object sender, EventArgs e)
 {
     if (dataGridView_ListOfClients.SelectedRows.Count > 0)
     {
         using (AddEditClient addEditClient = new AddEditClient())
         {
             addEditClient.action = "Edit";
             using (AxaContext ctx = new AxaContext())
             {
                 //int client_id = (int)dataGridView_ListOfClients.SelectedRows[0].Cells[0].Value;
                 //addEditClient.selected_client = ctx.Clients.Find(client_id);
                 //addEditClient.ShowDialog();
             }
         }
     }
 }
        private string CheckClientData(AddEditClient clientFromView)
        {
            DateTime checkDate = DateTime.ParseExact(clientFromView.ClientBirthdayString, "yyyy-mm-dd", null);

            if (String.IsNullOrEmpty(clientFromView.ClientLastName))
            {
                return("Ошибка ввода ФИО! Пустое значение Фамилии. (server)");
            }

            if (String.IsNullOrEmpty(clientFromView.ClientFirstName))
            {
                return("Ошибка ввода ФИО! Пустое значение Имени. (server)");
            }

            if (String.IsNullOrEmpty(clientFromView.ClientMiddleName))
            {
                return("Ошибка ввода ФИО! Пустое значение Отчества. (server)");
            }

            if (checkDate.CompareTo(DateTime.Today) > 0)
            {
                return("Ошибка ввода Даты рождения! Выбрана неправильная дата. (Позднее текущего дня.)(server)");
            }

            if (checkDate.CompareTo(new DateTime(1900, 01, 01)) < 0)
            {
                return("Ошибка ввода Даты рождения! Выбрана неправильная дата.(server)");
            }

            if (!CheckData.checkPhoneNumber(clientFromView.ClientPhoneNumber))
            {
                return("Ошибка ввода Номера телефона! Введите номер согласно форме +7(***)***-**-**");
            }

            if (!CheckData.checkEmail(clientFromView.ClientEmail))
            {
                return("Ошибка ввода E-mail. Неправильная форма записи (server)");
            }

            if (!СheckUniqEmail(clientFromView))
            {
                return("Ошибка ввода E-mail. Клиент с таким E-mail адресом уже существет!");
            }

            return(null);
        }
Exemple #13
0
        private void btnEditSelected_Click(object sender, EventArgs e)
        {
            AddEditClient dialog = new AddEditClient();

            DataGridViewRow row = null;

            if (dataGridClients.SelectedRows.Count > 0)
            {
                row = dataGridClients.SelectedRows[0];
                ClientEntity doc = (ClientEntity)row.DataBoundItem;
                if (dialog.ShowForm(doc) != DialogResult.Cancel)
                {
                    refresh();
                }
            }
            else
            {
                MessageBox.Show("Please select a row to edit.");
            }
        }
 private string CheckClientNull(AddEditClient clientFromView)
 {
     return(clientFromView == null ? "Ошибка данных! Пустая форма клиента." : null);
 }