示例#1
0
        public List <Factura_Excel> Listar_FacturasExcel(string Rut, string NombreEmisor, string Folio, string NombreItem, string FechaInicioEmision, string FechaTerminoEmison, string FechaInicioVen, string FechaTerminoVen, int Estado)
        {
            List <Factura_Excel> lista    = new List <Factura_Excel>();
            Conexion             conexion = new Conexion();
            SqlCommand           cmd      = conexion.AbrirConexionSV2000_Factura();

            if (cmd != null)
            {
                cmd.CommandText = "[Recepcion_Factura]";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Rut", Rut);
                cmd.Parameters.AddWithValue("@NombreEmisor", NombreEmisor);
                cmd.Parameters.AddWithValue("@Folio", Folio);
                cmd.Parameters.AddWithValue("@NombreItem", NombreItem);
                cmd.Parameters.AddWithValue("@FechaInicioEmision", FechaInicioEmision.Replace("/", "-"));
                cmd.Parameters.AddWithValue("@FechaTerminoEmision", FechaTerminoEmison.Replace("/", "-"));
                cmd.Parameters.AddWithValue("@FechaInicioVen", FechaInicioVen.Replace("/", "-"));
                cmd.Parameters.AddWithValue("@FechaTerminoVen", FechaTerminoVen.Replace("/", "-"));
                cmd.Parameters.AddWithValue("@Estado", Estado);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Factura_Excel f = new Factura_Excel();
                    f.Rut    = reader["Rut"].ToString();
                    f.Nombre = reader["NombreEmisor"].ToString();
                    f.Folio  = reader["Folio"].ToString().Replace(".0", "");

                    try
                    {
                        string[] str = reader["FechaEmision"].ToString().Split('-');
                        f.FechaEmision = str[2] + "/" + str[1] + "/" + str[0];
                    }
                    catch
                    {
                        f.FechaEmision = reader["FechaEmision"].ToString();
                    }


                    try
                    {
                        string[] str2 = reader["FechaVencimiento"].ToString().Split('-');
                        f.FechaVencimiento = str2[2] + "/" + str2[1] + "/" + str2[0];
                    }
                    catch
                    {
                        f.FechaVencimiento = reader["FechaVencimiento"].ToString();
                    }

                    if (reader["mont_neto"].ToString() != "")
                    {
                        f.ValorNeto = Convert.ToInt32(Convert.ToDouble(reader["mont_neto"].ToString())).ToString("N0").Replace(",", ".");
                    }
                    else
                    {
                        f.ValorNeto = "0";
                    }
                    if (reader["impu_vaag"].ToString() != "")
                    {
                        f.IVA = Convert.ToInt32(Convert.ToDouble(reader["impu_vaag"].ToString())).ToString("N0").Replace(",", ".");
                    }
                    else
                    {
                        f.IVA = "0";
                    }
                    if (reader["mont_tota"].ToString() != "")
                    {
                        f.Total = Convert.ToInt32(Convert.ToDouble(reader["mont_tota"].ToString())).ToString("N0").Replace(",", ".");
                    }
                    else
                    {
                        f.Total = "0";
                    }



                    if (reader["Estado"].ToString() == "ER3")
                    {
                        f.Estado = "DTE no Recibido-Error en Rut de Receptor";
                    }
                    else if (reader["Estado"].ToString() == "ER4")
                    {
                        f.Estado = "DTE no Recibido-DTE Repetido";
                    }
                    else if (reader["Estado"].ToString() == "ERR")
                    {
                        f.Estado = "DTE con errores internos";
                    }
                    else if (reader["Estado"].ToString() == "INI")
                    {
                        f.Estado = "DTE inicializado";
                    }

                    lista.Add(f);
                }
            }
            conexion.CerrarConexion();
            return(lista);
        }
示例#2
0
        public List <Factura_Excel> Listar_FacturasEnviadasExcel(string Rut, string NombreEmisor, string Folio, string NombreItem, string FechaInicio, string FechaTermino, int Estado)
        {
            List <Factura_Excel> lista    = new List <Factura_Excel>();
            Conexion             conexion = new Conexion();
            SqlCommand           cmd      = conexion.AbrirConexionSV2000_Factura();

            if (cmd != null)
            {
                cmd.CommandText = "[Envio_Factura]";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Rut", Rut);
                cmd.Parameters.AddWithValue("@NombreEmisor", NombreEmisor);
                cmd.Parameters.AddWithValue("@Folio", Folio);
                cmd.Parameters.AddWithValue("@NombreItem", NombreItem);
                cmd.Parameters.AddWithValue("@FechaInicio", FechaInicio.Replace("/", "-"));
                cmd.Parameters.AddWithValue("@FechaTermino", FechaTermino.Replace("/", "-"));
                cmd.Parameters.AddWithValue("@Estado", Estado);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Factura_Excel f = new Factura_Excel();
                    f.Folio  = reader["Folio"].ToString().Replace(".0", "");
                    f.Rut    = reader["Rut"].ToString();
                    f.Nombre = reader["Cliente"].ToString();


                    try
                    {
                        string[] str = reader["FechaEmision"].ToString().Split('-');
                        f.FechaEmision = str[2] + "/" + str[1] + "/" + str[0];
                    }
                    catch
                    {
                        f.FechaEmision = reader["FechaEmision"].ToString();
                    }

                    f.FechaVencimiento = reader["dias"].ToString();
                    if (reader["mont_neto"].ToString() != "")
                    {
                        f.ValorNeto = Convert.ToInt32(Convert.ToDouble(reader["mont_neto"].ToString())).ToString("N0").Replace(",", ".");
                    }
                    else
                    {
                        f.ValorNeto = "0";
                    }
                    if (reader["impu_vaag"].ToString() != "")
                    {
                        f.IVA = Convert.ToInt32(Convert.ToDouble(reader["impu_vaag"].ToString())).ToString("N0").Replace(",", ".");
                    }
                    else
                    {
                        f.IVA = "0";
                    }
                    if (reader["mont_tota"].ToString() != "")
                    {
                        f.Total = Convert.ToInt32(Convert.ToDouble(reader["mont_tota"].ToString())).ToString("N0").Replace(",", ".");
                    }
                    else
                    {
                        f.Total = "0";
                    }



                    if (reader["Estado"].ToString() == "DOK")
                    {
                        f.Estado = "DTE OK en el SII";
                    }
                    else if (reader["Estado"].ToString() == "RLV")
                    {
                        f.Estado = "DTE Aceptado con Reparos Leves";
                    }
                    else if (reader["Estado"].ToString() == "ERR")
                    {
                        f.Estado = "DTE con errores internos";
                    }
                    else if (reader["Estado"].ToString() == "RPR")
                    {
                        f.Estado = "Aprobado Con reparos por el SII";
                    }
                    lista.Add(f);
                }
            }
            conexion.CerrarConexion();
            return(lista);
        }