Exemplo n.º 1
0
        public static List <EGastos> ObtenerGastos()
        {
            GastosCL       gastosCL = new GastosCL();
            DataSet        dataSet  = gastosCL.TraerGasto("");
            List <EGastos> list     = new List <EGastos>();

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                list.Add(new EGastos
                {
                    id          = Convert.ToInt32(dataRow.ItemArray[0]),
                    descripcion = Convert.ToString(dataRow.ItemArray[1]),
                    monto       = Convert.ToDouble(dataRow.ItemArray[2]),
                    fecha       = Convert.ToDateTime(dataRow.ItemArray[3])
                });
            }
            return(list);
        }
Exemplo n.º 2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtGasto.Text) || !string.IsNullOrEmpty(txtMonto.Text))
            {
                GastosCL oGastos = new GastosCL();

                oGastos.InsertarGasto(txtGasto.Text, Convert.ToDouble(txtMonto.Text), dtFecha.Value);

                if (oGastos.IsError)
                {
                    MessageBox.Show(oGastos.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Gasto ingresado con éxito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LimpiarCajas();
                }
            }
            else
            {
                MessageBox.Show("Faltan campos que llenar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }