コード例 #1
0
 /*
  * Limpa a tela para uma nova inclusão
  */
 private void LimparTela()
 {
     dtpData.Value = DateTime.Now;
     txtValor.ResetText();
     txtLocal.Text             = "";
     cbxTipoGasto.SelectedItem = 1;
     gastosTO = new GastosTO();
 }
コード例 #2
0
        public void Incluir()
        {
            carregarCombos();

            gastosTO          = new GastosTO();
            gastosTO.StatusBD = StatusTransacao.Insert;
            this.ShowDialog();
        }
コード例 #3
0
        /*
         * Recebe o objeto com os dados completos dos gastos e apresenta na tela
         */
        private void PreencherValoresTela(GastosTO gastosTO)
        {
            carregarCombos();

            txtLocal.Text = gastosTO.LOCAL.Trim();
            txtValor.Text = gastosTO.VALOR.ToString();
            dtpData.Value = gastosTO.DATA;
            cbxTipoGasto.SelectedValue = gastosTO.ID_TIPO_GASTOS;
        }
コード例 #4
0
        /*
         * Alteração de gastos
         */
        public void Alterar(GastosTO objGastosTO)
        {
            GastosBLL gastoBLL = new GastosBLL();

            this.gastosTO = gastoBLL.SelectScalar(objGastosTO.ID_GASTOS);

            if (gastosTO != null)
            {
                PreencherValoresTela(gastosTO);
                gastosTO.StatusBD = StatusTransacao.Update;
            }

            this.ShowDialog();
        }
コード例 #5
0
        public void Excluir(GastosTO objGastosTO)
        {
            GastosBLL gastoBLL = new GastosBLL();

            this.gastosTO = gastoBLL.SelectScalar(objGastosTO.ID_GASTOS);

            if (gastosTO != null)
            {
                PreencherValoresTela(gastosTO);
                gastosTO.StatusBD = StatusTransacao.Delete;
            }

            DesabilitarComponentes();
            this.ShowDialog();
        }
コード例 #6
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            List <GastosTO> listaGastosSalvar = new List <GastosTO>();

            ControlarTelaSalvar();

            foreach (DataGridViewRow row in dgvGrid.Rows)
            {
                if (row == null)
                {
                    continue;
                }

                GastosTO gasto = new GastosTO();

                string local     = String.Empty;
                string valor     = String.Empty;
                string data      = String.Empty;
                string tipoGasto = String.Empty;

                local     = row.Cells["colLocal"].Value.ToString();
                valor     = row.Cells["colValor"].Value.ToString();
                data      = row.Cells["colData"].Value.ToString();
                tipoGasto = row.Cells["colTipoGasto"].Value.ToString();

                gasto.LOCAL          = local;
                gasto.VALOR          = Convert.ToDecimal(valor);
                gasto.DATA           = OutrosUtil.StringToDate(data);
                gasto.ID_TIPO_GASTOS = Convert.ToInt32(tipoGasto);
                gasto.StatusBD       = StatusTransacao.Insert;

                listaGastosSalvar.Add(gasto);
            }

            try
            {
                GastosBLL gastosBLL = new GastosBLL();
                gastosBLL.Save(listaGastosSalvar);


                MessageBox.Show("Dados Salvos com Sucesso!");
                IniciarTela();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #7
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            frmCadGasto frmCadGasto = new frmCadGasto();

            GastosTO gastosTO = new GastosTO();

            if (dgvListaGastos.CurrentRow != null)
            {
                DataGridViewRow row      = this.dgvListaGastos.SelectedRows[0];
                int             idGastos = (int)row.Cells["codlIdGastos"].Value;

                gastosTO.ID_GASTOS = idGastos;
                frmCadGasto.Excluir(gastosTO);
            }
            else
            {
                MessageBox.Show("Selecionar um item na lista :)");
            }

            BuscarDados();
        }