private void btnAnular_Click(object sender, EventArgs e) { if (Grilla.CurrentRow == null) { MessageBox.Show("Debe seleccionar un registro", Clases.cMensaje.Mensaje()); return; } cGastosNegocio obj = new cGastosNegocio(); Int32 CodGasto = Convert.ToInt32(Grilla.CurrentRow.Cells[0].Value.ToString()); obj.BorrarGasto(CodGasto); DateTime Fecha = DateTime.Now; double Importe = fun.ToDouble(Grilla.CurrentRow.Cells[4].Value.ToString()); string Descripcion = "ANULACION " + Grilla.CurrentRow.Cells[2].Value.ToString(); //Int32 CodGasto = Convert.ToInt32 (Grilla.CurrentRow.Cells[0].Value.ToString ()); Clases.cMovimiento mov = new Clases.cMovimiento(); mov.GrabarMovimiento(Importe, Descripcion, Fecha, 1, null); MessageBox.Show("Datos grabados correctamente", Clases.cMensaje.Mensaje()); Buscar(); }
private void btnBuscar_Click(object sender, EventArgs e) { Clases.cFunciones fun = new Clases.cFunciones(); if (fun.ValidarFecha(txtFechaDesde.Text) == false) { MessageBox.Show("Fecha desde incorrecta", Clases.cMensaje.Mensaje()); return; } if (fun.ValidarFecha(txtFechaHasta.Text) == false) { MessageBox.Show("Fecha hasta incorrecta", Clases.cMensaje.Mensaje()); return; } if (Convert.ToDateTime(txtFechaDesde.Text) > Convert.ToDateTime(txtFechaHasta.Text)) { MessageBox.Show("La fecha desde debe ser inferior a la fecha hasta", Clases.cMensaje.Mensaje()); return; } DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); string Concepto = txtConcepto.Text; Clases.cMovimiento mov = new Clases.cMovimiento(); DataTable trdo = mov.GetMovimientoxFecha(FechaDesde, FechaHasta, Concepto); DataTable tResul = new DataTable(); tResul.Columns.Add("Fecha"); tResul.Columns.Add("Descripcion"); tResul.Columns.Add("Ingreso"); tResul.Columns.Add("Egreso"); double TotalIngresos = 0; double TotalEgresos = 0; for (int i = 0; i < trdo.Rows.Count; i++) { string sFecha = trdo.Rows[i]["Fecha"].ToString(); string sDescripcion = trdo.Rows[i]["Descripcion"].ToString(); double Importe = Convert.ToDouble(trdo.Rows[i]["Importe"].ToString()); DataRow r = tResul.NewRow(); r["Fecha"] = sFecha; r["Descripcion"] = sDescripcion; if (Importe > 0) { TotalIngresos = TotalIngresos + Importe; r["Ingreso"] = Importe.ToString(); r["Egreso"] = ""; } else { TotalEgresos = TotalEgresos + Importe; Importe = (-1) * Importe; r["Ingreso"] = ""; r["Egreso"] = Importe.ToString(); } tResul.Rows.Add(r); } tResul = fun.TablaaMiles(tResul, "Ingreso"); tResul = fun.TablaaMiles(tResul, "Egreso"); trdo = fun.TablaaMiles(trdo, "ImporteEfectivo"); //Grilla.DataSource = trdo; Grilla.DataSource = tResul; Grilla.Columns[1].Width = 400; Grilla.Columns[2].Width = 150; Grilla.Columns[3].Width = 150; Grilla.Columns[1].HeaderText = "Descripción"; double Total = TotalIngresos + TotalEgresos; txtTotal.Text = Total.ToString(); txtTotal.Text = fun.FormatoEnteroMiles(txtTotal.Text); }
private void btnGuardar_Click(object sender, EventArgs e) { Clases.cFunciones fun = new Clases.cFunciones(); if (fun.ValidarFecha(txtFecha.Text) == false) { Mensaje("La fecha es incorrecta"); return; } if (txtEfectivo.Text == "") { Mensaje("Debe ingresar un importe"); return; } if (cmbConcepto.SelectedIndex == 0) { if (txtDescripcion.Text == "") { Mensaje("Debe ingresar una descripción"); return; } } Int32 CodConcepto = Convert.ToInt32(cmbConcepto.SelectedValue); string Empleado = ""; if (CodConcepto == 6) { if (CmbMecanico.SelectedIndex < 1) { Mensaje("Debe seleccionar un mecánico"); return; } else { Empleado = CmbMecanico.Text; } } DateTime Fecha = Convert.ToDateTime(txtFecha.Text); double Importe = fun.ToDouble(txtEfectivo.Text); string Descripcion = txtDescripcion.Text; Int32? CodEntidad = null; string NombreEntidad = ""; if (cmbConcepto.SelectedIndex > 0) { CodEntidad = Convert.ToInt32(cmbConcepto.SelectedValue); Clases.cEntidad ent = new Clases.cEntidad(); NombreEntidad = ent.GetNombrexCodigo(Convert.ToInt32(CodEntidad)); } if (NombreEntidad != "") { Descripcion = NombreEntidad + "," + Descripcion; } if (CodEntidad == 6) { Descripcion = cmbConcepto.Text + " " + Empleado.ToString() + " " + txtDescripcion.Text; } Clases.cGastosNegocio gasto = new Clases.cGastosNegocio(); gasto.GrabarGastos(Fecha, CodEntidad, Descripcion, Importe); Clases.cMovimiento mov = new Clases.cMovimiento(); mov.GrabarMovimiento(-1 * Importe, Descripcion, Fecha, 1, null); Mensaje("Datos grabados correctamente"); txtEfectivo.Text = ""; txtFecha.Text = ""; txtDescripcion.Text = ""; if (cmbConcepto.Items.Count > 0) { cmbConcepto.SelectedIndex = 0; } }