public void Agregar(DetalleVentas detalleVentas)
        {
            AccesoDatos conexion = new AccesoDatos();
            string      consulta = "INSERT INTO DETALLEVENTAS (NROVENTA,IDPRODUCTO,CANTIDAD,PRECIO) VALUES (";

            try
            {
                consulta += detalleVentas.IdVenta + ",";
                consulta += detalleVentas.IdProducto + ",";
                consulta += detalleVentas.Cantidad + ",";
                consulta += detalleVentas.Precio.ToString() + ")";

                conexion.setearConsulta(consulta);
                conexion.ejecutarAccion();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.cerrarConexion();
                conexion = null;
            }
        }
Beispiel #2
0
        public void BuscarTest()
        {
            RepositorioBase <DetalleVentas> repositorio = new RepositorioBase <DetalleVentas>();
            DetalleVentas detalle = repositorio.Buscar(1);

            Assert.IsNotNull(detalle);
        }
Beispiel #3
0
        public IActionResult CreateDetalleVenta([Bind("Id_DetalleVenta,Subtotal,Cantidad,Id_Venta,Id_Producto")] DetalleVentas detalleVentas)
        {
            if (detalleVentas != null)
            {
                Productos producto = (from p in _context.Productos where p.Id_Producto == detalleVentas.Id_Producto select p).FirstOrDefault();

                double newSubTotal = detalleVentas.Subtotal + (detalleVentas.Cantidad * producto.Precio);
                Math.Round((newSubTotal * 100d) / 100d);

                detalleVentas.Subtotal = newSubTotal;
                _context.Add(detalleVentas);
                _context.SaveChanges();
                ViewBag.productosList = (from p in _context.Productos select p).ToList();

                ViewBag.ventaObject = (from v in _context.Ventas where v.Id_Venta == detalleVentas.Id_Venta select v).FirstOrDefault();
                ViewBag.detList     = (from d in _context.DetalleVentas where d.Id_Venta == detalleVentas.Id_Venta select d).ToList();

                Ventas newTotalizedVenta = (from v in _context.Ventas where v.Id_Venta == detalleVentas.Id_Venta select v).FirstOrDefault();
                newTotalizedVenta.Total = newTotalizedVenta.Total + newSubTotal;
                _context.SaveChanges();

                return(View("CreateDetalleVenta", new { id = detalleVentas.Id_Venta }));
            }
            return(View("Index"));
        }
