예제 #1
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     MyEntityModel.RajoteroDbContext dbContext = new MyEntityModel.RajoteroDbContext();
     var categorias = dbContext.ps_category.ToList();
 }
예제 #2
0
        private void LoadSource()
        {
            var    dataContextArticulos = new MyEntityModel.ApplicationDbContextSql();
            string were  = " Select * from Articulos where ArticuloID > 0 ";
            string lista = "";
            var    dataContextRajotero  = new MyEntityModel.RajoteroDbContext();
            var    dataContextRepuestos = new MyEntityModel.RepuestosDeMovilesDbContext();

            if (radioGroupRajotero.SelectedIndex != 0)
            {
                var a = dataContextRajotero.ps_product.Where(w => w.reference.Trim() != "").Select(s => s.reference.Trim()).ToList();
                lista = "'" + String.Join("','", a) + "'";
            }
            if (radioGroupRajotero.SelectedIndex == 1)  // Publicados en rajotero
            {
                were += " and Codigo in  (" + lista + ") ";
            }
            if (radioGroupRajotero.SelectedIndex == 2)  // Sin Publicar en rajotero
            {
                were += " and Codigo not in  (" + lista + ") ";
            }
            if (radioGroupEscandallo.SelectedIndex == 1)  // Con Escandallo
            {
                were += " and ArticuloID in (Select ArticuloID from Escandallo) ";
            }
            if (radioGroupEscandallo.SelectedIndex == 2) // Sin Escandallo
            {
                were += " and ArticuloID not in (Select ArticuloID from Escandallo) ";
            }
            if (radioGroupActivos.SelectedIndex == 1)
            {
                were += " and Activo = 1 ";
            }
            if (radioGroupActivos.SelectedIndex == 2)
            {
                were += " and Activo = 0 ";
            }

            foreach (DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit in layoutControlCuentas.Controls.OfType <DevExpress.XtraEditors.ComboBoxEdit>())
            {
                if (comboBoxEdit.Name.Contains("Ebay"))
                {
                    string cuenta = comboBoxEdit.Name.Split(' ')[1];
                    if (comboBoxEdit.Text != "Todos")
                    {
                        List <string> codigos = dataContextRepuestos.EBAY_SEGUIMIENTO.Where(w => w.VENDEDOR == cuenta).Select(s => s.ARTICULO_MIO.Trim()).ToList();
                        lista = "'" + String.Join("','", codigos) + "'";
                        if (comboBoxEdit.Text == "Publicados")
                        {
                            were += " and Codigo in (" + lista + ") ";
                        }

                        if (comboBoxEdit.Text == "Sin publicar")
                        {
                            were += " and Codigo not in (" + lista + ") ";
                        }
                    }
                }
            }


            if (textEditDelEnvio.Text.Trim() != "")
            {
                int NumeroEnvio = 0;
                try
                {
                    NumeroEnvio = Convert.ToInt16(textEditDelEnvio.Text);
                }
                catch
                { }
                if (NumeroEnvio != 0)
                {
                    MyEntityModel.RepuestosDeMovilesDbContext dbContextRepuestos = new MyEntityModel.RepuestosDeMovilesDbContext();
                    var    a          = dbContextRepuestos.L_ENVIOS.Where(w => w.CABECERA == NumeroEnvio).Select(s => s.ARTICULO).ToList();
                    string listaEnvio = "'" + String.Join("','", a) + "'";
                    if (listaEnvio.Trim() != "")
                    {
                        were += " and Codigo in  (" + listaEnvio + ") ";
                    }
                    colUnidadesRecibidas.Visible = true;
                }
                else
                {
                    colUnidadesRecibidas.Visible = false;
                }
            }
            var palabras = textEditPalabras.Text.Split(' ');

            foreach (string palabra in palabras)
            {
                if (palabra.FirstOrDefault() == '-')
                {
                    var p = palabra.Remove(0, 1);
                    were += " AND nombre not like '%" + p + "%' ";
                }
                else
                {
                    were += " AND nombre like '%" + palabra + "%' ";
                }
            }
            IList <MyEntityModel.Articulo> articulos = dataContextArticulos.Database.SqlQuery <MyEntityModel.Articulo>(were).ToList();

            gridControlArticulos.DataSource = articulos;
            layoutControlGroupFiltros.Text  = "Articulos Encontrados " + articulos.Count.ToString();
        }