Example #1
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (!ValidarCampos())
            {
                MessageBox.Show("Existem campos não preenchidos");
                return;
            }

            DialogResult dialogResult = MessageBox.Show("Deseja salvar?", "Salvando...", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }
            List <GastosTO> gastoListaTO = new List <GastosTO>();

            if (gastosTO != null)
            {
                PreencherValoresSalvar();
                gastoListaTO.Add(gastosTO);
            }

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

                VerificarProcessoDepoisSalvar();
            }
            catch (Exception ex)
            {
                LoggerUtil.ErrorLog(ex.Message, ex);
                MessageBox.Show("Erro ao salvar os dados.");
            }
        }
        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);
            }
        }