Beispiel #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            DetalleVentas detalleVentas = db.DetalleVentas.Find(id);

            db.DetalleVentas.Remove(detalleVentas);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public override global::System.Data.DataSet Clone()
        {
            DetalleVentas cln = ((DetalleVentas)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Beispiel #6
0
        public void ModificarTest()
        {
            RepositorioBase <DetalleVentas> repositorio = new RepositorioBase <DetalleVentas>();
            bool          paso    = false;
            DetalleVentas detalle = repositorio.Buscar(1);

            detalle.VentaId = 2;
            paso            = repositorio.Modificar(detalle);
            Assert.AreEqual(true, paso);
        }
Beispiel #7
0
        public void ModificarTest()
        {
            RepositorioBase <DetalleVentas> repositorio = new RepositorioBase <DetalleVentas>();
            bool          paso = false;
            DetalleVentas d    = repositorio.Buscar(1);

            d.Unidades = 20;
            paso       = repositorio.Modificar(d);
            Assert.AreEqual(true, paso);
        }
Beispiel #8
0
        public string SaveChanges()
        {
            string message = null;

            try
            {
                var detVentaDataModel = new DetalleVentas();
                detVentaDataModel.IdDetalleVenta = IdDetalleVenta;
                detVentaDataModel.IdVenta        = IdVenta;
                detVentaDataModel.CodigoProducto = CodigoProducto;
                detVentaDataModel.Cantidad       = Cantidad;
                detVentaDataModel.Subtotal       = Subtotal;
                detVentaDataModel.Accion         = Accion;



                switch (state)
                {
                case EntityState.Added:
                {
                    genericRepository.Add(detVentaDataModel);
                    message = "Detalle de Venta registrado correctamente";
                    break;
                }

                case EntityState.deleted:
                {
                    genericRepository.Remove(IdVenta);
                    message = "Detalle de Venta eliminada exitosamente";
                    break;
                }

                case EntityState.Modified:
                {
                    genericRepository.Edit(detVentaDataModel);
                    message = "Detalle de Venta Modificada Exitosamente";
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                SqlException sqlEx = ex as SqlException;
                if (sqlEx != null && sqlEx.Number == 2267)
                {
                    message = "Registro duplicado";
                }
                else
                {
                    message = ex.Message;
                }
            }
            return(message);
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DetalleVentas ds = new DetalleVentas();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "id,idVenta,idProducto,cantidad,subTotal")] DetalleVentas detalleVentas)
        {
            if (ModelState.IsValid)
            {
                db.DetalleVentas.Add(detalleVentas);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.idVenta    = new SelectList(db.Ventas, "id", "descripcion", detalleVentas.idVenta);
            ViewBag.idProducto = new SelectList(db.Productos, "id", "nombre", detalleVentas.idProducto);
            return(View(detalleVentas));
        }
Beispiel #11
0
        // GET: DetalleVentas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DetalleVentas detalleVentas = db.DetalleVentas.Find(id);

            if (detalleVentas == null)
            {
                return(HttpNotFound());
            }
            return(View(detalleVentas));
        }
Beispiel #12
0
        private void AgregarProductometroButton_Click(object sender, EventArgs e)
        {
            int           id           = Convert.ToInt32(IDProductosnumericUpDown.Value);
            int           cantidad     = Convert.ToInt32(this.CantidadnumericUpDown.Value);
            Productos     producto     = new RepositorioBase <Productos>().Buscar(id);
            DetalleVentas detalleVenta = new DetalleVentas
            {
                Precio     = producto.Precio,
                Cantidad   = cantidad,
                ProductoId = id
            };

            listaVentas.Add(detalleVenta);
            ActualizarGrid();
        }
Beispiel #13
0
        public void GuardarTest()
        {
            RepositorioBase <DetalleVentas> repositorio = new RepositorioBase <DetalleVentas>();
            bool          paso = false;
            DetalleVentas d    = new DetalleVentas();

            d.Iddetalleventa  = 1;
            d.Idventa         = 1;
            d.Idproducto      = 1;
            d.Unidades        = 2;
            d.Costounidad     = 10;
            d.Descuentounidad = 5;
            d.Total           = 10;
            paso = repositorio.Guardar(d);
            Assert.AreEqual(true, paso);
        }
Beispiel #14
0
        // GET: DetalleVentas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DetalleVentas detalleVentas = db.DetalleVentas.Find(id);

            if (detalleVentas == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idVenta    = new SelectList(db.Ventas, "id", "descripcion", detalleVentas.idVenta);
            ViewBag.idProducto = new SelectList(db.Productos, "id", "nombre", detalleVentas.idProducto);
            return(View(detalleVentas));
        }
Beispiel #15
0
 public ActionResult Edit(DetalleVentas detalleVentas)
 {
     if (ModelState.IsValid)
     {
         DetalleVentas dv = db.DetalleVentas.Find(detalleVentas.id);
         dv.cantidad   = detalleVentas.cantidad;
         dv.subTotal   = detalleVentas.subTotal;
         dv.idVenta    = detalleVentas.idVenta;
         dv.idProducto = detalleVentas.idProducto;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idVenta    = new SelectList(db.Ventas, "id", "descripcion", detalleVentas.idVenta);
     ViewBag.idProducto = new SelectList(db.Productos, "id", "nombre", detalleVentas.idProducto);
     return(View(detalleVentas));
 }
Beispiel #16
0
            public void ModificarTest()
            {
                RepositorioBase <DetalleVentas> db = new RepositorioBase <DetalleVentas>();

                DetalleVentas entity = new DetalleVentas()
                {
                    IdDetalleVenta  = 4,
                    IdProducto      = 2,
                    IdVenta         = 1,
                    CostoUnidad     = 504,
                    DescuentoUnidad = 4,
                    Total           = 55,
                    Unidades        = 5
                };

                Assert.IsTrue(db.Modificar(entity));
            }
Beispiel #17
0
            public void GuardarTest()
            {
                RepositorioBase <DetalleVentas> db = new RepositorioBase <DetalleVentas>();

                DetalleVentas entity = new DetalleVentas()
                {
                    IdDetalleVenta  = 0,
                    IdProducto      = 1,
                    IdVenta         = 1,
                    CostoUnidad     = 500,
                    DescuentoUnidad = 4,
                    Total           = 50,
                    Unidades        = 4
                };

                Assert.IsTrue(db.Guardar(entity));
            }
Beispiel #18
0
        public void GuardarTest()
        {
            DetalleVentas tipos = new DetalleVentas()
            {
                VentaId         = 7,
                ProductoId      = 0,
                Unidades        = 1,
                CostoUnidad     = 0,
                DescuentoUnidad = 4,
                Total           = 10
            };

            RepositorioBase <DetalleVentas> repositorio = new RepositorioBase <DetalleVentas>();
            bool paso = false;

            paso = repositorio.Guardar(tipos);
            Assert.AreEqual(true, paso);
        }
Beispiel #19
0
        public void GuardarTest()
        {
            Repositorio <DetalleVentas> db = new Repositorio <DetalleVentas>();
            bool          paso             = false;
            DetalleVentas d = new DetalleVentas();

            d.IdDetalleVenta  = 1;
            d.IdVenta         = 1;
            d.IdProducto      = 1;
            d.Unidades        = 1;
            d.Costounidad     = 123;
            d.DescuentoUnidad = 10;
            d.Total           = 113;


            paso = db.Guardar(d);

            Assert.AreEqual(true, paso);
        }
Beispiel #20
0
        public ActionResult PayCart()
        {
            if (Session["Carrito"] == null)
            {
                return(RedirectToAction("Principal"));
            }
            else
            {
                List <OrdenVenta> carritos = Session["Carrito"] as List <OrdenVenta>;
                decimal?          monto    = 0;

                //aqui devería ingresar en base de datos
                //1. La venta
                Ventas v = new Ventas();
                v.Fecha      = DateTime.Now;
                v.Id_cliente = (int)Session["IdUsuario"];
                List <DetalleVentas> list = new List <DetalleVentas>();

                foreach (var item in carritos)
                {
                    //2. Los detalles de la venta
                    DetalleVentas dv = new DetalleVentas();
                    dv.Nombre   = item.Nombre;
                    dv.Precio   = item.Precio;
                    dv.Cantidad = item.Cantidad;
                    dv.Subtotal = item.SubTotal;
                    list.Add(dv);

                    monto = monto + item.SubTotal;
                    Productos p = db.Productos.Find(item.IdProducto);
                    p.Stock          -= item.Cantidad;
                    db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                v.monto         = monto;
                v.DetalleVentas = list;
                db.Ventas.Add(v);
                db.SaveChanges();
                Session["Carrito"] = null;
                return(RedirectToAction("Principal"));
            }
        }
Beispiel #21
0
        private List <DetalleVentas> LlenaClaseDetalles()
        {
            int countData = dataGridViewVentas.RowCount - 1;
            List <DetalleVentas> ArregloVentas = new List <DetalleVentas>();

            int row = 0;

            while (row < countData)
            {
                DetalleVentas Dt = new DetalleVentas();
                Dt.IdProductos = (int)dataGridViewVentas.Rows[row].Cells[0].Value;

                Dt.Cantidad     = int.Parse(dataGridViewVentas.Rows[row].Cells[2].Value.ToString());
                Dt.PrecioVentas = float.Parse(dataGridViewVentas.Rows[row].Cells[4].Value.ToString());

                ArregloVentas.Add(Dt);
                row++;
            }


            return(ArregloVentas);
        }
Beispiel #22
0
        void GuardarCambiosProductos()
        {
            try
            {
                using (var db = new DataContextLocal())
                {
                    var ultimatarea = listaProductos.Last();



                    var consulta  = db.DetalleVentas.Where(q => q.VentaId == ventaId).ToList();
                    var IdDetalle = consulta.LastOrDefault().DetalleVentasId;

                    var CantidadArticulos = int.Parse(ultimatarea.txtPrecio.Text);

                    DetalleVentas detalle = db.DetalleVentas.Find(IdDetalle);

                    detalle.Cantidad  = CantidadArticulos;
                    detalle.Subtotal  = double.Parse(ultimatarea.lblSubTotal.Text);
                    detalle.Descuento = Descuento;

                    try
                    {
                        db.Entry(detalle).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                    }


                    SumatoriaPrecios();
                }
            }
            catch (Exception)
            {
            }
        }
        public IActionResult Post([FromBody] Venta value)
        {
            bool error = false;

            if (value.RCliente == 0 || value.RUsuario == 0 || value.Productos.Count < 1)
            {
                error = true;
            }
            else
            {
                var transaccion = context.Database.BeginTransaction();
                try
                {
                    Ventas venta = new Ventas
                    {
                        RCliente  = value.RCliente,
                        RUsuario  = value.RUsuario,
                        FechaHora = value.FechaHora
                    };
                    context.Ventas.Add(venta);

                    context.SaveChanges();

                    Ventas id_venta = (from vent in context.Ventas
                                       orderby vent.IdVentas descending
                                       select vent).FirstOrDefault <Ventas>();

                    foreach (DetalleVenta detalleVenta in value.Productos)
                    {
                        if (string.IsNullOrWhiteSpace(detalleVenta.RProducto))
                        {
                            Productos servicio = (from pro in context.Productos
                                                  orderby pro.IdProductos descending
                                                  where pro.Nombre == detalleVenta.RProductoNombre && pro.PrecioVenta == detalleVenta.Precio
                                                  select pro).FirstOrDefault <Productos>();

                            if (servicio == null)
                            {
                                Productos producto = (from pro in context.Productos
                                                      orderby pro.IdProductos descending
                                                      where pro.IdProductos.Length < 4
                                                      select pro).FirstOrDefault <Productos>();
                                int id;
                                if (producto == null)
                                {
                                    id = 1;
                                }
                                else
                                {
                                    id = Int32.Parse(producto.IdProductos) + 1;
                                }
                                //Nuevo Servicio
                                servicio = new Productos
                                {
                                    IdProductos = id.ToString(),
                                    Nombre      = WebUtility.HtmlEncode(detalleVenta.RProductoNombre),
                                    PrecioVenta = detalleVenta.Precio
                                };

                                context.Productos.Add(servicio);
                                context.SaveChanges();
                            }


                            DetalleVentas detalleVentas = new DetalleVentas()
                            {
                                RProducto = servicio.IdProductos,
                                RVenta    = id_venta.IdVentas,
                                Cantidad  = detalleVenta.Cantidad
                            };

                            context.DetalleVentas.Add(detalleVentas);
                            context.SaveChanges();
                        }
                        else
                        {
                            if (detalleVenta.RProducto.Length > 4)
                            {
                                Productos productos = (from pro in context.Productos
                                                       where pro.IdProductos == detalleVenta.RProducto
                                                       select pro).FirstOrDefault <Productos>();

                                int invt = (int)(productos.Cantidad - detalleVenta.Cantidad);
                                if (invt < 0)
                                {
                                    transaccion.Dispose();
                                    return(new JsonResult(new { Status = "Fail" }));
                                }
                                productos.Cantidad = invt;
                                context.SaveChanges();
                            }

                            DetalleVentas nueva_detalleVentas = new DetalleVentas
                            {
                                RProducto = detalleVenta.RProducto,
                                RVenta    = id_venta.IdVentas,
                                Cantidad  = detalleVenta.Cantidad
                            };

                            context.DetalleVentas.Add(nueva_detalleVentas);
                            context.SaveChanges();
                        }
                    }

                    context.SaveChanges();
                    transaccion.Commit();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error ocurrido.");
                    Console.WriteLine(ex.Message);
                    error = true;
                }
                transaccion.Dispose();
            }

            var Result = new { Status = !error ? "Success" : "Fail" };

            return(new JsonResult(Result));
        }
Beispiel #24
0
        public void CargarPanelProductos(int aiProducto, string NombreProducto, double PrecioProducto)
        {
            try
            {
                var id        = aiProducto;
                var productos = db.Productos.Where(q => q.ProductoId == id).ToList();
                listaProductos = new List <OrdenDetalleViewModel>();
                var Colores = true;
                foreach (var item in productos)
                {
                    var panelViewProductos = new OrdenDetalleViewModel(string.Empty, string.Empty, 0);



                    panelViewProductos.panelTarea.Size        = new Size(897, 45);
                    panelViewProductos.panelTarea.MouseEnter += new EventHandler(Mouseovertabla);
                    panelViewProductos.panelTarea.MouseLeave += new EventHandler(Mouseleavetabla);
                    panelViewProductos.panelTarea.Name        = item.CodigoId.ToString();

                    if (Colores == true)
                    {
                        panelViewProductos.panelTarea.BackColor = Color.White;
                        Colores = false;
                    }
                    else
                    {
                        panelViewProductos.panelTarea.BackColor = Color.WhiteSmoke;
                        Colores = true;
                    }



                    panelViewProductos.lblTarea.Text = item.Nombre.ToString();

                    panelViewProductos.lblTarea.Location = new Point(0, 0);

                    panelViewProductos.lblTarea.Size = new Size(90, 45);



                    panelViewProductos.txtPrecio.Text = "1";

                    panelViewProductos.txtPrecio.KeyPress += new KeyPressEventHandler(ClickPrecioneTecla);
                    panelViewProductos.txtPrecio.Location  = new Point(115, 0);

                    panelViewProductos.txtPrecio.Size = new System.Drawing.Size(100, 34);


                    panelViewProductos.lblPrecio.Text = item.PrecioVenta.ToString();

                    panelViewProductos.lblPrecio.Location = new Point(230, 0);



                    panelViewProductos.cmbDescuentos.Name                  = item.ProductoId.ToString();
                    panelViewProductos.cmbDescuentos.DataSource            = db.Ofertas.ToList();
                    panelViewProductos.cmbDescuentos.DisplayMember         = "Descripcion";
                    panelViewProductos.cmbDescuentos.ValueMember           = "OfertaId";
                    panelViewProductos.cmbDescuentos.SelectedIndexChanged += new EventHandler(ClickDescuento);

                    panelViewProductos.cmbDescuentos.Location = new Point(325, 0);


                    panelViewProductos.lblSubTotal.Text = item.PrecioVenta.ToString();

                    panelViewProductos.lblSubTotal.Location = new Point(452, 0);



                    panelViewProductos.panelTarea.Controls.Add(panelViewProductos.lblTarea);
                    panelViewProductos.panelTarea.Controls.Add(panelViewProductos.txtPrecio);
                    panelViewProductos.panelTarea.Controls.Add(panelViewProductos.cmbDescuentos);
                    panelViewProductos.panelTarea.Controls.Add(panelViewProductos.lblPrecio);

                    panelViewProductos.panelTarea.Controls.Add(panelViewProductos.lblSubTotal);

                    listaProductos.Add(panelViewProductos);
                    rowCount         += 1;
                    tbpDatos.RowCount = rowCount;
                    this.tbpDatos.Controls.Add(listaProductos.Last().panelTarea, 0, rowCount);

                    var ultimatarea       = listaProductos.Last();
                    var CantidadArticulos = int.Parse(ultimatarea.txtPrecio.Text);

                    var detalleVenta = new DetalleVentas {
                        Precio = double.Parse(ultimatarea.lblPrecio.Text), Cantidad = CantidadArticulos, Descuento = Descuento, Subtotal = double.Parse(ultimatarea.lblSubTotal.Text), CodigoId = aiProducto, VentaId = ventaId
                    };
                    db.DetalleVentas.Add(detalleVenta);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
            }
        }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                DetalleVentas ds = new DetalleVentas();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "DetalleVentasDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }