Exemple #1
0
        private void BtnAlterar_Click(object sender, EventArgs e)
        {
            Gasto     objGasto;
            GastoCtrl objGastoCtrl;

            try
            {
                objGasto     = new Gasto();
                objGastoCtrl = new GastoCtrl();

                int    linha       = this.dgvGastos.SelectedCells[0].RowIndex;
                string codigo      = this.dgvGastos.Rows[linha].Cells[0].Value.ToString();
                string descricao   = this.dgvGastos.Rows[linha].Cells[1].Value.ToString();
                string tipo        = this.dgvGastos.Rows[linha].Cells[2].Value.ToString();
                string valor       = this.dgvGastos.Rows[linha].Cells[3].Value.ToString();
                string data        = this.dgvGastos.Rows[linha].Cells[4].Value.ToString();
                string codigoObra  = this.dgvGastos.Rows[linha].Cells[5].Value.ToString();
                string codigoEtapa = this.dgvGastos.Rows[linha].Cells[6].Value.ToString();

                objGasto.setDescricao(descricao);
                objGasto.setTipo(tipo);
                objGasto.setValor(valor);
                objGasto.setData(data);
                objGasto.setObraCodigo(codigoObra);
                objGasto.setEtapaCodigo(codigoEtapa);
                objGasto.setCodigo(codigo);
                if (MessageBox.Show("Deseja Confirmar a Alteração?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    bool mensagem = objGastoCtrl.alterar(objGasto);
                    if (mensagem)
                    {
                        MessageBox.Show("Gasto Atualizado com Sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                        MessageBoxDefaultButton.Button1);
                    }
                    carregaGrid();
                }
                else
                {
                    carregaGrid();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }