예제 #1
0
 private void delete_Click(object sender, EventArgs e)
 {
     try
     {
         //if (clientLogic.SelectedClient == null)
         //    throw new Exception("NIEY!!!>_< UpdateButton");
         if (dataGridView1.CurrentRow != null)
         {
             DataGridViewRow row    = dataGridView1.CurrentRow;
             ClientModel     client = new ClientModel()
             {
                 CompanyId = Int32.Parse(row.Cells["CompanyId"].Value.ToString()),
                 Id        = Int32.Parse(row.Cells["ClientId"].Value.ToString()),
                 //  PersonId = Int32.Parse(row.Cells["PersonId"].Value.ToString()),
                 Name          = row.Cells["ClientName"].Value.ToString(),
                 SurName       = row.Cells["Surname"].Value.ToString(),
                 Patronymic    = row.Cells["Patronymic"].Value.ToString(),
                 CompanyAdress = row.Cells["CompanyAdress"].Value.ToString(),
                 Phone         = row.Cells["PhoneColumn"].Value.ToString(),
                 Email         = row.Cells["Email"].Value.ToString(),
                 CompanyName   = row.Cells["CompanyName"].Value.ToString(),
             };
             clientLogic.Delete(client);
             UpdateDAtaSet();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        public void DeleteClient(int id, string Name, int InformationId)
        {
            Client user = new Client()
            {
                Id            = id,
                Name          = Name,
                InformationId = InformationId
            };

            clientLogic.Delete(user);
        }
예제 #3
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            int selectedId = (ClientGrid.SelectedItem as ClientVM).Id;
            var responce   = ClientLogic.Delete(new ClientVM
            {
                Id = selectedId,
            });

            if (responce.IsCompleted)
            {
                ClientGrid.ItemsSource = ClientLogic.List().Object;
            }
        }
예제 #4
0
 private void ButtonDel_Click(object sender, EventArgs e)
 {
     if (dataGridViewClients.SelectedRows.Count == 1)
     {
         if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int id = Convert.ToInt32(dataGridViewClients.SelectedRows[0].Cells[0].Value);
             try
             {
                 clientLogic.Delete(new ClientBindingModel {
                     Id = id
                 });
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             LoadData();
         }
     }
     ClearForms();
 }