private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { // ((System.Windows.Forms.DataGridViewRow) // ((((System.Windows.Forms.DataGridView)sender).Rows).Items[0])).DataBoundItem var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerrysInnerJoinDataSet1.CarrosRow; switch (e.ColumnIndex) { case 0: { this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; case 1: { frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); this.carrosTableAdapter.UpdateQuery1( editCarro.CarrosRow.Modelo, editCarro.CarrosRow.Ano.ToString(), editCarro.CarrosRow.Marca, editCarro.CarrosRow.UsuAlt, DateTime.Now, editCarro.CarrosRow.Id); } break; } this.carrosTableAdapter.CustomQuerry(this.querrysInnerJoinDataSet1.Carros); }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.ParteFinalLocadoraTSQLDataSet1.CarrosRow; switch (e.ColumnIndex) { case 0: this.carrosTableAdapter.SetAtivoQuery(carSelect.Id); break; case 1: frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); this.carrosTableAdapter.Update(editCarro.CarrosRow); /*editCarro.CarrosRow.Marca, * editCarro.CarrosRow.Modelo, * editCarro.CarrosRow.Ano, * editCarro.CarrosRow.UsuAlt, * editCarro.CarrosRow.DatAlt = DateTime.Now, * editCarro.CarrosRow.Id);*/ break; } this.carrosTableAdapter.CustomQuery(this.parteFinalLocadoraTSQLDataSet1.Carros); }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var carSelect = ((System.Data.DataRowView) //foi isolado pois são objetos diferentes "( )" this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerysInnerJoinDataSet1.CarrosRow; //*DataGridViewExample = nome do namespace //Este código ta convertendo toda a linha selecionada para uma switch (e.ColumnIndex) { case 0: //Deletar { this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; case 1: //Editar { frmEdicaoCarros editCar = new frmEdicaoCarros(); editCar.CarrosRow = carSelect; //vai selecionar o carro e depois fazer a edição editCar.ShowDialog(); //se for apenas ".Show();", morre o contexto. não realiza o desejado. this.carrosTableAdapter.Update(editCar.CarrosRow); //atualiza todos os campos /*this.carrosTableAdapter.UpdateQuery1(editCar.CarrosRow.Modelo, * editCar.CarrosRow.Ano.ToString(), * editCar.CarrosRow.Marca, * editCar.CarrosRow.UsuAlt, * DateTime.Now, * editCar.CarrosRow.Id);*/ } break; } this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet1.Carros); //antes era Custon }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) // Cell content click por isso apga em qualquer coluna { var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerysInnerJoinDataSet1.CarrosRow; switch (e.ColumnIndex) { // Coluna Deletar case 0: { // DELETE this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; case 1: { frmEdicaoCarros edicaoCarros = new frmEdicaoCarros(); edicaoCarros.CarrosRow = carSelect; edicaoCarros.ShowDialog(); /* this.carrosTableAdapter.UpdateQuery1( * edicaoCarros.CarrosRow.Modelo, * edicaoCarros.CarrosRow.Ano.ToString(), * edicaoCarros.CarrosRow.Marca, * edicaoCarros.CarrosRow.UsuAlt, * DateTime.Now, * edicaoCarros.CarrosRow.Id);*/ } break; } this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet11.Carros); }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var carrosSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerysInnerJoinDataSet1.CarrosRow; switch (e.ColumnIndex) { case 0: { this.carrosTableAdapter.DeleteQuery(carrosSelect.Id); } break; // Coluna DELETAR case 1: // Coluna EDITAR { frmEdicaoCarros editarCarros = new frmEdicaoCarros(); editarCarros.CarrosRow = carrosSelect; // Atribui o resultado da pesquisa feita anteriormente ao objeto 'CarrosRow'. editarCarros.ShowDialog(); this.carrosTableAdapter.Update(editarCarros.CarrosRow); //Faz a mesma coisa que o código comentado abaixo sem precisar // de query no sql, mas é mais "custoso" para o Banco de Dados. /*this.carrosTableAdapter.UpdateQuery( * editarCarros.CarrosRow.Modelo, * editarCarros.CarrosRow.Ano.ToString(), * editarCarros.CarrosRow.Marca, * editarCarros.CarrosRow.UsuAlt, * DateTime.Now, * editarCarros.CarrosRow.Id); */ } break; } this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet1.Carros); }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { //((System.Windows.Forms.DataGridViewRow) //(((System.Windows.Forms.DataGridView)sender).Rows).Items[0])) //.DataBoundItem var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerysInnerJoinDataSet1.CarrosRow; //usamos o switch porque poderia ter outras opções, neste caso poderia até ser um if switch (e.ColumnIndex) //para escolher quais colunas vão deletar informações { //Coluna deletar case 0: { this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; case 1: { frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); //this.carrosTableAdapter.Update(editCarrro.CarrosRow); //é o mesmo que: //só que daí não precisaria criar uma querry para Update //e atualizaria todos os campos, e nós só queremos atualizar: modelo, ano e marca //portato, a forma mais correta é: this.carrosTableAdapter.UpdateQuery( editCarro.CarrosRow.Modelo, editCarro.CarrosRow.Ano.ToString(), editCarro.CarrosRow.Marca, editCarro.CarrosRow.UsuAlt, DateTime.Now, editCarro.CarrosRow.Id); } break; } //MessageBox.Show(carSelect.Modelo); //para ver se está dando certo // MessageBox.Show(carSelect.Ano.ToString()); //para ver se está dando certo this.carrosTableAdapter.CustomQuery(this.querysInnerJoinDataSet1.Carros); //para mostrar a lista atualizada }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerysInnerJoinDataSet1.CarrosRow; switch (e.ColumnIndex) { case 0: { this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; case 1: { frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); this.carrosTableAdapter.Update(editCarro.CarrosRow); } break; } this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet1.Carros); }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewDoSocorro.ParteFinalLocadoraTSQLDataSet.CarrosRow; switch (e.ColumnIndex) { case 0: { this.carrosTableAdapter.SetNaoAtivoQuery(carSelect.Id); this.carrosTableAdapter.CustomQuery(parteFinalLocadoraTSQLDataSet.Carros); } break; case 1: { frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); } break; } }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { /*((System.Windows.Forms.DataGridViewRow)(new System.Collections * .ArrayList.ArrayListDebugView(((System.Windows.Forms.DataGridView)sender) * .Rows.items).Items[0])).DataBoundItem*/ var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExample.QuerysInnerDataSet1.CarrosRow; switch (e.ColumnIndex) { case 0: { /*TODO: Deletar*/ this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; case 1: { /*TODO: Editar*/ frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); this.carrosTableAdapter.Update(editCarro.CarrosRow); /* * this.carrosTableAdapter.UpdateQuery1( * editCarro.CarrosRow.Modelo, * editCarro.CarrosRow.Ano.ToString(), * editCarro.CarrosRow.Marca, * editCarro.CarrosRow.UsuAlt, * DateTime.Now, * editCarro.CarrosRow.Id);*/ } break; } this.carrosTableAdapter.CustomQuery(this.querysInnerDataSet1.Carros); }
private void DataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { var carSelect = ((System.Data.DataRowView) this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row as DataGridViewExempleForm.QuerysInnerJoinDataSet1.CarrosRow; switch (e.ColumnIndex) { //Coluna Deletar case 0: { this.carrosTableAdapter.DeleteQuery(carSelect.Id); } break; //Editar case 1: { frmEdicaoCarros editCarro = new frmEdicaoCarros(); editCarro.CarrosRow = carSelect; editCarro.ShowDialog(); //ou this.carrosTableAdapter.Update(editCarro.CarrosRow); /* (editCarro.CarrosRow.Modelo, * editCarro.CarrosRow.Ano.ToString(), * editCarro.CarrosRow.Marca, * editCarro.CarrosRow.UsuAlt, * DateTime.Now, * editCarro.CarrosRow.Id);*/ } break; } this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet1.Carros); }