Пример #1
0
        private void ELRTextBox_Leave(object sender, EventArgs e)
        {
            ELRUtils util   = new ELRUtils();
            string   NDecim = "N";

            try
            {
                NDecim += Decimales.ToString();

                if (EsBusqueda)
                {
                    GetById();
                }

                if ((Formato == tbFormato.Decimal) || (Formato == tbFormato.DecimalPositivo))
                {
                    this.Text = util.ConvertirANumero(Text.Trim()).ToString(NDecim);
                }
                if ((Formato == tbFormato.NumerosEnteros) || (Formato == tbFormato.NumerosEnterosPositivos))
                {
                    if (Text.Trim() == "")
                    {
                        Text = "0";
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                util = null;
            }
        }
        private void dtgData_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            double  total = 0;
            string  unico = "0";
            double  cantidad, valor;
            object  calcObject;
            DataRow fila;

            try
            {
                unico    = dtgData["Unico", dtgData.CurrentRow.Index].Value.ToString();
                cantidad = objUtil.ConvertirANumero(dtgData["Cantidad", dtgData.CurrentRow.Index].Value.ToString());

                fila  = MyData.Select("Unico = " + unico)[0];
                valor = double.Parse(fila["Valor"].ToString());

                total = cantidad * valor;

                fila["Total"] = total;

                //TOTALIZAMOS LOS DATOS
                total      = 0;
                calcObject = MyData.Compute("Sum(Total)", "");
                if (calcObject != null)
                {
                    if (calcObject.ToString().Trim() != "")
                    {
                        total = double.Parse(calcObject.ToString());
                    }

                    lblTotal.Text = total.ToString("N2");
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
        }
Пример #3
0
        private void ELRTextBox_Enter(object sender, EventArgs e)
        {
            ELRUtils util = new ELRUtils();

            try
            {
                if ((Formato == tbFormato.Decimal) || (Formato == tbFormato.DecimalPositivo))
                {
                    this.Text = util.ConvertirANumero(Text.Trim()).ToString();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                util = null;
            }
        }
Пример #4
0
        private bool Calcular()
        {
            bool   resultado = false;
            double total;

            try
            {
                btnAceptar.Enabled = false;

                montoDeduda = 0;
                enEfectivo  = objUtil.ConvertirANumero(txtEnEfectivo.Text);
                enCheques   = objUtil.ConvertirANumero(txtEnCheques.Text);
                enTarjetas  = objUtil.ConvertirANumero(txtEnTarjeta.Text);
                aPagar      = objUtil.ConvertirANumero(txtAPagar.Text);

                aDevolver = enEfectivo - aPagar;
                if (aDevolver < 0)
                {
                    aDevolver = 0;
                }

                total = (enEfectivo - aDevolver) + enCheques + enTarjetas;
                if ((enEfectivo < 0) || (enCheques < 0) || (enTarjetas < 0) || (aPagar < 0))
                {
                    if (aPagar < 0)
                    {
                        txtAPagar.SelectAll();
                        txtAPagar.Focus();
                    }
                    else if (enEfectivo < 0)
                    {
                        txtEnEfectivo.SelectAll();
                        txtEnEfectivo.Focus();
                    }
                    else if (enCheques < 0)
                    {
                        txtEnCheques.SelectAll();
                        txtEnCheques.Focus();
                    }
                    else
                    {
                        txtEnTarjeta.SelectAll();
                        txtEnTarjeta.Focus();
                    }

                    throw new Exception("No Puede Digitar Valores Negativos");
                }
                if (total > aPagar)
                {
                    throw new Exception("El Desglose de Pago no Puede Superar el Monto a Cobrar");
                }
                else
                {
                    montoDeduda = monto - aPagar;

                    //Mostramos los Datos
                    txtADevolver.Text   = aDevolver.ToString("n2");
                    lblACredito.Text    = "A Deber: " + montoDeduda.ToString("N2");
                    lblACredito.Visible = ((PermiteCredito) && (montoDeduda > 0));

                    btnAceptar.Enabled = (total == aPagar);

                    resultado = true;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(resultado);
        }
Пример #5
0
        public void MostrarReporte()
        {
            ReportDataSource DSData;
            DataRow          fila;

            string        NOMBRE_EMPRESA_OFICINA = "";
            string        DIRECCION_OFICINA      = "";
            string        RNC_EMPRESA            = "";
            string        TELEFONOS_OFICINA      = "";
            DirectoryInfo dirReport;
            int           cantParametros = 0, parmIndex = 0;
            double        valorRNC = 0;

            DataDB_ELR_NET.DataDB db = new DataDB_ELR_NET.DataDB();

            bool resultado = true;

            byte[] arrPicture;
            string logoBase64 = "";

            try
            {
                dirReport = new DirectoryInfo(Application.StartupPath + @"\reportes");

                pathReporte = pathReporte.ToUpper().Trim();
                if (!pathReporte.Contains(dirReport.ToString().ToUpper()))
                {
                    pathReporte = dirReport.ToString() + @"\" + pathReporte;
                }

                //AGREGAMOS LA EXTENSION
                if (!pathReporte.Contains("RDLC"))
                {
                    pathReporte += ".rdlc";
                }


                //CARGAMOS EL REPORTE LOCAL DESDE LA CARPETA REPORTES
                resultado = File.Exists(pathReporte);



                if (resultado == false)
                {
                    objUtil.MostrarMensajeError("El Archivo [" + pathReporte + "] No Existe");
                }

                if (resultado)
                {
                    reportViewer1.ProcessingMode         = ProcessingMode.Local;
                    reportViewer1.LocalReport.ReportPath = pathReporte;
                    reportViewer1.LocalReport.DataSources.Clear();

                    //AGREGAMOS LOS DATASET
                    if (MyParametrosDS.Count > 0)
                    {
                        foreach (ReportesDS item in MyParametrosDS)
                        {
                            DSData       = new ReportDataSource();
                            DSData.Name  = item.Nombre;
                            DSData.Value = item.Valor;

                            reportViewer1.LocalReport.DataSources.Add(DSData);
                        }
                    }
                    else
                    {
                        DSData       = new ReportDataSource();
                        DSData.Name  = "DSData";
                        DSData.Value = DTData;

                        reportViewer1.LocalReport.DataSources.Add(DSData);
                    }



                    //Buscamos los datos de la oficina
                    if (DTOficina == null)
                    {
                        db.LimpiarFiltros();

                        if (oficinaId > 0)
                        {
                            db.AddFiltroIgualA("Oficina_Id", oficinaId.ToString());
                        }
                        if (empresaId > 0)
                        {
                            db.AddFiltroIgualA("Empresa_Id", empresaId.ToString());
                        }

                        DTOficina = db.GetAll("VEMPRESAS_OFICINAS", 1, db.Filtros);
                    }


                    //Vamos a Obtener los datos de la Oficina Para Pasar como Parametros
                    if (DTOficina.Rows.Count > 0)
                    {
                        fila = DTOficina.Rows[0];
                        NOMBRE_EMPRESA_OFICINA = fila["Empresa_Nombre"].ToString() + ", " + fila["Nombre"].ToString();
                        DIRECCION_OFICINA      = fila["Direccion"].ToString();

                        TELEFONOS_OFICINA = fila["Telefono1"].ToString();
                        if (!(fila["Telefono2"] is DBNull))
                        {
                            if (fila["Telefono2"].ToString().Trim() != "")
                            {
                                if (TELEFONOS_OFICINA.Trim() != "")
                                {
                                    TELEFONOS_OFICINA += ", ";
                                }
                                TELEFONOS_OFICINA += fila["Telefono2"].ToString().Trim();
                            }
                        }

                        RNC_EMPRESA = fila["Empresa_RNC"].ToString();
                        valorRNC    = objUtil.ConvertirANumero(RNC_EMPRESA.Replace("-", ""));
                        if (valorRNC <= 0)
                        {
                            RNC_EMPRESA = "0";
                        }
                    }

                    //AGREGAMOS LOS PARAMETROS
                    AddParm("NOMBRE_EMPRESA_OFICINA", NOMBRE_EMPRESA_OFICINA);
                    AddParm("RNC_EMPRESA", RNC_EMPRESA);
                    AddParm("DIRECCION_OFICINA", DIRECCION_OFICINA);
                    AddParm("TELEFONOS_OFICINAS", TELEFONOS_OFICINA);
                    AddParm("TITULO", titulo);
                    AddParm("NOMBRE_USUARIO", nombreUsuario);

                    //CARGAMOS EL LOGO
                    logoEmpresa = Environment.CurrentDirectory + @"\images\logo.png";
                    arrPicture  = File.ReadAllBytes(logoEmpresa);
                    logoBase64  = Convert.ToBase64String(arrPicture);
                    AddParm("LOGO_EMPRESA", logoBase64);


                    if (montoLetras.Trim() != "")
                    {
                        AddParm("MONTO_LETRAS", montoLetras.ToUpper());
                    }

                    //AGREGAMOS OTROS PARAMETROS
                    parmIndex      = 0;
                    cantParametros = otrosParms.Count;
                    ReportParameter[] parametros = new ReportParameter[cantParametros];
                    foreach (MyReportParameter item in otrosParms)
                    {
                        if (parmIndex >= cantParametros)
                        {
                            break;
                        }
                        parametros[parmIndex] = new ReportParameter(item.nombre, item.valor);
                        parmIndex++;
                    }


                    this.reportViewer1.LocalReport.SetParameters(parametros);

                    //MOSTRAMOS VISTA EN DISENO DE IMPRESION
                    reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                    reportViewer1.ZoomMode    = ZoomMode.Percent;
                    reportViewer1.ZoomPercent = 100;

                    //POR ULTIMO UN REFRESH AL REPORTE
                    reportViewer1.RefreshReport();
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
        }
Пример #6
0
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            DataColumn MyColumna;
            DataRow    MyFila;
            ELRUtils   util   = new ELRUtils();
            string     NDecim = "N";

            string valor = "";

            try
            {
                valor = ValorPorDefecto;

                if (DSData != null)
                {
                    if (NombreTabla.Trim() == "")
                    {
                        if (!DSData.Tables[0].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[0].Columns[CampoData];
                        MyFila    = DSData.Tables[0].Rows[posicion];
                    }
                    else
                    {
                        if (!DSData.Tables[NombreTabla].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[NombreTabla].Columns[CampoData];
                        MyFila    = DSData.Tables[NombreTabla].Rows[posicion];
                    }

                    if (MyColumna.MaxLength > 0)
                    {
                        MaxLength = MyColumna.MaxLength;
                    }

                    //APLICAMOS FORMATO DECIMAL
                    if ((MyColumna.DataType == typeof(Decimal)) || (MyColumna.DataType == typeof(Double)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0.0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.DecimalPositivo;
                            if (Decimales <= 0)
                            {
                                Decimales = 2;
                            }
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        NDecim   += Decimales.ToString();
                        this.Text = util.ConvertirANumero(valor).ToString(NDecim);
                    }
                    else if ((MyColumna.DataType == typeof(Int16)) || (MyColumna.DataType == typeof(Int32)) || (MyColumna.DataType == typeof(Int64)) || (MyColumna.DataType == typeof(Single)) || (MyColumna.DataType == typeof(SByte)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnteros;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else if ((MyColumna.DataType == typeof(UInt16)) || (MyColumna.DataType == typeof(UInt32)) || (MyColumna.DataType == typeof(UInt64)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnterosPositivos;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else
                    {
                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila);
                        }

                        if (CampoData.ToUpper().Contains("CEDULA"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("RNC"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("TELEFONO"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }
                        else if (CampoData.ToUpper().Contains("CELULAR"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }


                        this.Text = valor.Trim();
                    }
                }

                if (EsAutoGenerado)
                {
                    this.Enabled = false;
                }
                if ((!esNuevo) && (this.Enabled))
                {
                    this.Enabled = EsEditable;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }