示例#1
0
        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;
            }
        }
示例#2
0
 private void btnAnular_Click(object sender, EventArgs e)
 {
     if (dgvIngresos.CurrentRow != null)
     {
         if (FacturaDAL.getIsParentReservas((Int64)dgvIngresos.CurrentRow.Cells[0].Value))
         {
             if (MessageBox.Show("¿Esta seguro que desea anular esta factura? si lo hace, tambien se anularan los pagos que se le allan cobrado al cliente. Este ingreso ya no aparecerá en los resgistros.", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 if (FacturaDAL.anularFactura((Int64)dgvIngresos.CurrentRow.Cells[0].Value, true, Inicio.CurrentUser))
                 {
                     MessageBox.Show("La factura ha sido anulada correctamente, los calculos se reiniciarán automaticamente.", "Operación realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
                     numPages = Pages.Count;
                     SetCurrentPage();
                     tmrTaskDgv.Start();
                 }
             }
         }
         else
         {
             if (MessageBox.Show("¿Esta seguro que desea anular esta factura? si lo hace, este ingreso ya no aparecerá en los resgistros.", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 if (FacturaDAL.anularFactura((Int64)dgvIngresos.CurrentRow.Cells[0].Value, false, Inicio.CurrentUser))
                 {
                     MessageBox.Show("La factura ha sido anulada correctamente, los calculos se reiniciarán automaticamente.", "Operación realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
                     numPages = Pages.Count;
                     SetCurrentPage();
                     tmrTaskDgv.Start();
                 }
             }
         }
     }
 }
示例#3
0
 private void dgvIngresos_DoubleClick(object sender, EventArgs e)
 {
     if (dgvIngresos.CurrentRow != null)
     {
         FrmFactura factura = new FrmFactura();
         factura.EditingObject = FacturaDAL.getFacturaById((Int64)dgvIngresos.CurrentRow.Cells[0].Value);
         factura.ShowDialog();
     }
 }
示例#4
0
 private void icUpdate_Click(object sender, EventArgs e)
 {
     txtCurrentIndex.Text = 1.ToString();
     currentPage          = 1;
     Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
     numPages = Pages.Count;
     SetCurrentPage();
     tmrTaskDgv.Start();
 }
示例#5
0
        public static Factura BuscarPorFolio(int folio)
        {
            //using (TransactionScope scope = new TransactionScope())
            //{
            Factura facturaADevolver = FacturaDAL.DevolverPorId(folio);

            //scope.Complete();
            return(facturaADevolver);
            //};
        }
示例#6
0
 private void txtBuscar_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == Convert.ToChar(Keys.Enter))
     {
         Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
         numPages = Pages.Count;
         SetCurrentPage();
         tmrTaskDgv.Start();
     }
 }
示例#7
0
        private List <Factura> GetListFacturas(List <Int64> pLista)
        {
            List <Factura> facturas = new List <Factura>();

            if (pLista != null)
            {
                facturas = rdbMontYear.Checked ? FacturaDAL.getFacturasIndexerParametro(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) : FacturaDAL.getFacturasIndexerNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, currentPage - 1, pLimit);
            }
            return(facturas);
        }
示例#8
0
 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());
 }
示例#9
0
        public static int RegistrarFacturacion(Factura factura)
        {
            int folio;

            using (TransactionScope scope = new TransactionScope())
            {
                folio = FacturaDAL.Crear(factura);
                FacturaDAL.ActualizarTotal(factura.Folio, factura.Total);
                scope.Complete();
            };
            return(folio);
        }
示例#10
0
        private void btnIngresoExterno_Click(object sender, EventArgs e)
        {
            FrmFactura factura = new FrmFactura();

            factura.IngresoInterno = false;
            factura.ShowDialog();
            Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
            numPages = Pages.Count;
            SetCurrentPage();

            tmrTaskDgv.Start();
        }
