private void picExcel_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; string folderName = Properties.Settings.Default.DocumentsPath + "\\Contabilidad_" + Convert.ToInt32((cbxYear.SelectedItem as Year).Desde) + "_Goll"; string fileName = (cbxYear.SelectedItem as Year).Desde + "_" + cbxMonth.SelectedItem.ToString() + ".xlsx"; Validation.FormManager frmManager = new Validation.FormManager(); if (frmManager.generateExcel(FacturaDAL.getFacturasSemanas(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id) , EgresoDAL.getEgresosSemanas(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id), folderName, fileName, Convert.ToInt32((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2019").Month)) { MessageBox.Show("La hoja de calculo ha sido generada en la carpeta \"" + Properties.Settings.Default.DocumentsPath + "\\Contabilidad_" + Convert.ToInt32((cbxYear.SelectedItem as Year).Desde) + "_Goll\"" + ".", "Operación realizada", MessageBoxButtons.OK, MessageBoxIcon.Information); Cursor = Cursors.Arrow; } } catch (Exception ex) { string folderName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Errores_" + Assembly.GetExecutingAssembly().GetName().Name + "_V_" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); string fileName = "Exeptions_" + Name + ".txt"; Validation.FormManager frmManager = new Validation.FormManager(); frmManager.writeException(folderName, fileName, ex, "El archivo de excel del mes de " + Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2019").ToString("MMMM", new CultureInfo("es-ES")) + " esta siendo usado por otro programa."); MessageBox.Show("El archivo de excel del mes de " + Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2019").ToString("MMMM", new CultureInfo("es-ES")) + " esta siendo usado por otro programa.", "Error al generar", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor = Cursors.Arrow; } }
private void icUpdate_Click(object sender, EventArgs e) { Pages = rdbMontYear.Checked ? EgresoDAL.getIdsEgresosByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : EgresoDAL.getIdsEgresosNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit); numPages = Pages.Count; SetCurrentPage(); tmrTaskDgv.Start(); }
private void btnGuardar_Click(object sender, EventArgs e) { try { if (Val_NewObject()) { if (EgresoDAL.insertEgreso(NewObject, Inicio.CurrentUser)) { MessageBox.Show("El egreso ha sido " + (EditingObject.Id == 0 ? "registrado" : "actualizado") + " exitosamente.", "Registro satisfactorio", MessageBoxButtons.OK, MessageBoxIcon.Information); EditingObject = null; this.Close(); } else { MessageBox.Show("Ocurrio un error inesperado al intentar " + (EditingObject.Id == 0 ? "registrar" : "actualizar") + " el egreso, por favor cierre el formulario y vuelva a intentarlo. Si el problema persiste contacte con el desarrollador al correo [email protected].", "Registro interrumpido", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { string folderName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Errores_" + Assembly.GetExecutingAssembly().GetName().Name + "_V_" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); string fileName = "Exeptions_" + Name + ".txt"; Validation.FormManager frmManager = new Validation.FormManager(); frmManager.writeException(folderName, fileName, ex, "Ocurrio un error inesperado al intentar registrar el egreso"); MessageBox.Show("Ocurrio un error inesperado al intentar registrar el egreso, por favor cierre el formulario y vuelva a intentarlo. Si el problema persiste contacte con el desarrollador al correo " + Properties.Settings.Default.developerEmail, "Registro interrumpido", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private List <Egreso> GetListEgresos(List <Int64> pLista) { List <Egreso> Egresos = new List <Egreso>(); if (pLista != null) { Egresos = rdbMontYear.Checked ? EgresoDAL.getEgresosIndexerParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, currentPage - 1, pLimit) : EgresoDAL.getEgresosIndexerNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, currentPage - 1, pLimit); } return(Egresos); }
private void FillDgv(List <Egreso> lista) { dgvEgresos.Rows.Clear(); foreach (Egreso obj in lista) { dgvEgresos.Rows.Add(obj.Id, Convert.ToDateTime(obj.FhRegistro).ToString("dd/MM/yyyy"), obj.Tipo, obj.Nombre, obj.Total); } CalcularGanancias(rdbMontYear.Checked ? FacturaDAL.getTotalFacturasByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : FacturaDAL.getTotalFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit), rdbMontYear.Checked ? EgresoDAL.getTotalEgresoByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : EgresoDAL.getTotalEgresoNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit)); lblPages.Text = "Página " + currentPage + " de " + (numPages == 0 ? "1" : numPages.ToString()); }
private void FrmEgreso_Load(object sender, EventArgs e) { try { if (EditingObject != null) { LstPermiso permiso = Inicio.CurrentUser.Sucursales.Where(a => a.IdSucursal == Inicio.CurrentSucursal.Id).FirstOrDefault().Permisos.Where(a => a.Permiso.Nombre == "Editar Egresos").FirstOrDefault(); btnGuardar.Enabled = !(permiso == null || permiso.Otorgado == false); List <string> EgresosName = EgresoDAL.getNameEgresos(Inicio.CurrentSucursal.Id); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); foreach (string name in EgresosName) { collection.Add(name); } txtNombre.AutoCompleteCustomSource = collection; txtNombre.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtNombre.AutoCompleteSource = AutoCompleteSource.CustomSource; txtNombre.Text = EditingObject.Nombre; txtTipo.Text = EditingObject.Tipo; txtTotal.Text = EditingObject.Total.ToString(); dtpFHRegistro.Value = Convert.ToDateTime(EditingObject.FhRegistro); lblTitulo.Text = "Editar Egreso"; } else { LstPermiso permiso = Inicio.CurrentUser.Sucursales.Where(a => a.IdSucursal == Inicio.CurrentSucursal.Id).FirstOrDefault().Permisos.Where(a => a.Permiso.Nombre == "Registrar Egresos").FirstOrDefault(); btnGuardar.Enabled = !(permiso == null || permiso.Otorgado == false); EditingObject = new Egreso(); List <string> EgresosName = EgresoDAL.getNameEgresos(Inicio.CurrentSucursal.Id); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); foreach (string name in EgresosName) { collection.Add(name); } txtNombre.AutoCompleteCustomSource = collection; txtNombre.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtNombre.AutoCompleteSource = AutoCompleteSource.CustomSource; } } catch (Exception ex) { string folderName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Errores_" + Assembly.GetExecutingAssembly().GetName().Name + "_V_" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); string fileName = "Exeptions_" + Name + ".txt"; Validation.FormManager frmManager = new Validation.FormManager(); frmManager.writeException(folderName, fileName, ex, "Ha ocurrido un error al intentar cargar la información de este control"); MessageBox.Show("Ha ocurrido un error al intentar cargar la información de este control, por favor comuniquese con el desarrollador al correo " + Properties.Settings.Default.developerEmail, "Error fatal", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dgvEgresos_DoubleClick(object sender, EventArgs e) { if (dgvEgresos.CurrentRow != null) { FrmEgreso egreso = new FrmEgreso(); egreso.EditingObject = EgresoDAL.getEgresoById((Int64)dgvEgresos.CurrentRow.Cells[0].Value); egreso.ShowDialog(); Pages = rdbMontYear.Checked ? EgresoDAL.getIdsEgresosByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : EgresoDAL.getIdsEgresosNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit); numPages = Pages.Count; SetCurrentPage(); tmrTaskDgv.Start(); } }
private void btnAnularEgreso_Click(object sender, EventArgs e) { if (dgvEgresos.CurrentRow != null) { if (MessageBox.Show("¿Esta seguro que desea anular este egreso? si lo hace, este egreso ya no aparecerá en los resgistros.", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (EgresoDAL.anularEgreso((Int64)dgvEgresos.CurrentRow.Cells[0].Value, false, Inicio.CurrentUser)) { MessageBox.Show("El egreso ha sido anulado correctamente, los calculos se reiniciarán automaticamente.", "Operación realizada", MessageBoxButtons.OK, MessageBoxIcon.Information); Pages = rdbMontYear.Checked ? EgresoDAL.getIdsEgresosByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : EgresoDAL.getIdsEgresosNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit); numPages = Pages.Count; SetCurrentPage(); tmrTaskDgv.Start(); } } } }
private void FillDgv(List <Factura> lista) { dgvIngresos.Rows.Clear(); numPages = Pages.Count; SetCurrentPage(); foreach (Factura obj in lista) { string concepto = ""; foreach (Detfactura det in obj.DetsFactura) { concepto += (det.Concepto == "Mensualidad"? "Cuota " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Convert.ToDateTime(CuotaDAL.getCuotaById(det.Matricdetfac.IdCuota).FhRegistro).ToString("MMMM")):det.Concepto) + (obj.DetsFactura.Count > 1 ? obj.DetsFactura.Last().Id == det.Id ? "." : ", " : "."); } decimal total = 0; decimal descuento = 0; decimal subtotal = 0; foreach (Detfactura det in obj.DetsFactura) { subtotal += det.Total; } foreach (Detfactura det in obj.DetsFactura) { descuento += det.Descuento; } total = subtotal - descuento; dgvIngresos.Rows.Add(obj.Id, obj.NFactura, Convert.ToDateTime(obj.FhRegistro).ToString("dd-MM-yyyy"), PersonaDAL.getPersonaById(obj.IdPersona).Nombre, concepto, Decimal.Round(subtotal, 2).ToString(), Decimal.Round(descuento, 2).ToString(), "$" + Decimal.Round(total, 2).ToString() ); } CalcularGanancias(rdbMontYear.Checked ? FacturaDAL.getTotalFacturasByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : FacturaDAL.getTotalFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit), rdbMontYear.Checked ? EgresoDAL.getTotalEgresoByParametro(Convert.ToInt64((cbxYear.SelectedItem as Year).Desde), Convert.ToDateTime("20-" + cbxMonth.SelectedItem.ToString() + "-2010").ToString("MM"), Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit) : EgresoDAL.getTotalEgresoNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit)); lblPages.Text = "Página " + currentPage + " de " + (numPages == 0 ? "1" : numPages.ToString()); return; }
public EgresoController() { _oEgresoDAL = new EgresoDAL(); }