Exemplo n.º 1
0
        private void gridViewEbay_Click(object sender, EventArgs e)
        {
            GridView view             = gridViewEbay;
            int      currentRowHandle = view.FocusedRowHandle;

            MyEntityModel.EBAY_SEGUIMIENTO            row       = (MyEntityModel.EBAY_SEGUIMIENTO)view.GetRow(currentRowHandle);
            MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
            List <EBAY_SEGUIMIENTO> articulos = dbContext.EBAY_SEGUIMIENTO.Where(w => w.CODIGO.Trim() == row.ARTICULO_MIO).ToList();

            codigoActual = row.ARTICULO_MIO.Trim();
            gridControlEbaycompetencia.DataSource = articulos;
            if (!LayoutControlEbaycompetenciaCargada)
            {
                if (File.Exists("Layouts\\EbayUserControl\\gridViewEbaycompetencia.xml"))
                {
                    gridViewEbaycompetencia.RestoreLayoutFromXml("Layouts\\EbayUserControl\\gridViewEbaycompetencia.xml");
                }
                LayoutControlEbaycompetenciaCargada = true;
            }

            if (layoutControlGroupImagenes.Visible)
            {
                //              PintarImagenesEbay(row);
                //              new Thread(new ThreadStart(PintarImagenesEbay(row))).Start();
                Thread thread = new Thread(() => PintarImagenesEbay(row));
                thread.Start();
            }
            costosEbayUserControl1.articuloEbayID = row.ARTICULO;
        }
Exemplo n.º 2
0
        public static string fnNombreCategoria(long categoria)
        {
            string nombre = "";
            RepuestosDeMovilesDbContext dbcontext       = new RepuestosDeMovilesDbContext();
            EBAY_CATEGORIAS             ebay_categorias = dbcontext.EBAY_CATEGORIAS.Where(w => w.CategoryID == categoria).FirstOrDefault();

            if (ebay_categorias == null)
            {
                Debug.WriteLine("No encuentro la categoria");
                return("");
            }
            nombre = ebay_categorias.CategoryName;
            while (ebay_categorias.CategoryLevel > 1)
            {
                ebay_categorias = dbcontext.EBAY_CATEGORIAS.Where(w => w.CategoryID == ebay_categorias.CategoryParentID).FirstOrDefault();
                if (ebay_categorias == null)
                {
                    Debug.WriteLine("No encuentro la categoria padre");
                    return("");
                }
                nombre += "->" + ebay_categorias.CategoryName;
            }

            return(nombre);
        }
Exemplo n.º 3
0
        private void PintarImagenesEbay(MyEntityModel.EBAY_SEGUIMIENTO row)
        {
            MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
            dbContext.LeerArticuloEbay(row.ARTICULO, row.VENDEDOR, row.ARTICULO_MIO, row.CODIGO);
            EBAY_SEGUIMIENTO ebay          = dbContext.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == row.ARTICULO).FirstOrDefault();
            List <string>    ListaImagenes = new List <string>();

            imageSliderEbay.Images.Clear();
            ListaImagenes.Clear();

            if (ebay.PictureURL != null)
            {
                string[] URLs = ebay.PictureURL.Split('\t');

                foreach (string url in URLs)
                {
                    Uri    uri = new Uri(url);
                    string fil = uri.Segments[5];
                    fil = fil.Remove(fil.Length - 1);
                    fil = fil + ".jpg";
                    var directorio = string.Format(".\\{0}\\{1}\\{2}\\{3}", fil[0], fil[1], fil[2], fil[3]);
                    Directory.CreateDirectory(directorio);
                    fil = directorio + "\\" + fil;
                    if (!System.IO.File.Exists(fil))
                    {
                        WebClient webClient = new WebClient();
                        webClient.DownloadFile(url, fil);
                    }
                    imageSliderEbay.Images.Add(Image.FromFile(fil));
                }
            }
        }
Exemplo n.º 4
0
        public static void fnAnadirCompetenciaSeguimiento(ItemType item, string codigoActual)
        {
            EBAY_SEGUIMIENTO ebay_seguimiento = new EBAY_SEGUIMIENTO();

            fnCopiarArticuloEbaySeguimiento(item, ebay_seguimiento);
            ebay_seguimiento.CODIGO = codigoActual;
            RepuestosDeMovilesDbContext dbcontext = new RepuestosDeMovilesDbContext();

            dbcontext.EBAY_SEGUIMIENTO.Add(ebay_seguimiento);
            dbcontext.SaveChanges();
        }
Exemplo n.º 5
0
        public static decimal fnCostoEnvio(int peso, string nombre)
        {
            decimal costo = 0;
            string  sql   = "Select id from COSTOS_ENVIOS_NOMBRES where nombres like '%" + nombre + "%'";
            RepuestosDeMovilesDbContext dbContext = new RepuestosDeMovilesDbContext();
            int id = dbContext.Database.SqlQuery <int>(sql).FirstOrDefault();

            if (id > 0)
            {
                sql   = "Select precio from COSTOS_ENVIOS_PESOS where " + peso.ToString() + " >= peso_inicial  and peso_final >= " + peso.ToString() + " and id_nombre = " + id.ToString();
                costo = dbContext.Database.SqlQuery <decimal>(sql).FirstOrDefault();
            }
            return(costo);
        }
Exemplo n.º 6
0
        public void Cargar(string codigo)
        {
            MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
            List <string> ListaCodigos = FuncionesEbay.fnListaCodigos(codigo);
            string        CadenaIn     = "";

            foreach (var c in ListaCodigos)
            {
                CadenaIn += "'" + c + "'";
            }
            CadenaIn = CadenaIn.Replace("''", "','");

            string sql = string.Format("Select * from EBAY_SEGUIMIENTO where (articulo_mio in ({0}) or codigo in ({0})) and vendedor in ({1})", CadenaIn, Global.CuentasEbaySQL);
            var    a   = dbContext.Database.SqlQuery <MyEntityModel.EBAY_SEGUIMIENTO>(sql).ToList();

            gridControlEbay.Invoke((MethodInvoker)(() => gridControlEbay.DataSource = a));
            costosEbayUserControl1.articuloEbayID = "";
        }
Exemplo n.º 7
0
        private void checkEditNoDisponibles_CheckedChanged(object sender, EventArgs e)
        {
            checkEditNoDisponibles.Enabled = false;
            WaitForm1 fr = new WaitForm1();

            fr.Show();
            DevExpress.XtraEditors.ProgressBarControl pb = (DevExpress.XtraEditors.ProgressBarControl)fr.Controls.Find("progressBarControl1", true)[0];
            pb.Properties.Maximum = gridViewArticulos.DataRowCount;
            if (checkEditNoDisponibles.Checked)
            {
                int i;
                simpleButtonLeerEbayTodos.Enabled = false;
                List <string> ListaTodosCodigos = new List <string>();
                List <string> ListaArticulos    = new List <string>();
                MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
                for (i = 0; i < gridViewArticulos.DataRowCount; i++)
                {
                    pb.Text = i.ToString();
                    Application.DoEvents();
                    string        codigo       = (string)gridViewArticulos.GetRowCellValue(i, "Codigo");
                    List <string> ListaCodigos = FuncionesEbay.fnListaCodigos(codigo);
                    string        CadenaIn     = "";
                    foreach (var c in ListaCodigos)
                    {
                        CadenaIn += "'" + c + "'";
                    }
                    CadenaIn = CadenaIn.Replace("''", "','");
                    string sql = string.Format("Select * from EBAY_SEGUIMIENTO where (articulo_mio in ({0}) or codigo in ({0})) and vendedor in ({1}) and (restocking = 'NO' or UNIDADES_DISPONIBLE < 1 )", CadenaIn, Global.CuentasEbaySQL);
                    var    a   = dbContext.Database.SqlQuery <MyEntityModel.EBAY_SEGUIMIENTO>(sql).ToList();
                    foreach (MyEntityModel.EBAY_SEGUIMIENTO b in a)
                    {
                        rowNoDisponibles.Add(i);
                    }
                }
            }
            else
            {
                rowNoDisponibles.Clear();
            }

            gridViewArticulos.LayoutChanged();
            checkEditNoDisponibles.Enabled = true;
            fr.Close();
        }
Exemplo n.º 8
0
        private void simpleButtonLeerEbayTodos_Click(object sender, EventArgs e)
        {
            int i;
            List <CodigoArticulos> codigoArticulos = new List <CodigoArticulos>();

            simpleButtonLeerEbayTodos.Enabled = false;
            List <string> ListaTodosCodigos = new List <string>();
            List <string> ListaArticulos    = new List <string>();

            MyEntityModel.RepuestosDeMovilesDbContext dbContext = new MyEntityModel.RepuestosDeMovilesDbContext();
            for (i = 0; i < gridViewArticulos.DataRowCount; i++)
            {
                string        codigo       = (string)gridViewArticulos.GetRowCellValue(i, "Codigo");
                List <string> ListaCodigos = FuncionesEbay.fnListaCodigos(codigo);
                string        CadenaIn     = "";
                foreach (var c in ListaCodigos)
                {
                    CadenaIn += "'" + c + "'";
                }
                CadenaIn = CadenaIn.Replace("''", "','");
                string sql = string.Format("Select * from EBAY_SEGUIMIENTO where (articulo_mio in ({0}) or codigo in ({0})) and vendedor in ({1})", CadenaIn, Global.CuentasEbaySQL);
                var    a   = dbContext.Database.SqlQuery <MyEntityModel.EBAY_SEGUIMIENTO>(sql).ToList();
                foreach (MyEntityModel.EBAY_SEGUIMIENTO b in a)
                {
                    codigoArticulos.Add(new CodigoArticulos {
                        codigo = codigo, articulo = b.ARTICULO, rowHandle = i
                    });
                }
            }
            codigoArticulos = codigoArticulos.Distinct().ToList();
            gridViewArticulos.ClearSelection();
            Parallel.ForEach(codigoArticulos, new ParallelOptions {
                MaxDegreeOfParallelism = 4
            }, ac =>
            {
                ItemType Item = MyEntityModel.FuncionesEbay.LeerArticuloEbay(ac.articulo);
                if ((Item.Quantity - Item.SellingStatus.QuantitySold) == 0)
                {
                    gridViewArticulos.SelectRow(ac.rowHandle);
                }
            });
            simpleButtonLeerEbayTodos.Enabled = true;
        }
Exemplo n.º 9
0
        public static SiNo fnCategoriaTecnologica(long categoria)
        {
            RepuestosDeMovilesDbContext dbcontext       = new RepuestosDeMovilesDbContext();
            EBAY_CATEGORIAS             ebay_categorias = dbcontext.EBAY_CATEGORIAS.Where(w => w.CategoryID == categoria).FirstOrDefault();

            if (ebay_categorias == null)
            {
                Debug.WriteLine("No encuentro la categoria");
                return(SiNo.No);
            }
            while (ebay_categorias.CategoryLevel > 1)
            {
                ebay_categorias = dbcontext.EBAY_CATEGORIAS.Where(w => w.CategoryID == ebay_categorias.CategoryParentID).FirstOrDefault();
                if (ebay_categorias == null)
                {
                    Debug.WriteLine("No encuentro la categoria padre");
                    return(SiNo.No);
                }
            }
            return(ebay_categorias.Tecnologico);
        }
Exemplo n.º 10
0
        private void gridViewArticulos_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            GridView view = sender as GridView;

            if (e.Column.FieldName == "Stock" && e.IsGetData)
            {
                int comprados = (int)Convert.ToInt64(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "comprados"));
                int vendidos  = (int)Convert.ToInt64(view.GetListSourceRowCellValue(e.ListSourceRowIndex, "Vendidos"));
                if (view.GetListSourceRowCellValue(e.ListSourceRowIndex, "Codigo").ToString().Trim() == "3161")
                {
                    e.Value = "A";
                }
                e.Value = comprados - vendidos;
            }
            if (e.Column.FieldName == "UnidadesRecibidas" && e.IsGetData)
            {
                int NumeroEnvio = 0;
                try
                {
                    NumeroEnvio = Convert.ToInt16(textEditDelEnvio.Text);
                }
                catch
                { }
                if (NumeroEnvio == 0)
                {
                    return;
                }
                MyEntityModel.RepuestosDeMovilesDbContext dbContextRepuestos = new MyEntityModel.RepuestosDeMovilesDbContext();
                string codigo = (string)view.GetListSourceRowCellValue(e.ListSourceRowIndex, "Codigo");

                try
                {
                    var a = dbContextRepuestos.L_ENVIOS.Where(w => w.ARTICULO == codigo && w.CABECERA == NumeroEnvio).Select(s => s.UNIDADES).FirstOrDefault().Value;
                    e.Value = Convert.ToInt16(a);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 11
0
        public static List <ArticulosEnEscandallo> fnArticulosEnEscandalloEbay(string articuloEbayID)
        {
            int articuloID = 0;

            try
            {
                RepuestosDeMovilesDbContext dbContext = new RepuestosDeMovilesDbContext();
                string codigo = dbContext.EBAY_SEGUIMIENTO.Where(w => w.ARTICULO == articuloEbayID).FirstOrDefault().ARTICULO_MIO.Trim();
                ApplicationDbContextSql dbContextSQL = new ApplicationDbContextSql();
                articuloID = dbContextSQL.Articulos.Where(w => w.Codigo == codigo).FirstOrDefault().ArticuloID;
            }
            catch
            { }
            if (articuloID > 0)
            {
                return(fnArticulosEnEscandallo(articuloID));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 12
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();
        }