示例#11
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (currentFactura.Id == 0)
                {
                    LstPermiso permiso = Inicio.CurrentUser.Sucursales.Where(a => a.IdSucursal == Inicio.CurrentSucursal.Id).FirstOrDefault().Permisos.Where(a => a.Permiso.Nombre == "Registrar Ingresos").FirstOrDefault();
                    btnRegistrar.Enabled = !(permiso == null || permiso.Otorgado == false);

                    foreach (Detfactura det in currentFactura.DetsFactura)
                    {
                        currentFactura.Observacion += det.Descuento > 0 ? "DESCUENTO DE $" + Decimal.Round(det.Descuento, 2) + " EN " + det.Producto.Nombre + ". " : "";
                    }
                    currentFactura.Observacion += txtObservacion.Text;

                    Factura facturaInserted = FacturaDAL.insertFactura(currentFactura, Inicio.CurrentUser);
                    if (facturaInserted.Id != 0)
                    {
                        currentFactura = facturaInserted;
                        imprimirFactura();
                        MessageBox.Show("El ingreso ha sido registrado exitosamente.", "Registro satisfactorio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        currentFactura    = null;
                        this.DialogResult = DialogResult.Yes;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ocurrio un error inesperado al intentar registrar el ingreso, 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);
                    }
                }
                else
                {
                    imprimirFactura();
                    this.DialogResult = DialogResult.Yes;
                    this.Close();
                }
            }
            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 ingreso");
                MessageBox.Show("Ocurrio un error inesperado al intentar registrar el ingreso, 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);
                this.DialogResult = DialogResult.No;
                this.Close();
            }
        }
示例#12
0
        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;
        }
示例#13
0
        private void cbxMonth_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                txtCurrentIndex.Text = "1";
                Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
                numPages = Pages.Count;
                SetCurrentPage();
                tmrTaskDgv.Start();
            }
            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 ingresos sin parametros");
                MessageBox.Show("Ha ocurrido un error al intentar cargar la información de ingresos sin parametros, por favor comuniquese con el desarrollador al correo [email protected]", "Error fatal", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#14
0
 public FacturaBL(FacturaDAL facturaDAL)
 {
     this.facturaDAL = facturaDAL;
 }
示例#15
0
 public static void ActualizarFactura(Factura factura)
 {
     FacturaDAL.ActualizarFactura(factura);
 }
示例#16
0
        private void ControlIngresos_Load(object sender, EventArgs e)
        {
            try
            {
                cbxYear.DataSource    = YearDAL.getYears(10000);
                cbxYear.DisplayMember = "Desde";
                cbxYear.ValueMember   = "Id";
                DateTime date = DateTime.Today.AddMonths(-(DateTime.Today.Month - 1));
                for (int i = 0; i < 12; i++)
                {
                    cbxMonth.Items.Add(date.AddMonths(i).ToString("MMMM"));
                }


                cbxMonth.SelectedIndex = DateTime.Now.Month - 1;
                cbxYear.SelectedIndex  = 0;
                Pages    = rdbMontYear.Checked ? FacturaDAL.getIdsFacturasByParametro(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.getIdsFacturasNoParametro(Validation.Validation.Val_Injection(txtBuscar.Text), Inicio.CurrentSucursal.Id, pLimit);
                numPages = Pages.Count;
                SetCurrentPage();
                tmrTaskDgv.Start();

                cbxMonth.SelectedIndexChanged += cbxMonth_SelectedIndexChanged;
                cbxYear.SelectedIndexChanged  += cbxMonth_SelectedIndexChanged;
                rdbMontYear.CheckedChanged    += cbxMonth_SelectedIndexChanged;
                if (ingresoMes == 1)
                {
                    pnlParametro.Enabled = false;
                    pnlParametro.Visible = false;
                    cbxMonth.Enabled     = false;
                    cbxYear.Enabled      = false;
                    this.FormBorderStyle = FormBorderStyle.Sizable;
                    lblTiltulo.Text      = "Ingresos del mes de " + DateTime.Now.ToString("MMMM", new CultureInfo("es-ES"));
                }
                foreach (LstPermiso obj in Inicio.CurrentUser.Sucursales.Where(a => a.IdSucursal == Inicio.CurrentSucursal.Id).FirstOrDefault().Permisos)
                {
                    switch (obj.Permiso.Nombre)
                    {
                    case "Registrar Ingresos":
                        if (obj.Otorgado)
                        {
                            btnNuevoIngreso.Enabled   = true;
                            btnIngresoExterno.Enabled = true;
                        }
                        break;

                    case "Anular Ingresos":
                        if (obj.Otorgado)
                        {
                            btnAnular.Enabled = true;
                        }
                        break;

                    case "Exportar Ingresos y Egresos del mes":
                        if (obj.Otorgado)
                        {
                            picExcel.Enabled = true;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            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 [email protected]", "Error fatal", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }