コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }