private void CarregaMetas() { txtMEtaPercentual1.Clear(); txtmetaValor1.Clear(); double MetaValor = 0; double MetaPercentual = 0; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DataTable tabela = bll.LocalizarGrupoPorId(Convert.ToInt32(cbGrupos.SelectedValue.ToString())); try { MetaValor = Convert.ToDouble(tabela.Rows[0][2].ToString()); } catch {} txtmetaValor1.Text = MetaValor.ToString("#,0.00"); try { MetaPercentual = Convert.ToDouble(tabela.Rows[0][3]) * 100; } catch {} txtMEtaPercentual1.Text = MetaPercentual.ToString() + "%"; btEditar.Enabled = true; }
private void CarregaDgvContas() { try { dgvContas.Rows.Clear(); if (cbGrupos.Text != "") { String[] C = { "", "", "", "" }; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DataTable tabela = bll.LocalizarGrupoCusto(Convert.ToInt32(cbGrupos.SelectedValue.ToString())); BLLConfigCusto bllconfig = new BLLConfigCusto(cx); DataTable tabela1; for (int i = 0; i < tabela.Rows.Count; i++) { tabela1 = bllconfig.LocalizarConfigPorId(Convert.ToInt32(tabela.Rows[i][2])); C = new string[] { tabela.Rows[i][0].ToString(), tabela.Rows[i][2].ToString(), tabela1.Rows[0][1].ToString() + " - " + tabela1.Rows[0][2].ToString() }; this.dgvContas.Rows.Add(C); } } else { } } catch { } }
private void CarregaDgvAdmin() { try { dgvAdmin.Rows.Clear(); if (cbGrupos.Text != "") { String[] C = { "", "" }; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); //Lista todas as receitas do grupo selecionado DataTable tabela = bll.LocalizarGrupoReceita(Convert.ToInt32(cbGrupos.SelectedValue.ToString())); BLLConfigReceita bllconfig = new BLLConfigReceita(cx); DataTable tabela1; for (int i = 0; i < tabela.Rows.Count; i++) { //descreve receita por id tabela1 = bllconfig.LocalizarConfigReceitaPorCodEUnidade(Convert.ToInt32(tabela.Rows[i][1]), Convert.ToInt32(cbUnidade.Text)); C = new string[] { tabela.Rows[i][1].ToString(), tabela.Rows[i][0].ToString(), Convert.ToInt32(tabela1.Rows[0][1]).ToString("00") + " - " + tabela1.Rows[0][2].ToString() }; this.dgvAdmin.Rows.Add(C); } } } catch { } }
private void btExcluirGrupo_Click(object sender, EventArgs e) { DialogResult d = MessageBox.Show("ATENÇÃO! Ao excluir este grupo todos os itens contidos nele serão deletados. Continuar?", "Aviso", MessageBoxButtons.YesNo); if (d.ToString() == "Yes") { if (cbGrupos.SelectedValue.ToString() != "-1" && cbGrupos.SelectedValue.ToString() != "") { liberado = false; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); bll.ExcluirGrupo(Convert.ToInt32(cbGrupos.SelectedValue.ToString())); carregaGrupo(); CarregaDgvAdmin(); CarregaDgvContas(); liberado = true; } else { liberado = false; cbGrupos.Text = ""; liberado = true; } btExcluirGrupo.Enabled = false; } }
private void btAddAdmin_Click(object sender, EventArgs e) { if (cbGrupos.SelectedValue.ToString() == "-1") { MessageBox.Show("Por favor escolha um grupo válido."); cbGrupoAdmin.Text = ""; cbGrupos.Focus(); } else if (cbGrupoAdmin.Text == "") { MessageBox.Show("selecione uma conta do cbGrupoAdmin para continuar"); } else if (cbGrupos.SelectedValue.ToString() != "-1") { bool repetido = false; for (int i = 0; i < dgvAdmin.Rows.Count; i++) { if (Convert.ToInt32(cbGrupoAdmin.SelectedValue) == Convert.ToInt32(dgvAdmin.Rows[i].Cells[0].Value)) { repetido = true; } } if (repetido) { MessageBox.Show("Já existe cadastro para este códido do Admin neste grupo.", "AVISO!"); } else { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DTOCmvGrupo dto = new DTOCmvGrupo() { idCmvGrupo = Convert.ToInt32(cbGrupos.SelectedValue), CodReceita = Convert.ToInt32(cbGrupoAdmin.SelectedValue), idUnidade = unidade }; bll.IncluirGrupoReceita(dto); cbGrupoAdmin.Text = ""; CarregaDgvAdmin(); } } else { MessageBox.Show("Por favor escolha um grupo válido."); cbGrupoAdmin.Text = ""; cbGrupos.Focus(); } }
private void btAddConta_Click(object sender, EventArgs e) { if (cbGrupos.SelectedValue.ToString() == "-1") { MessageBox.Show("Por favor escolha um grupo válido."); cbConta.Text = ""; cbGrupos.Focus(); } else if (cbConta.Text != "") { bool repetido = false; if (dgvContas.Rows.Count > 0) { for (int i = 0; i < dgvContas.Rows.Count; i++) { if (Convert.ToInt32(cbConta.SelectedValue.ToString()) == Convert.ToInt32(dgvContas.Rows[i].Cells[1].Value)) { repetido = true; } } } if (repetido) { MessageBox.Show("Já existe cadastro para esta conta gerencial neste grupo.", "AVISO!"); } else { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DTOCmvGrupo dto = new DTOCmvGrupo(); dto.idCmvGrupo = Convert.ToInt32(cbGrupos.SelectedValue); dto.IdConfigCusto = Convert.ToInt32(cbConta.SelectedValue); bll.IncluirGrupoCusto(dto); cbConta.Text = ""; CarregaDgvContas(); } } else { MessageBox.Show("Por favor escolha um grupo válido."); cbConta.Text = ""; cbGrupos.Focus(); } }
private void btSalvar_Click(object sender, EventArgs e) { double metaValor = 0; double metaPercentual = 0; if (txtmetaValor1.Text != "") { metaValor = Convert.ToDouble(txtmetaValor1.Text); } if (txtMEtaPercentual1.Text != "") { metaPercentual = Convert.ToDouble(txtMEtaPercentual1.Text.Replace("%", "")) / 100; } DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DTOCmvGrupo dto = new DTOCmvGrupo(); dto.cmvGrupoMetaValor = metaValor; dto.cmvGrupoMetaPercentual = metaPercentual; dto.idCmvGrupo = Convert.ToInt32(cbGrupos.SelectedValue.ToString());; dto.cmvGrupoNome = txtNome.Text; bll.Alterar(dto); txtMEtaPercentual1.Enabled = false; txtmetaValor1.Enabled = false; btSalvar.Enabled = false; btEditar.Enabled = true; gbConta.Enabled = true; gbAdmin.Enabled = true; txtNome.Clear(); txtNome.Visible = false; cbGrupos.Visible = true; cbConta.Enabled = true; cbGrupoAdmin.Enabled = true; btAddAdmin.Enabled = true; btAddConta.Enabled = true; dgvAdmin.Enabled = true; dgvContas.Enabled = true; carregaGrupo(); cbGrupos.Text = dto.cmvGrupoNome; }
private void carregaGrupo() { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DataTable tabela = bll.LocalizarGrupo(unidade); var dataSource = new List <Language>(); dataSource.Add(new Language() { Name = "", Value = "" }); for (int i = 0; i < tabela.Rows.Count; i++) { dataSource.Add(new Language() { Name = tabela.Rows[i][1].ToString(), Value = Convert.ToInt32(tabela.Rows[i][0]).ToString() }); } dataSource.Add(new Language() { Name = "**Adicionar Grupo**", Value = "-1" }); //Setup data binding this.cbGrupos.DataSource = dataSource; this.cbGrupos.DisplayMember = "Name"; this.cbGrupos.ValueMember = "Value"; this.cbGrupos.Text = ""; dgvAdmin.Rows.Clear(); dgvContas.Rows.Clear(); txtMEtaPercentual1.Clear(); txtmetaValor1.Clear(); cbGrupoAdmin.Text = ""; cbConta.Text = ""; }
private void dgvAdmin_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3) { if (e.RowIndex >= 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLConfigCusto bll = new BLLConfigCusto(cx); DataTable tabela = bll.LocalizarConfigPorId(Convert.ToInt32(dgvAdmin.Rows[e.RowIndex].Cells[0].Value)); cbGrupoAdmin.Text = dgvAdmin.Rows[e.RowIndex].Cells[2].Value.ToString(); BLLCmvGrupo bllg = new BLLCmvGrupo(cx); bllg.ExcluirGrupoReceita(Convert.ToInt32(dgvAdmin.Rows[e.RowIndex].Cells[1].Value)); CarregaDgvAdmin(); } } }
private void btAdicionarGrupo_Click(object sender, EventArgs e) { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bll = new BLLCmvGrupo(cx); DTOCmvGrupo dto = new DTOCmvGrupo(); dto.cmvGrupoNome = txtNomeGrupo.Text; dto.idUnidade = unidade; double metaPercapta = 0; if (txtMetaValor.Text != "") { metaPercapta = Math.Round(Convert.ToDouble(txtMetaValor.Text), 2); } double metaPercentual = 0; if (txtMetaPercent.Text != "") { metaPercentual = Math.Round((Convert.ToDouble(txtMetaPercent.Text.Replace("%", "")) / 100), 4); } dto.cmvGrupoMetaPercentual = metaPercentual; dto.cmvGrupoMetaValor = metaPercapta; txtMetaValor.Clear(); txtMetaPercent.Clear(); bll.IncluirGrupo(dto); txtNomeGrupo.Clear(); pnCadastroGrupo.Visible = false; liberado = false; carregaGrupo(); liberado = true; cbGrupos.Text = dto.cmvGrupoNome; }
private void CarregaCbGrupos() { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLCmvGrupo bllg = new BLLCmvGrupo(cx); DataTable tabela = bllg.LocalizarGrupo(unidade); var dataSource1 = new List <Language>(); dataSource1.Add(new Language() { Name1 = "", Value1 = "0" }); for (int i = 0; i < tabela.Rows.Count; i++) { dataSource1.Add(new Language() { Name1 = tabela.Rows[i][1].ToString(), Value1 = Convert.ToInt32(tabela.Rows[i][0]).ToString() }); } var dataSource2 = new List <Language>(); dataSource2.Add(new Language() { Name2 = "", Value2 = "0" }); for (int i = 0; i < tabela.Rows.Count; i++) { dataSource2.Add(new Language() { Name2 = tabela.Rows[i][1].ToString(), Value2 = Convert.ToInt32(tabela.Rows[i][0]).ToString() }); } var dataSource4 = new List <Language>(); dataSource4.Add(new Language() { Name4 = "", Value4 = "0" }); for (int i = 0; i < tabela.Rows.Count; i++) { dataSource4.Add(new Language() { Name4 = tabela.Rows[i][1].ToString(), Value4 = Convert.ToInt32(tabela.Rows[i][0]).ToString() }); } var dataSource5 = new List <Language>(); dataSource5.Add(new Language() { Name5 = "", Value5 = "0" }); for (int i = 0; i < tabela.Rows.Count; i++) { dataSource5.Add(new Language() { Name5 = tabela.Rows[i][1].ToString(), Value5 = Convert.ToInt32(tabela.Rows[i][0]).ToString() }); } liberado = false; //Atualiza grupo 01 this.cbComparativo01.DataSource = dataSource1; this.cbComparativo01.DisplayMember = "Name1"; this.cbComparativo01.ValueMember = "Value1"; //Atualiza grupo 02 this.cbComparativo02.DataSource = dataSource2; this.cbComparativo02.DisplayMember = "Name2"; this.cbComparativo02.ValueMember = "Value2"; }