private void BtnRemover_Click(object sender, EventArgs e) { GastoCtrl objGastoCtrl; try { objGastoCtrl = new GastoCtrl(); int linha = this.dgvGastos.SelectedCells[0].RowIndex; int codigo = Convert.ToInt32(dgvGastos.Rows[linha].Cells[0].Value.ToString()); if (MessageBox.Show("Deseja Confirmar a Remoção?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { bool mensagem = objGastoCtrl.remover(codigo); if (mensagem) { MessageBox.Show("Gasto Removido com Sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } carregaGrid(); } else { carregaGrid(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
private void BtnCadastrar_Click(object sender, EventArgs e) { Gasto objGasto; GastoCtrl objGastoCtrl; try { objGasto = new Gasto(); objGastoCtrl = new GastoCtrl(); string descricao = this.txtDescricao.Text; string tipo = this.cmbTipo.Text; string valor = this.txtValor.Text; string data = this.txtData.Text; string codigoObra = this.obraCodigo.ToString(); string codigoEtapa = this.etapaCodigo.ToString(); objGasto.setDescricao(descricao); objGasto.setTipo(tipo); objGasto.setData(data); objGasto.setValor(valor); objGasto.setObraCodigo(codigoObra); objGasto.setEtapaCodigo(codigoEtapa); bool mensagem = objGastoCtrl.cadastrar(objGasto); if (mensagem) { MessageBox.Show("Gasto Cadastrado com Sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); limparCampos(); carregaGrid(); } else { MessageBox.Show("Gasto Não Cadastrado", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RelatorioGastosView_Load(object sender, EventArgs e) { dtpInicio.Value = new DateTime(2019, 01, 01); dtpFim.Value = new DateTime(2019, 12, 31); GastoCtrl objGastoCtrl; try { objGastoCtrl = new GastoCtrl(); this.dgvRelatorio.DataSource = objGastoCtrl.gastosObra(this.obraCodigo); this.dgvRelatorio.Columns[0].HeaderText = "Descrição"; this.dgvRelatorio.Columns[1].HeaderText = "Tipo"; this.dgvRelatorio.Columns[2].HeaderText = "Valor"; this.dgvRelatorio.Columns[3].HeaderText = "Data"; this.dgvRelatorio.DefaultCellStyle.Font = new Font("Trebuchet MS", 12); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void carregaGrid() { GastoCtrl objGastoCtrl; try { objGastoCtrl = new GastoCtrl(); this.dgvGastos.DataSource = objGastoCtrl.gastosEtapa(this.obraCodigo, this.etapaCodigo); this.dgvGastos.Columns[0].Visible = false; this.dgvGastos.Columns[1].HeaderText = "Descrição"; this.dgvGastos.Columns[2].HeaderText = "Tipo"; this.dgvGastos.Columns[3].HeaderText = "Valor"; this.dgvGastos.Columns[4].HeaderText = "Data"; this.dgvGastos.Columns[5].Visible = false; this.dgvGastos.Columns[6].Visible = false; this.dgvGastos.DefaultCellStyle.Font = new Font("Trebuchet MS", 10); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnFiltrar_Click(object sender, EventArgs e) { Gasto objGasto; GastoCtrl objGastoCtrl; try { objGasto = new Gasto(); objGastoCtrl = new GastoCtrl(); objGasto.setObraCodigo(this.obraCodigo.ToString()); this.dgvRelatorio.DataSource = objGastoCtrl.filtrar(objGasto, dtpInicio.Value, dtpFim.Value); this.dgvRelatorio.Columns[0].HeaderText = "Descrição"; this.dgvRelatorio.Columns[1].HeaderText = "Tipo"; this.dgvRelatorio.Columns[2].HeaderText = "Valor"; this.dgvRelatorio.Columns[3].HeaderText = "Data"; this.dgvRelatorio.DefaultCellStyle.Font = new Font("Trebuchet MS", 12); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnGerar_Click(object sender, EventArgs e) { GastoCtrl objGastoCtrl; DataTable tabela; try { objGastoCtrl = new GastoCtrl(); string tipo = this.cmbGrafico.Text; if (tipo == "Gastos por Etapa") { this.chGrafico.Series.Clear(); this.chGrafico.Series.Add(new Series()); this.chGrafico.Series[0].Name = "Gráfico"; this.chGrafico.Series[0].IsVisibleInLegend = false; this.chGrafico.Titles.Clear(); this.chGrafico.Titles.Add(this.cmbGrafico.Text); this.chGrafico.ChartAreas[0].AxisY.Title = "Total"; this.chGrafico.ChartAreas[0].AxisX.Interval = 1; this.chGrafico.ChartAreas[0].AxisY.Interval = 1000; this.chGrafico.Series[0].ChartType = SeriesChartType.Column; this.chGrafico.Series[0].Points.Clear(); tabela = objGastoCtrl.gastosEtapas(); for (int i = 0; i < tabela.Rows.Count; i++) { this.chGrafico.Series[0].Points.Add(new DataPoint { YValues = new double[] { (Convert.ToInt32(tabela.Rows[i][1])) }, AxisLabel = tabela.Rows[i][0].ToString() }); } } else if (tipo == "Gastos por Tipo") { this.chGrafico.Series.Clear(); this.chGrafico.Series.Add(new Series()); this.chGrafico.Series[0].Name = "Gráfico"; this.chGrafico.Series[0].IsVisibleInLegend = false; this.chGrafico.Titles.Clear(); this.chGrafico.Titles.Add(this.cmbGrafico.Text); this.chGrafico.ChartAreas[0].AxisY.Title = "Total"; this.chGrafico.ChartAreas[0].AxisX.Interval = 1; this.chGrafico.ChartAreas[0].AxisY.Interval = 1000; this.chGrafico.Series[0].ChartType = SeriesChartType.Column; this.chGrafico.Series[0].Points.Clear(); tabela = objGastoCtrl.gastosTipo(); for (int i = 0; i < tabela.Rows.Count; i++) { this.chGrafico.Series[0].Points.Add(new DataPoint { YValues = new double[] { (Convert.ToInt32(tabela.Rows[i][1])) }, AxisLabel = tabela.Rows[i][0].ToString() }); } } else if (tipo == "Gastos por Mês") { this.chGrafico.Series.Clear(); this.chGrafico.Series.Add(new Series()); this.chGrafico.Series[0].Name = "Gráfico"; this.chGrafico.Series[0].IsVisibleInLegend = false; this.chGrafico.Titles.Clear(); this.chGrafico.Titles.Add(this.cmbGrafico.Text); this.chGrafico.ChartAreas[0].AxisY.Title = "Total"; this.chGrafico.ChartAreas[0].AxisX.Interval = 1; this.chGrafico.ChartAreas[0].AxisY.Interval = 1000; this.chGrafico.Series[0].ChartType = SeriesChartType.Column; this.chGrafico.Series[0].Points.Clear(); tabela = objGastoCtrl.gastosMes(); for (int i = 0; i < tabela.Rows.Count; i++) { this.chGrafico.Series[0].Points.Add(new DataPoint { YValues = new double[] { (Convert.ToInt32(tabela.Rows[i][1])) }, AxisLabel = tabela.Rows[i][0].ToString() }); } } else if (tipo == "Gastos Estimados x Gastos Reais") { this.chGrafico.Series.Clear(); this.chGrafico.Series.Add(new Series()); this.chGrafico.Series[0].Name = "Gráfico"; this.chGrafico.Series[0].IsVisibleInLegend = false; this.chGrafico.Titles.Clear(); this.chGrafico.Titles.Add(this.cmbGrafico.Text); this.chGrafico.ChartAreas[0].AxisY.Title = "Total"; this.chGrafico.ChartAreas[0].AxisX.Interval = 1; this.chGrafico.ChartAreas[0].AxisY.Interval = 1000; this.chGrafico.Series[0].ChartType = SeriesChartType.Column; this.chGrafico.Series[0].Points.Clear(); tabela = objGastoCtrl.comparativoGastos(); for (int i = 0; i < tabela.Rows.Count; i++) { this.chGrafico.Series[0].Points.Add(new DataPoint { YValues = new double[] { (Convert.ToInt32(tabela.Rows[i][0])) }, }); } } else if (tipo == "Planejamento Estimado x Planejamento Real") { this.chGrafico.Series.Clear(); this.chGrafico.Series.Add(new Series()); this.chGrafico.Series[0].Name = "Gráfico"; this.chGrafico.Series[0].IsVisibleInLegend = false; this.chGrafico.Titles.Clear(); this.chGrafico.Titles.Add(this.cmbGrafico.Text); this.chGrafico.Series[0].ChartType = SeriesChartType.Line; this.chGrafico.Series[0].Points.Clear(); tabela = objGastoCtrl.comparativoPrazos(); for (int i = 0; i < tabela.Rows.Count; i++) { this.chGrafico.Series[0].Points.Add(new DataPoint { YValues = new double[] { (Convert.ToInt32(tabela.Rows[i][0])) }, AxisLabel = tabela.Rows[i][1].ToString() }); this.chGrafico.Series[0].Points.Add(new DataPoint { YValues = new double[] { (Convert.ToInt32(tabela.Rows[i][2])) }, AxisLabel = tabela.Rows[i][3].ToString() }); } } } catch (Exception ex) { MessageBox.Show("Erro: " + ex.Message); } }