public agregarServicioViewModel(IWindowManager windowmanager, Servicio s, BuscadorServicioViewModel m)
        {
            _windowManager = windowmanager;
            //Servicio para editar del buscador
            txtCodigo = s.CodServicio;
            txtNombre = s.Nombre;
            txtProveedor = DataObjects.Compras.ServicioSQL.getCODfromProv(s.IdProveedor);
            txtDescripcion = s.Descripcion;

            LstProducto = sp.Buscar(s.IdServicio) as List<ServicioxProducto>;

            indicador = 2;
            model = m;
        }
        public reportViewerServicios()
        {
            InitializeComponent();

            FechaDesde.Text = "01/01/" + DateTime.Today.Year;
            FechaHasta.Text = "31/12/" + DateTime.Today.Year;
            List<Servicio> lstServicio = DataObjects.Reportes.reporteServiciosSQL.BuscarServicio();
            Servicio ser = new Servicio();
            ser.Nombre = "TODOS";
            lstServicio.Add(ser);
            cmbServicio.ItemsSource = lstServicio;
            List<Cliente> lstCliente = DataObjects.Reportes.ReporteVentasSQL.BuscarCliente();
            cmbCliente.ItemsSource = lstCliente;
            List<Tienda> lstTienda = DataObjects.Reportes.ReporteVentasSQL.BuscarTienda();
            cmbTienda.ItemsSource = lstTienda;

            cmbTienda.SelectedIndex = 0;
            cmbCliente.SelectedIndex = 0;

            cmbServicio.SelectedIndex = cmbServicio.Items.Count-1;

            PrepareReport();
        }
Пример #3
0
        public static List<Servicio> BuscarServicio()
        {
            List<Servicio> lstServicio = new List<Servicio>();
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.inf245g4ConnectionString);
            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT nombre FROM Servicio order by 1";
            cmd.CommandType = CommandType.Text;
            cmd.Connection = conn;

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Servicio e = new Servicio();
                    e.Nombre = reader["nombre"].ToString();
                    lstServicio.Add(e);
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace.ToString());
            }

            return lstServicio;
        }
Пример #4
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;
        }
 //Funciones de la clase
 public void SelectedItemChanged(object sender)
 {
     servicioSeleccionado = ((sender as DataGrid).SelectedItem as Servicio);
 }
        public agregarServicioViewModel(IWindowManager windowmanager, Servicio s, BuscadorServicioViewModel m, Ventas.VentaRegistrarViewModel ventaRegistrarViewModel, int ventanaAccion)
        {
            _windowManager = windowmanager;
            // TODO: Complete member initialization
            this.servicioSeleccionado = s;
            this.buscadorServicioViewModel = m;
            this.ventaRegistrarViewModel = ventaRegistrarViewModel;
            this.ventanaAccion = ventanaAccion;

            //Servicio para editar del buscador
            txtCodigo = s.CodServicio;
            txtNombre = s.Nombre;
            txtProveedor = DataObjects.Compras.ServicioSQL.getCODfromProv(s.IdProveedor);
            txtDescripcion = s.Descripcion;

            LstProducto = sp.Buscar(s.IdServicio) as List<ServicioxProducto>;

            indicador = 2;
            model = m;
        }
        public void GuardarServicio()
        {
            int k, y, i;
            Servicio s = new Servicio();

            s.IdProveedor = Prov.IdProveedor;
            s.Nombre = TxtNombre;
            s.Descripcion = TxtDescripcion;
            s.CodServicio = TxtCodigo;

            if (validar(s) == true)
            {

                if (indicador == 1)
                {
                    k = new ServicioSQL().Agregar(s);
                    Id = usql.ObtenerMaximoID("Servicio", "idServicio");

                    if (Id == 0) Id = 1;

                    if (LstProducto != null)
                    {
                        for (i = 0; i < LstProducto.Count; i++)
                        {
                            LstProducto[i].IdServicio = Id;
                            y = sp.InsertarValidado(LstProducto[i]);
                        }
                    }

                    if (k == 0)
                        _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Ocurrio un error"));
                    else
                        _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Servicio Registrado \n\nCodigo = " + txtCodigo + "\nNombre = " + txtNombre +
                                        "\nProveedor = " + txtProveedor + "\nDescripcion = " + txtDescripcion));
                }

                if (indicador == 2)
                {

                    k = new ServicioSQL().Actualizar(s);

                    if (k == 0)
                        _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Ocurrio un error"));
                    else
                        _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Servicio Editado \n\nCodigo = " + txtCodigo + "\nNombre = " + txtNombre +
                                        "\nProveedor = " + txtProveedor + "\nDescripcion = " + txtDescripcion));
                }

                if (model != null)
                    model.ActualizarServicio();
            }
        }