コード例 #1
0
ファイル: Form1.cs プロジェクト: nalexi/HBClass
        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.carrosTableAdapter1.DeleteQuery(carSelect.Id);
                break;

            case 1: {
                FrmEdicaoCarros editCarros = new FrmEdicaoCarros();
                editCarros.CarrosRow = carSelect;
                editCarros.ShowDialog();

                //this.carrosTableAdapter1.Update(editCarros.CarrosRow);

                this.carrosTableAdapter1.UpdateQuery(
                    editCarros.CarrosRow.Modelo,
                    editCarros.CarrosRow.Ano.ToString(),
                    editCarros.CarrosRow.Marca,
                    editCarros.CarrosRow.UsuAlt,
                    DateTime.Now,
                    editCarros.CarrosRow.Id
                    );
            } break;
            }
            this.carrosTableAdapter1.CustomQuery(querysInnerJoinDataSet1.Carros);
        }
コード例 #2
0
        private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //var carSelect =
            // ((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 DataGridView.QuerysInnerJoinDataSet1.CarrosRow;

            //MessageBox.Show(carSelect.Ano.ToString());
            switch (e.ColumnIndex)
            {
            //COLUNA DELETAR
            case 0:
            {
                this.carrosTableAdapter.DeleteQuery(carSelect.Id);
                //this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet1.Carros);
            } break;

            case 1: {
                FrmEdicaoCarros editCarro = new FrmEdicaoCarros();
                editCarro.CarrosRow = carSelect;
                editCarro.ShowDialog();

                //COM ESSE EXEMPLO NAO PRECISA CRIAR QUERY
                //this.carrosTableAdapter.Update(editCar.CarrosRow);

                this.carrosTableAdapter.UpdateQuery(
                    editCarro.CarrosRow.Modelo,
                    editCarro.CarrosRow.Ano.ToString(),
                    editCarro.CarrosRow.Marca,
                    editCarro.CarrosRow.UsuAlt,
                    DateTime.Now,
                    editCarro.CarrosRow.Id);
            } break;
            }

            //  this.carrosTableAdapter.DeleteQuery(carSelect.Id);
            this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet1.Carros);     //PARA MOSTRAR ATUALIZADA
        }
コード例 #3
0
        private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var carSelect = ((System.Data.DataRowView)
                             this.dataGridView1.Rows[e.RowIndex].DataBoundItem).Row
                            as DataGridViewExample.QuerysInnerJoinDataSet2.CarrosRow;

            switch (e.ColumnIndex)
            {   //Coluna Deletar
            case 0:
            {
                this.carrosTableAdapter.DeleteQuery(carSelect.Id);
            }
            break;

            case 1:
            {
                FrmEdicaoCarros editCarros = new FrmEdicaoCarros();
                editCarros.CarrosRow = carSelect;
                editCarros.ShowDialog();

                //Forma 1 de atualizar (Atualiza todas as querys, mesmo que se altere apenas um campo)
                this.carrosTableAdapter.Update(editCarros.CarrosRow);

                //Forma 2 de atualizar os dados ( Forma correta, fazendo uma Query)

                /*this.carrosTableAdapter.UpdateQuery(
                 *  editCarros.CarrosRow.Modelo,
                 *  editCarros.CarrosRow.Ano.ToString(),
                 *  editCarros.CarrosRow.Marca,
                 *  editCarros.CarrosRow.UsuInc,
                 *  DateTime.Now,
                 *  editCarros.CarrosRow.Id);*/
            }
            break;
            }

            this.carrosTableAdapter.CustomQuery(querysInnerJoinDataSet2.Carros);
        }