Example #1
0
        public void Recuperar()
        {
            if (File.Exists(Application.StartupPath + "\\Tostatronic_Cotizacion.xml"))
            {
                try
                {
                    InformacionVenta informacionVenta = GuardarCotizacion.Leer();

                    List <string[]> listaCliente = Sql.BuscarDatos("SELECT id_cliente, rfc, nombres, apellido_paterno, id_tipo_cliente FROM clientes WHERE id_cliente = '" +
                                                                   informacionVenta.Id_cliente + "'");

                    id_cliente              = int.Parse(listaCliente[0][0]);
                    txtRfc.Text             = listaCliente[0][1];
                    txtNombre.Text          = listaCliente[0][2];
                    txtApellidoPaterno.Text = listaCliente[0][3];
                    tipoCliente             = int.Parse(listaCliente[0][4]);

                    foreach (Producto producto in informacionVenta.Productos)
                    {
                        List <string[]> lista = Sql.BuscarDatos("SELECT * FROM productos WHERE codigo = '" +
                                                                producto.Id_producto + "'");
                        float descuentoTemp = Descuento(lista[0][0]);
                        float subTotalTemp  = producto.Cantidad * float.Parse(lista[0][7 - tipoCliente]);
                        dgvCotizacion.Rows.Add(new string[] { lista[0][0], lista[0][1],
                                                              producto.Cantidad.ToString(), lista[0][7 - tipoCliente],
                                                              (subTotalTemp - subTotalTemp * descuentoTemp / 100).ToString(), descuentoTemp.ToString() });
                    }
                    Total();
                    ActivarCotizacion();
                }
                catch (Exception) { }
            }
        }
        public static void Guardar(InformacionVenta informacionVenta)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(InformacionVenta));
            TextWriter    textWriter = new StreamWriter(Application.StartupPath + "\\Tostatronic_Venta.xml");

            serializer.Serialize(textWriter, informacionVenta);
            textWriter.Close();
        }
        public static InformacionVenta Leer()
        {
            XmlSerializer    serializer       = new XmlSerializer(typeof(InformacionVenta));
            FileStream       fs               = new FileStream(Application.StartupPath + "\\Tostatronic_Venta.xml", FileMode.Open);
            TextReader       textReader       = new StreamReader(fs);
            InformacionVenta informacionVenta = (InformacionVenta)serializer.Deserialize(textReader);

            fs.Close();
            File.Delete(Application.StartupPath + "\\Tostatronic_Venta.xml");
            return(informacionVenta);
        }