public void AgregarDetalleServicio()
        {
            Evaluador ev = new Evaluador();
            int nuevo = 1;

            List<DetalleVentaServicio> aux = new List<DetalleVentaServicio>();
            foreach (DetalleVentaServicio item in LstVentaServicios)
            {
                if (item.IdServicio == serv.IdServicio)
                {
                    nuevo = 0;
                }
                aux.Add(item);
            }

            if (nuevo == 1)
            {
                DetalleVentaServicio dv = new DetalleVentaServicio();
                ServicioxProductoSQL sxpsql = new ServicioxProductoSQL();
                dv.Servicio = sxpsql.ServiciobyId(serv.IdServicio);
                dv.IdProducto = serv.Producto.IdProducto;
                dv.IdServicio = serv.IdServicio;
                dv.Descripcion = dv.Servicio.Descripcion;
                dv.Precio = serv.Precio;

                aux.Add(dv);

                total += Math.Round(dv.Precio, 2);
                TxtTotal = total.ToString();
                subt = Math.Round(total / (1 + IGV), 2);
                TxtSubTotal = subt.ToString();
                igv_total = Math.Round((subt) * IGV, 2);
                TxtIGVTotal = igv_total.ToString();
                TxtPagaCon = txtPagaCon;
            }
            LstVentaServicios = aux;
            TxtServicio = "";
        }
示例#2
0
        public object Buscar(params object[] filters)
        {
            List<Servicio> lstServicio = new List<Servicio>();
            DBConexion db = new DBConexion();
            SqlDataReader reader;

            String where = "";
            string codProducto = "";

            if (filters.Length > 0 && filters.Length <= 3)
            {

                string proveedor = Convert.ToString(filters[0]);
                string nombre = Convert.ToString(filters[1]);
                codProducto = Convert.ToString(filters[2]);

                if (proveedor != "")
                {
                    int idProveedor = getIDfromProv(proveedor);
                    where += " and idProveedor = '" + idProveedor.ToString() + "' ";
                }

                if (nombre != "")
                {
                    where += " and nombre LIKE  '%" + nombre + "%' ";
                }

            }

            db.cmd.CommandText = "SELECT * FROM Servicio WHERE  estado = 1   " + where;
            db.cmd.CommandType = CommandType.Text;
            db.cmd.Connection = db.conn;

            try
            {
                db.conn.Open();

                reader = db.cmd.ExecuteReader();

                while (reader.Read())
                {

                    Servicio s = new Servicio();

                    s.IdServicio = Convert.ToInt32(reader["idServicio"].ToString());
                    s.IdProveedor = Convert.ToInt32(reader["idProveedor"].ToString());
                    s.CodServicio = reader["codServicio"].ToString();
                    s.Nombre = reader["nombre"].ToString();
                    s.Descripcion = reader["descripcion"].ToString();

                    if (codProducto != "")
                    {
                        ServicioxProductoSQL spSQL = new ServicioxProductoSQL();
                        Producto p = new ProductoSQL().Buscar_por_CodigoProducto(codProducto);

                        if (p != null)
                        {
                            //MessageBox.Show("idServ = " + s.IdServicio + " IdProd = " + p.IdProducto);
                            if (spSQL.productoPertenece(s.IdServicio, p.IdProducto) == true)
                                lstServicio.Add(s);
                        }
                    }

                    else
                        lstServicio.Add(s);
                }

                db.conn.Close();

            }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace.ToString());
            }

            return lstServicio;
        }