private void dataGridViewFailures_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridViewFailures.CurrentCell.ColumnIndex.Equals(7) && e.RowIndex != -1)
            {
                var id                     = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[0].Value.ToString());
                var id_username            = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[1].Value.ToString());
                var id_type_of_failure     = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[2].Value.ToString());
                var id_city                = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[3].Value.ToString());
                var begin_of_failure       = Convert.ToDateTime(dataGridViewFailures.Rows[e.RowIndex].Cells[4].Value);
                var additional_description = dataGridViewFailures.Rows[e.RowIndex].Cells[6].Value.ToString();

                var failure = new Failure
                {
                    Id                    = id,
                    Id_Username           = id_username,
                    Id_TypeOfFailure      = id_type_of_failure,
                    Id_City               = id_city,
                    BeginOfFailure        = begin_of_failure,
                    AdditionalDescription = additional_description
                };

                EditFailure formEditFailure = new EditFailure(failure);
                formEditFailure.Show();
            }

            if (dataGridViewFailures.CurrentCell.ColumnIndex.Equals(8) && e.RowIndex != -1)
            {
                var id                     = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[0].Value.ToString());
                var id_username            = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[1].Value.ToString());
                var id_type_of_failure     = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[2].Value.ToString());
                var id_city                = Convert.ToInt32(dataGridViewFailures.Rows[e.RowIndex].Cells[3].Value.ToString());
                var begin_of_failure       = Convert.ToDateTime(dataGridViewFailures.Rows[e.RowIndex].Cells[4].Value.ToString());
                var additional_description = dataGridViewFailures.Rows[e.RowIndex].Cells[6].Value.ToString();

                var failure = new Failure
                {
                    Id                    = id,
                    Id_Username           = id_username,
                    Id_TypeOfFailure      = id_type_of_failure,
                    Id_City               = id_city,
                    BeginOfFailure        = begin_of_failure,
                    AdditionalDescription = additional_description
                };
                _failureRepository.DeleteFailure(failure);
                _tableBindingSource.DataSource  = _failureRepository.GetFailures();
                dataGridViewFailures.DataSource = _tableBindingSource;
            }
        }
Esempio n. 2
0
 public void DeleteFailure(int id)
 {
     Failurerepository.DeleteFailure(id);
 }