private void btnAgregarGasto_Click(object sender, EventArgs e) { string error = ""; MontoEntities montoEntity = new MontoEntities(TipoMonto.Gasto); Utiles.AccionEnum.TipoAccion tipoAccion = Utiles.AccionEnum.TipoAccion.Add; montoEntity.Descripcion = txtDescripcionGasto.Text; montoEntity.Monto = txtGasto.Text; montoEntity.Tipo = ddlTipo.SelectedItem.ToString(); montoEntity.ID_Cliente = ddlClientes.SelectedValue.ToString(); error = Utiles.Validaciones.ValidarCampos(montoEntity.Descripcion, montoEntity.Monto); if (error == "") { IngLogic.Save(montoEntity, tipoAccion); txtDescripcionGasto.Clear(); txtGasto.Clear(); ListarGastos(Mes_Actual); } else { MessageBox.Show(error, "Campos incompletos", MessageBoxButtons.OK); } }
private void btnAgregarIngreso_Click(object sender, EventArgs e) { string error = ""; MontoEntities montoEntity = new MontoEntities(TipoMonto.Ingreso); Utiles.AccionEnum.TipoAccion tipoAccion = Utiles.AccionEnum.TipoAccion.Add; montoEntity.Descripcion = Utiles.FirstToUpper.ToUpper(txtDescripcionIngreso.Text); montoEntity.Monto = txtIngreso.Text; montoEntity.Tipo = ddlTipo.SelectedItem.ToString(); montoEntity.ID_Cliente = ddlClientes.SelectedValue.ToString(); error = Utiles.Validaciones.ValidarCampos(montoEntity.Descripcion, montoEntity.Monto); if (this.ddlTipo.SelectedItem.ToString() == "Agregar nuevo...") { error += "Seleccione otro Tipo"; } if (error == "") { IngLogic.Save(montoEntity, tipoAccion); txtDescripcionIngreso.Clear(); txtIngreso.Clear(); ListarIngresos(DateTime.Now.Month); } else { MessageBox.Show(error, "Campos incompletos", MessageBoxButtons.OK); } }
private void btnBorrar_Click(object sender, EventArgs e) { string desc = ddlTipos.SelectedItem.ToString(); IngLogic.BorrarTipo(desc); this.Close(); }
private void ListarIngresos(int oMes) { this.ddlTipo.DataSource = IngLogic.GetTipos(true); ddlClientes.DataSource = IngLogic.GetClientes(); ddlClientes.DisplayMember = "Nombre_Apellido"; ddlClientes.ValueMember = "ID"; dgvIngresos.DataSource = IngLogic.GetIngresos(oMes.ToString()); }
private void ddlTipo_SelectedIndexChanged(object sender, EventArgs e) { if (ddlTipo.SelectedItem.ToString() == "Agregar nuevo...") { AgregarTipo agTipo = new AgregarTipo(); agTipo.ShowDialog(); this.ddlTipo.DataSource = IngLogic.GetTipos(true); } if (ddlTipo.SelectedItem.ToString() == "Borrar existente...") { BorrarTipo borrarTipo = new BorrarTipo(); borrarTipo.ShowDialog(); this.ddlTipo.DataSource = IngLogic.GetTipos(true); } }
private void btnAgregar_Click(object sender, EventArgs e) { string error = Validaciones.ValidarTipo(this.txtDescripcion.Text); error += IngLogic.ExisteTipo(txtDescripcion.Text); if (error == "") { string desc = Utiles.FirstToUpper.ToUpper(txtDescripcion.Text); IngLogic.NuevoTipo(desc); this.txtDescripcion.Clear(); this.Close(); } else { MessageBox.Show(error, "Error al ingresar nuevo tipo", MessageBoxButtons.OK); } }
private void btnChange_Click(object sender, EventArgs e) { string error = ""; MontoEntities.Descripcion = txtChangeDescripcion.Text; MontoEntities.Monto = txtChangeMonto.Text; MontoEntities.Tipo = ddlTipo.SelectedItem.ToString(); error = Utiles.Validaciones.ValidarCampos(MontoEntities.Descripcion, MontoEntities.Monto); if (error == "") { IngLogic.Save(MontoEntities, Utiles.AccionEnum.TipoAccion.Modify); this.Close(); } else { MessageBox.Show(error, "Campos incompletos", MessageBoxButtons.OK); } }
public CalcularTotal() { InitializeComponent(); List <string> listTipos = IngLogic.GetTipos(false); List <string> listMeses = Calendario.GetMeses(); List <string> listAños = Calendario.GetAños(); listTipos.Add("Todo"); listMeses.Add("Todo"); listAños.Add("Todo"); this.ddlTipos.DataSource = listTipos; this.ddlAños.DataSource = listAños; this.ddlMeses.DataSource = listMeses; //pongo como seleccionado el mes actual int month = DateTime.Today.Month; ddlMeses.SelectedIndex = month - 1; }
public CambiarDatos(MontoEntities montoEntity) : this() { MontoEntities = montoEntity; switch (montoEntity.TipoMonto) { case TipoMonto.Ingreso: this.lblTitleChange.Text = "Editar Ingreso"; break; case TipoMonto.Gasto: this.lblTitleChange.Text = "Editar Gasto"; break; } this.txtChangeDescripcion.Text = montoEntity.Descripcion; this.txtChangeMonto.Text = montoEntity.Monto; this.ddlTipo.DataSource = IngLogic.GetTipos(false); /* * it's necessary because it may happen a "tipo" item be deleted.. * then if you want to edit some register which has that "tipo" * it will cause an error because it'll try to select its "tipo" in the combobox */ foreach (var s in ddlTipo.Items) { if (s.ToString() == montoEntity.Tipo) { this.ddlTipo.SelectedItem = montoEntity.Tipo; break; } /*it's not necessary an "else" statement because ddlTipo.DataSource = ... * already completes the combobox's list and will select the first item in * the list */ } }
private void btnBorrarIngreso_Click(object sender, EventArgs e) { MontoEntities montoEntity = new MontoEntities(TipoMonto.Ingreso); if (dgvIngresos.SelectedRows.Count > 0) { montoEntity.ID = int.Parse(dgvIngresos.SelectedCells[0].Value.ToString()); } DialogResult dr = MessageBox.Show("¿Estás seguro de borrar este registro? No podrá deshacerlo luego", "¿Estás seguro?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); switch (dr) { case DialogResult.Yes: IngLogic.Save(montoEntity, Utiles.AccionEnum.TipoAccion.Delete); ListarIngresos(DateTime.Now.Month); break; case DialogResult.Cancel: break; } }
private void btnTotal_Click(object sender, EventArgs e) { int month = 0; string selectedValueMeses = ddlMeses.SelectedItem.ToString(); string selectedValueAños = ddlAños.SelectedValue.ToString(); string tipo = ddlTipos.SelectedItem.ToString(); switch (selectedValueMeses) { case "Todo": month = 0; break; case "Enero": month = 01; break; case "Febrero": month = 02; break; case "Marzo": month = 03; break; case "Abril": month = 04; break; case "Mayo": month = 05; break; case "Junio": month = 06; break; case "Julio": month = 07; break; case "Agosto": month = 08; break; case "Septiembre": month = 09; break; case "Octubre": month = 10; break; case "Noviembre": month = 11; break; case "Diciembre": month = 12; break; default: month = 0; break; } int result = IngLogic.CalcularTotalMonto(month, selectedValueAños, ddlTipos.SelectedItem.ToString(), Path); this.txtTotal.Text = "$" + result.ToString(); }
public BorrarTipo() { InitializeComponent(); this.ddlTipos.DataSource = IngLogic.GetTipos(false); }