Пример #1
0
 private void insertListaModulos(int id, string clave, string articulo, string linea, string clave_vidrio, string id_aluminio, string id_herrajes, string id_otros, int secciones, string descripcion, string usuario, int id_diseño, bool cs, string parametros, string reglas, bool privado)
 {
     listas = new listas_entities_pva();
     try
     {
         var k = new modulo()
         {
             id           = id,
             clave        = clave,
             articulo     = articulo,
             linea        = linea,
             clave_vidrio = clave_vidrio,
             id_aluminio  = id_aluminio,
             id_herraje   = id_herrajes,
             id_otros     = id_otros,
             secciones    = secciones,
             descripcion  = descripcion,
             usuario      = usuario,
             id_diseño    = id_diseño,
             cs           = cs,
             parametros   = parametros,
             reglas       = reglas,
             privado      = privado
         };
         listas.modulos.Add(k);
         listas.SaveChanges();
     }
     catch (Exception err)
     {
         constants.errorLog(err.ToString());
     }
 }
Пример #2
0
        //

        //Cargar esquemas inherentes
        private void cargarEsquemasInherentes()
        {
            cotizaciones_local cotizaciones = new cotizaciones_local();

            var modulo_c = (from x in cotizaciones.modulos_cotizaciones where x.merge_id == id select x);

            if (modulo_c != null)
            {
                foreach (var n in modulo_c)
                {
                    listas_entities_pva listas = new listas_entities_pva();
                    int modulo_id = (int)n.modulo_id;
                    var modulo    = (from x in listas.modulos where x.id == modulo_id select x).SingleOrDefault();
                    if (modulo != null)
                    {
                        int id_diseño = (int)modulo.id_diseño;
                        var diseño    = (from x in listas.esquemas where x.id == id_diseño select x).SingleOrDefault();
                        if (diseño != null)
                        {
                            string[] e = diseño.esquemas.ToString().Split(',');
                            foreach (string v in e)
                            {
                                if (v != "")
                                {
                                    treeView2.Nodes[0].Nodes.Add(v);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        //

        //optimizador de tabla local
        public void optimizeLocalDataBase()
        {
            listas = new listas_entities_pva();
            try
            {
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE lista_costo_corte_e_instalado");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE lista_precio_corte_e_instalado");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE lista_precios_hojas");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE acabados");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE perfiles");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE herrajes");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE otros");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE modulos");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE esquemas");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE categorias");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE proveedores");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE lineas_modulos");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE colores_aluminio");
                listas.Database.ExecuteSqlCommand("TRUNCATE TABLE paquetes");
            }
            catch (Exception err)
            {
                constants.errorLog(err.ToString());
            }
        }
Пример #4
0
        private void insertListaOtros(int id, string clave, string articulo, string proveedor, string linea, string caracteristicas, string color, float largo, float alto, float precio, string moneda)
        {
            listas = new listas_entities_pva();
            float tc = constants.tc;

            try
            {
                if (moneda != "MXN")
                {
                    var k = new otro()
                    {
                        id              = id,
                        clave           = clave,
                        articulo        = articulo,
                        proveedor       = proveedor,
                        linea           = linea,
                        caracteristicas = caracteristicas,
                        color           = color,
                        largo           = largo,
                        alto            = alto,
                        precio          = Math.Round(precio * tc, 2),
                        moneda          = moneda
                    };
                    listas.otros.Add(k);
                    listas.SaveChanges();
                }
                else
                {
                    var k = new otro()
                    {
                        id              = id,
                        clave           = clave,
                        articulo        = articulo,
                        proveedor       = proveedor,
                        linea           = linea,
                        caracteristicas = caracteristicas,
                        color           = color,
                        largo           = largo,
                        alto            = alto,
                        precio          = Math.Round(precio, 2),
                        moneda          = moneda
                    };
                    listas.otros.Add(k);
                    listas.SaveChanges();
                }
            }
            catch (Exception err)
            {
                constants.errorLog(err.ToString());
            }
        }
Пример #5
0
        //acabado
        private void loadColoresAluminio()
        {
            listas_entities_pva listas = new listas_entities_pva();

            var colores = from x in listas.colores_aluminio select x;

            if (colores != null)
            {
                comboBox2.Items.Clear();
                foreach (var c in colores)
                {
                    comboBox2.Items.Add(c.clave);
                }
            }
        }
Пример #6
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            listas_entities_pva listas = new listas_entities_pva();
            var paquetes = from x in listas.paquetes where x.comp_clave.Contains(textBox1.Text) || x.comp_articulo.Contains(textBox1.Text) || x.id.ToString().StartsWith(textBox1.Text)
                           orderby x.comp_articulo ascending
                           select new
            {
                Id        = x.id,
                Clave     = x.comp_clave,
                Artículo  = x.comp_articulo,
                Categoría = x.comp_type
            };

            datagridviewNE1.DataSource = null;
            datagridviewNE1.DataSource = paquetes.ToList();
        }
Пример #7
0
        private void loadCristales()
        {
            listas_entities_pva listas = new listas_entities_pva();
            var filter = from x in listas.lista_costo_corte_e_instalado
                         where x.articulo.Contains(comboBox2.Text)
                         orderby x.articulo ascending
                         select new
            {
                Clave          = x.clave,
                Artículo       = x.articulo,
                Proveedor      = x.proveedor,
                Costo_Corte_m2 = "$" + x.costo_corte_m2
            };

            datagridviewNE2.DataSource = null;
            datagridviewNE2.DataSource = filter.ToList();
        }
Пример #8
0
 private void TextBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         listas_entities_pva listas = new listas_entities_pva();
         var paquetes = from x in listas.paquetes
                        orderby x.comp_articulo ascending
                        select new
         {
             Id        = x.id,
             Clave     = x.comp_clave,
             Artículo  = x.comp_articulo,
             Categoría = x.comp_type
         };
         datagridviewNE1.DataSource = null;
         datagridviewNE1.DataSource = paquetes.ToList();
     }
 }
Пример #9
0
        private void insertListaPrecioHojas(string clave, string articulo, float largo, float alto, float precio_hoja, string proveedor, string moneda)
        {
            listas = new listas_entities_pva();
            float tc = constants.tc;

            try
            {
                if (moneda != "MXN")
                {
                    var k = new lista_precios_hojas()
                    {
                        clave       = clave,
                        articulo    = articulo,
                        largo       = Math.Round(largo, 2),
                        alto        = Math.Round(alto, 2),
                        precio_hoja = Math.Round(precio_hoja * tc, 2),
                        proveedor   = proveedor,
                        moneda      = moneda
                    };
                    listas.lista_precios_hojas.Add(k);
                    listas.SaveChanges();
                }
                else
                {
                    var k = new lista_precios_hojas()
                    {
                        clave       = clave,
                        articulo    = articulo,
                        largo       = Math.Round(largo, 2),
                        alto        = Math.Round(alto, 2),
                        precio_hoja = Math.Round(precio_hoja, 2),
                        proveedor   = proveedor,
                        moneda      = moneda
                    };
                    listas.lista_precios_hojas.Add(k);
                    listas.SaveChanges();
                }
            }
            catch (Exception err)
            {
                constants.errorLog(err.ToString());
            }
        }
Пример #10
0
 private void insertListaAcabados(string clave, string acabado, float neto_recto, float neto_curvo)
 {
     listas = new listas_entities_pva();
     try
     {
         var k = new acabado()
         {
             clave      = clave,
             acabado1   = acabado,
             neto_recto = Math.Round(neto_recto, 2),
             neto_curvo = Math.Round(neto_curvo, 2)
         };
         listas.acabados.Add(k);
         listas.SaveChanges();
     }
     catch (Exception err)
     {
         constants.errorLog(err.ToString());
     }
 }
Пример #11
0
        private void insertListaPrecioCorteInstalado(string clave, string articulo, float precio_corte_m2, float precio_instalado, string proveedor, string moneda)
        {
            listas = new listas_entities_pva();
            float tc = constants.tc;

            try
            {
                if (moneda != "MXN")
                {
                    var k = new lista_precio_corte_e_instalado()
                    {
                        clave    = clave,
                        articulo = articulo,
                        precio_venta_corte_m2  = Math.Round(precio_corte_m2 * tc, 2),
                        precio_venta_instalado = Math.Round(precio_instalado * tc, 2),
                        proveedor = proveedor,
                        moneda    = moneda
                    };
                    listas.lista_precio_corte_e_instalado.Add(k);
                    listas.SaveChanges();
                }
                else
                {
                    var k = new lista_precio_corte_e_instalado()
                    {
                        clave    = clave,
                        articulo = articulo,
                        precio_venta_corte_m2  = Math.Round(precio_corte_m2, 2),
                        precio_venta_instalado = Math.Round(precio_instalado, 2),
                        proveedor = proveedor,
                        moneda    = moneda
                    };
                    listas.lista_precio_corte_e_instalado.Add(k);
                    listas.SaveChanges();
                }
            }
            catch (Exception err)
            {
                constants.errorLog(err.ToString());
            }
        }
Пример #12
0
 private void insertPaquetes(int id, string clave, string items, string type, string articulo)
 {
     listas = new listas_entities_pva();
     try
     {
         var k = new paquete()
         {
             id            = id,
             comp_clave    = clave,
             comp_items    = items,
             comp_type     = type,
             comp_articulo = articulo
         };
         listas.paquetes.Add(k);
         listas.SaveChanges();
     }
     catch (Exception err)
     {
         constants.errorLog(err.ToString());
     }
 }
Пример #13
0
 private void insertColoresAluminio(int id, string clave, string color, string proveedor, float precio, float costo_extra)
 {
     listas = new listas_entities_pva();
     try
     {
         var k = new colores_aluminio()
         {
             id             = id,
             clave          = clave,
             color          = color,
             proveedor      = proveedor,
             precio         = Math.Round(precio, 2),
             costo_extra_ml = Math.Round(costo_extra, 2)
         };
         listas.colores_aluminio.Add(k);
         listas.SaveChanges();
     }
     catch (Exception err)
     {
         constants.errorLog(err.ToString());
     }
 }
Пример #14
0
        private void cambiar_imagen_Load(object sender, EventArgs e)
        {
            new sqlDateBaseManager().dropTableOnGridView(datagridviewNE1, "esquemas");
            datagridviewNE1.ClearSelection();
            loadColoresAluminio();

            cotizaciones_local  cotizaciones = new cotizaciones_local();
            listas_entities_pva listas       = new listas_entities_pva();

            var data = (from x in cotizaciones.modulos_cotizaciones where x.id == id select x).SingleOrDefault();

            if (data != null)
            {
                if (data.modulo_id != -2)
                {
                    comboBox2.Enabled = false;
                    acabado           = data.acabado_perfil;
                    if (data.modulo_id >= 0)
                    {
                        int modulo_id = (int)data.modulo_id;
                        var modulo    = (from x in listas.modulos where x.id == modulo_id select x).SingleOrDefault();
                        if (modulo != null)
                        {
                            int diseño_id = (int)modulo.id_diseño;
                            LeerDiseño(diseño_id);
                        }
                    }
                }
                if (data.new_desing != "" && data.new_desing != null)
                {
                    if (constants.stringToInt(data.new_desing) > 0)
                    {
                        desing = constants.stringToInt(data.new_desing);
                        LeerDiseño(desing);
                    }
                }
            }
        }
Пример #15
0
 private void calcular()
 {
     if (comboBox2.Text == "paquetes" || comboBox3.Text == "Cristal")
     {
         string clave = string.Empty;
         float  c     = 0;
         listas_entities_pva listas = new listas_entities_pva();
         foreach (DataGridViewRow x in datagridviewNE2.Rows)
         {
             clave = x.Cells[1].Value.ToString();
             if (x.Cells[0].Value.ToString() == "Cristal")
             {
                 var cristales = (from y in listas.lista_costo_corte_e_instalado where y.clave == clave select y).SingleOrDefault();
                 if (cristales != null)
                 {
                     c = c + ((float)cristales.costo_corte_m2 * constants.stringToFloat(x.Cells[3].Value.ToString()));
                 }
             }
             else if (x.Cells[0].Value.ToString() == "Herraje")
             {
                 var herrajes = (from y in listas.herrajes where y.clave == clave select y).SingleOrDefault();
                 if (herrajes != null)
                 {
                     c = c + ((float)herrajes.precio * constants.stringToFloat(x.Cells[3].Value.ToString()));
                 }
             }
             else if (x.Cells[0].Value.ToString() == "Otros")
             {
                 var otros = (from y in listas.otros where y.clave == clave select y).SingleOrDefault();
                 if (otros != null)
                 {
                     c = c + ((float)otros.precio * constants.stringToFloat(x.Cells[3].Value.ToString()));
                 }
             }
         }
         textBox9.Text = Math.Round(c, 2).ToString();
     }
 }
Пример #16
0
 private void insertEsquemas(int id, string nombre, int filas, int columnas, string diseño, string esquemas, bool marco, string grupo)
 {
     listas = new listas_entities_pva();
     try
     {
         var k = new esquema()
         {
             id       = id,
             nombre   = nombre,
             filas    = filas,
             columnas = columnas,
             diseño   = diseño,
             esquemas = esquemas,
             marco    = marco,
             grupo    = grupo
         };
         listas.esquemas.Add(k);
         listas.SaveChanges();
     }
     catch (Exception err)
     {
         constants.errorLog(err.ToString());
     }
 }
Пример #17
0
        private void load(int id)
        {
            listas_entities_pva listas = new listas_entities_pva();

            datagridviewNE2.Rows.Clear();
            comboBox3.Enabled = false;
            this.id           = id;
            string type     = string.Empty;
            var    paquetes = (from x in listas.paquetes where x.id == id select x).SingleOrDefault();

            if (paquetes != null)
            {
                _clave         = paquetes.comp_clave;
                type           = paquetes.comp_type;
                comboBox3.Text = paquetes.comp_type;

                string[] v     = paquetes.comp_items.Split(',');
                string[] k     = null;
                string   clave = string.Empty;
                foreach (string x in v)
                {
                    k = x.Split(':');
                    if (k.Length == 3)
                    {
                        clave = k[1];
                        dynamic p = null;
                        if (k[0] == "1")
                        {
                            p = (from y in listas.lista_costo_corte_e_instalado where y.clave == clave select y.articulo).SingleOrDefault();
                        }
                        else if (k[0] == "2")
                        {
                            p = (from y in listas.herrajes where y.clave == clave select y.articulo).SingleOrDefault();
                        }
                        else if (k[0] == "3")
                        {
                            p = (from y in listas.otros where y.clave == clave select y.articulo).SingleOrDefault();
                        }
                        if (p != null)
                        {
                            datagridviewNE2.Rows.Add(getComponente(k[0]), clave, p, k[2]);
                        }
                    }
                }
            }

            if (type == "Cristal")
            {
                var cristal = (from x in listas.lista_costo_corte_e_instalado where x.clave == _clave select x).SingleOrDefault();
                if (cristal != null)
                {
                    textBox3.Text  = cristal.clave;
                    textBox2.Text  = cristal.articulo;
                    textBox9.Text  = cristal.costo_corte_m2.ToString();
                    comboBox4.Text = cristal.proveedor;
                }
            }
            else if (type == "Herraje")
            {
                var herrajes = (from x in listas.herrajes where x.clave == _clave select x).SingleOrDefault();
                if (herrajes != null)
                {
                    textBox3.Text     = herrajes.clave;
                    textBox2.Text     = herrajes.articulo;
                    comboBox2.Text    = herrajes.linea;
                    textBox6.Text     = herrajes.color;
                    textBox9.Text     = herrajes.precio.ToString();
                    richTextBox1.Text = herrajes.caracteristicas;
                    comboBox4.Text    = herrajes.proveedor;
                }
            }
            else if (type == "Otros Materiales")
            {
                var otros = (from x in listas.otros where x.clave == _clave select x).SingleOrDefault();
                if (otros != null)
                {
                    textBox3.Text     = otros.clave;
                    textBox2.Text     = otros.articulo;
                    comboBox2.Text    = otros.linea;
                    textBox6.Text     = otros.color;
                    textBox7.Text     = otros.largo.ToString();
                    textBox8.Text     = otros.alto.ToString();
                    textBox9.Text     = otros.precio.ToString();
                    richTextBox1.Text = otros.caracteristicas;
                    comboBox4.Text    = otros.proveedor;
                }
            }
        }
Пример #18
0
        private void loadListas()
        {
            listas_entities_pva listas = new listas_entities_pva();

            switch (comboBox1.SelectedIndex)
            {
            case 0:
                var cristal = from x in listas.lista_costo_corte_e_instalado
                              orderby x.articulo ascending
                              select new
                {
                    Clave           = x.clave,
                    Artículo        = x.articulo,
                    Proveedor       = x.proveedor,
                    Costo_Corte_m2  = "$" + x.costo_corte_m2,
                    Costo_Instalado = "$" + x.costo_instalado
                };
                if (datagridviewNE3.InvokeRequired == true)
                {
                    datagridviewNE3.Invoke((MethodInvoker) delegate
                    {
                        datagridviewNE3.DataSource = null;
                        datagridviewNE3.DataSource = cristal.ToList();
                    });
                }
                else
                {
                    datagridviewNE3.DataSource = null;
                    datagridviewNE3.DataSource = cristal.ToList();
                }
                break;

            case 1:
                var herraje = from x in listas.herrajes
                              orderby x.articulo ascending
                              select new
                {
                    Id              = x.id,
                    Clave           = x.clave,
                    Artículo        = x.articulo,
                    Linea           = x.linea,
                    Proveedor       = x.proveedor,
                    Caracteristicas = x.caracteristicas,
                    Color           = x.color,
                    Precio          = "$" + x.precio
                };
                if (datagridviewNE3.InvokeRequired == true)
                {
                    datagridviewNE3.Invoke((MethodInvoker) delegate
                    {
                        datagridviewNE3.DataSource = null;
                        datagridviewNE3.DataSource = herraje.ToList();
                    });
                }
                else
                {
                    datagridviewNE3.DataSource = null;
                    datagridviewNE3.DataSource = herraje.ToList();
                }
                break;

            case 2:
                var data = from x in listas.otros
                           orderby x.articulo ascending
                           select new
                {
                    Id              = x.id,
                    Clave           = x.clave,
                    Artículo        = x.articulo,
                    Linea           = x.linea,
                    Proveedor       = x.proveedor,
                    Caracteristicas = x.caracteristicas,
                    Color           = x.color,
                    Precio          = "$" + x.precio
                };
                if (datagridviewNE3.InvokeRequired == true)
                {
                    datagridviewNE3.Invoke((MethodInvoker) delegate
                    {
                        datagridviewNE3.DataSource = null;
                        datagridviewNE3.DataSource = data.ToList();
                    });
                }
                else
                {
                    datagridviewNE3.DataSource = null;
                    datagridviewNE3.DataSource = data.ToList();
                }
                break;

            default:
                break;
            }
        }
Пример #19
0
        //Leer diseño
        private void LeerDiseño(int id_diseño)
        {
            listas_entities_pva listas = new listas_entities_pva();
            var diseño = (from x in listas.esquemas where x.id == id_diseño select x).SingleOrDefault();

            if (diseño != null)
            {
                tableLayoutPanel1.Controls.Clear();
                label1.Text = diseño.id + "-" + diseño.nombre;
                getEsquemasFromDiseño(diseño.esquemas);
                tableLayoutPanel1.RowCount    = (int)diseño.filas;
                tableLayoutPanel1.ColumnCount = (int)diseño.columnas;
                label3.Text = "Diseño: (" + diseño.diseño + ")";
                foreach (string e in esquemas)
                {
                    if (File.Exists(constants.folder_resources_dir + "esquemas\\corredizas\\" + e + ".png"))
                    {
                        constants.loadDiseño("esquemas\\corredizas\\", e, tableLayoutPanel1);
                    }
                    else if (File.Exists(constants.folder_resources_dir + "esquemas\\puertas\\" + e + ".png"))
                    {
                        constants.loadDiseño("esquemas\\puertas\\", e, tableLayoutPanel1);
                    }
                    else if (File.Exists(constants.folder_resources_dir + "esquemas\\ventanas_abatibles\\" + e + ".png"))
                    {
                        constants.loadDiseño("esquemas\\ventanas_abatibles\\", e, tableLayoutPanel1);
                    }
                    else if (File.Exists(constants.folder_resources_dir + "esquemas\\ventanas_fijas\\" + e + ".png"))
                    {
                        constants.loadDiseño("esquemas\\ventanas_fijas\\", e, tableLayoutPanel1);
                    }
                    else if (File.Exists(constants.folder_resources_dir + "esquemas\\templados\\" + e + ".png"))
                    {
                        constants.loadDiseño("esquemas\\templados\\", e, tableLayoutPanel1);
                    }
                    else if (File.Exists(constants.folder_resources_dir + "esquemas\\otros\\" + e + ".png"))
                    {
                        constants.loadDiseño("esquemas\\otros\\", e, tableLayoutPanel1);
                    }
                }
                if (diseño.marco == true)
                {
                    if (diseño.grupo == "puerta")
                    {
                        tableLayoutPanel1.Padding = new Padding(10, 10, 10, 0);
                    }
                    else
                    {
                        tableLayoutPanel1.Padding = new Padding(10, 10, 10, 10);
                    }
                }
                else
                {
                    tableLayoutPanel1.Padding = new Padding(0, 0, 0, 0);
                }
                tableLayoutPanel1.RowStyles.Clear();
                for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
                {
                    tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / tableLayoutPanel1.RowCount));
                }
                tableLayoutPanel1.ColumnStyles.Clear();
                for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++)
                {
                    ColumnStyle sty = new ColumnStyle(SizeType.Percent, 100 / tableLayoutPanel1.ColumnCount);
                    tableLayoutPanel1.ColumnStyles.Add(sty);
                }
                checkAcabado(acabado);
            }
        }
Пример #20
0
        private void TextBox10_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                listas_entities_pva listas = new listas_entities_pva();
                switch (comboBox1.SelectedIndex)
                {
                case 0:
                    var costo_corte = from x in listas.lista_costo_corte_e_instalado
                                      where x.articulo.Contains(textBox10.Text) || x.clave.Contains(textBox10.Text)
                                      orderby x.articulo ascending
                                      select new
                    {
                        Clave           = x.clave,
                        Artículo        = x.articulo,
                        Proveedor       = x.proveedor,
                        Costo_Corte_m2  = "$" + x.costo_corte_m2,
                        Costo_Instalado = "$" + x.costo_instalado
                    };
                    datagridviewNE3.DataSource = null;
                    datagridviewNE3.DataSource = costo_corte.ToList();
                    break;

                case 1:
                    var herrajes = from x in listas.herrajes
                                   where x.articulo.Contains(textBox10.Text) || x.clave.Contains(textBox10.Text)
                                   orderby x.articulo ascending
                                   select new
                    {
                        Id              = x.id,
                        Clave           = x.clave,
                        Artículo        = x.articulo,
                        Linea           = x.linea,
                        Proveedor       = x.proveedor,
                        Caracteristicas = x.caracteristicas,
                        Color           = x.color,
                        Precio          = "$" + x.precio
                    };
                    datagridviewNE3.DataSource = null;
                    datagridviewNE3.DataSource = herrajes.ToList();
                    break;

                case 2:
                    var otros = from x in listas.otros
                                where x.articulo.Contains(textBox10.Text) || x.clave.Contains(textBox10.Text)
                                orderby x.articulo ascending
                                select new
                    {
                        Id              = x.id,
                        Clave           = x.clave,
                        Artículo        = x.articulo,
                        Linea           = x.linea,
                        Proveedor       = x.proveedor,
                        Caracteristicas = x.caracteristicas,
                        Color           = x.color,
                        Precio          = "$" + x.precio
                    };
                    datagridviewNE3.DataSource = null;
                    datagridviewNE3.DataSource = otros.ToList();
                    break;

                default: break;
                }
                listas.Dispose();
            }
        }
Пример #21
0
 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     listas_entities_pva listas = new listas_entities_pva();
     switch (comboBox1.SelectedIndex)
     {
         case 0:
             if (comboBox3.Text != "")
             {
                 var filter = from x in listas.lista_costo_corte_e_instalado
                              where (x.articulo.Contains(comboBox3.Text)) && (x.proveedor == comboBox2.Text)
                              orderby x.articulo ascending
                              select new
                              {
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Proveedor = x.proveedor,
                                  Costo_Corte_m2 = "$" + x.costo_corte_m2,
                                  Costo_Instalado = "$" + x.costo_instalado
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             else
             {
                 var filter = from x in listas.lista_costo_corte_e_instalado
                              where x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Proveedor = x.proveedor,
                                  Costo_Corte_m2 = "$" + x.costo_corte_m2,
                                  Costo_Instalado = "$" + x.costo_instalado
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             break;
         case 1:
             if (comboBox3.Text != "")
             {
                 var filter = from x in listas.perfiles
                              where x.linea == comboBox3.Text && x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Id = x.id,
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Linea = x.linea,
                                  Proveedor = x.proveedor,
                                  Largo = x.largo + " m",
                                  Crudo = "$" + x.crudo,
                                  Blanco = "$" + x.blanco,
                                  Hueso = "$" + x.hueso,
                                  Champagne = "$" + x.champagne,
                                  Gris = "$" + x.gris,
                                  Negro = "$" + x.negro,
                                  Brillante = "$" + x.brillante,
                                  Natural = "$" + x.natural_1,
                                  Madera = "$" + x.madera,
                                  Chocolate = "$" + x.chocolate,
                                  Acero_Inox = "$" + x.acero_inox,
                                  Bronce = "$" + x.bronce
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             else
             {
                 var filter = from x in listas.perfiles
                              where x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Id = x.id,
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Linea = x.linea,
                                  Proveedor = x.proveedor,
                                  Largo = x.largo + " m",
                                  Crudo = "$" + x.crudo,
                                  Blanco = "$" + x.blanco,
                                  Hueso = "$" + x.hueso,
                                  Champagne = "$" + x.champagne,
                                  Gris = "$" + x.gris,
                                  Negro = "$" + x.negro,
                                  Brillante = "$" + x.brillante,
                                  Natural = "$" + x.natural_1,
                                  Madera = "$" + x.madera,
                                  Chocolate = "$" + x.chocolate,
                                  Acero_Inox = "$" + x.acero_inox,
                                  Bronce = "$" + x.bronce
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             break;
         case 2:
             if (comboBox3.Text != "")
             {
                 var filter = from x in listas.herrajes
                              where x.linea == comboBox3.Text && x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Id = x.id,
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Linea = x.linea,
                                  Proveedor = x.proveedor,
                                  Caracteristicas = x.caracteristicas,
                                  Color = x.color,
                                  Precio = "$" + x.precio
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             else
             {
                 var filter = from x in listas.herrajes
                              where x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Id = x.id,
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Linea = x.linea,
                                  Proveedor = x.proveedor,
                                  Caracteristicas = x.caracteristicas,
                                  Color = x.color,
                                  Precio = "$" + x.precio
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             break;
         case 3:
             if (comboBox3.Text != "")
             {
                 var filter = from x in listas.otros
                              where x.linea == comboBox3.Text && x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Id = x.id,
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Linea = x.linea,
                                  Proveedor = x.proveedor,
                                  Caracteristicas = x.caracteristicas,
                                  Color = x.color,
                                  Precio = "$" + x.precio
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             else
             {
                 var filter = from x in listas.otros
                              where x.proveedor == comboBox2.Text
                              orderby x.articulo ascending
                              select new
                              {
                                  Id = x.id,
                                  Clave = x.clave,
                                  Artículo = x.articulo,
                                  Linea = x.linea,
                                  Proveedor = x.proveedor,
                                  Caracteristicas = x.caracteristicas,
                                  Color = x.color,
                                  Precio = "$" + x.precio
                              };
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = filter.ToList();
             }
             break;
         default:
             break;
     }
     listas.Dispose();
 }
Пример #22
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            cotizaciones_local  cotizaciones = new cotizaciones_local();
            listas_entities_pva listas       = new listas_entities_pva();
            int    modulo_id  = 0;
            int    esquema_id = 0;
            string buffer     = string.Empty;
            string c_clave    = string.Empty;
            float  count      = 0;
            string dir        = string.Empty;
            string acabado    = string.Empty;
            int    seccion    = -1;
            int    m_c        = 0;
            int    columns    = 0;
            int    rows       = 0;
            int    v_count    = 1;

            cotizaciones.Database.ExecuteSqlCommand("TRUNCATE TABLE materiales_modulos");
            cotizaciones.Database.ExecuteSqlCommand("DBCC CHECKIDENT (materiales_modulos, RESEED, 1)");
            cotizaciones.Database.ExecuteSqlCommand("TRUNCATE TABLE cortes");
            cotizaciones.Database.ExecuteSqlCommand("DBCC CHECKIDENT (cortes, RESEED, 1)");

            var modulos = from x in cotizaciones.modulos_cotizaciones where x.modulo_id > 0 && x.sub_folio == constants.sub_folio select x;

            if (modulos != null)
            {
                int _m_c         = 1;
                int counter      = 0;
                int modulos_cant = modulos.Count();
                progressBar1.Maximum = modulos_cant;
                progressBar1.Value   = 0;

                foreach (var v in modulos)
                {
                    var _m = (from x in cotizaciones.modulos_cotizaciones where x.id == v.merge_id select x).FirstOrDefault();
                    if (_m != null)
                    {
                        _m_c = (int)_m.cantidad;
                    }
                    v_count = (int)v.cantidad * _m_c;
                    counter++;
                    backgroundWorker1.ReportProgress(counter);
                    label1.Text = "Desglosando: " + v.articulo;
                    modulo_id   = (int)v.modulo_id;
                    var modulo = (from x in listas.modulos where x.id == modulo_id select x).SingleOrDefault();

                    if (modulo != null)
                    {
                        esquema_id = (int)modulo.id_diseño;
                        var esquema = (from x in listas.esquemas where x.id == esquema_id select x).SingleOrDefault();

                        string[] d_s   = v.dimensiones.Split(',');
                        int[]    d_num = new int[d_s.Length - 1];

                        for (int i = 0; i < d_num.Length; i++)
                        {
                            d_num[i] = int.Parse(d_s[i]);
                        }

                        int c = 0;

                        if (esquema != null)
                        {
                            columns = (int)esquema.columnas;
                            rows    = (int)esquema.filas;
                            if (esquema.marco == false)
                            {
                                c = 1;
                            }
                        }

                        int[,] arr = new int[((int)modulo.secciones + 1) + c, 2];

                        for (int i = 0; i < d_num.Length; i++)
                        {
                            if (i % 2 == 0)
                            {
                                arr[c, 0] = d_num[i];
                            }
                            else
                            {
                                arr[c, 1] = d_num[i];
                                c++;
                            }
                        }

                        claves_perfiles.Clear();
                        foreach (char x in v.claves_perfiles)
                        {
                            if (x == ',')
                            {
                                claves_perfiles.Add(buffer);
                                buffer = string.Empty;
                                continue;
                            }
                            buffer = buffer + x.ToString();
                        }

                        buffer  = "";
                        count   = 0;
                        dir     = "";
                        seccion = -1;
                        c_clave = "";
                        acabado = "";
                        m_c     = 0;

                        //aluminio
                        foreach (char alm in modulo.id_aluminio)
                        {
                            if (alm != ',')
                            {
                                if (alm == ':')
                                {
                                    c_clave = buffer;
                                    buffer  = "";
                                    continue;
                                }
                                if (alm == '-')
                                {
                                    count  = constants.stringToFloat(buffer) * v_count;
                                    buffer = "";
                                    continue;
                                }
                                if (alm == '$')
                                {
                                    dir    = buffer;
                                    buffer = "";
                                    continue;
                                }
                                buffer = buffer + alm.ToString();
                            }
                            else
                            {
                                seccion = constants.stringToInt(buffer);
                                buffer  = "";

                                string[] y = claves_perfiles[m_c].Split('-');
                                if (y.Length > 0)
                                {
                                    c_clave = y[0];
                                    if (y.Length > 1)
                                    {
                                        count = constants.stringToFloat(y[1]) * v_count;
                                        if (y.Length == 3)
                                        {
                                            acabado = y[2];
                                        }
                                    }
                                }
                                var perfiles = (from x in listas.perfiles where x.clave == c_clave select x).SingleOrDefault();

                                if (perfiles != null)
                                {
                                    if (acabado == "")
                                    {
                                        acabado = v.acabado_perfil;
                                    }

                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave && x.acabado == acabado select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            insertarMateriales(1, c_clave, perfiles.articulo, count, dir == "largo" ? arr[seccion, 0] * count : arr[seccion, 1] * count, 0, acabado, (float)perfiles.largo);
                                        }
                                        else
                                        {
                                            updateMateriales(c_clave, count, dir == "largo" ? arr[seccion, 0] * count : arr[seccion, 1] * count, 0, acabado);
                                        }
                                        ///Cortes
                                        insertarCortes(c_clave, perfiles.articulo, modulo_id, v.ubicacion, dir == "largo" ? arr[seccion, 0] * count : arr[seccion, 1], (float)perfiles.largo, acabado, count);
                                    }
                                }

                                m_c++;
                            }
                        }
                        //

                        buffer  = "";
                        count   = 0;
                        seccion = -1;
                        c_clave = "";
                        m_c     = 0;

                        claves_cristales.Clear();
                        foreach (char x in v.claves_cristales)
                        {
                            if (x == ',')
                            {
                                claves_cristales.Add(buffer);
                                buffer = string.Empty;
                                continue;
                            }
                            buffer = buffer + x.ToString();
                        }

                        //cristales
                        foreach (char cri in modulo.clave_vidrio)
                        {
                            if (cri != ',')
                            {
                                if (cri == ':')
                                {
                                    c_clave = buffer;
                                    buffer  = "";
                                    continue;
                                }
                                if (cri == '$')
                                {
                                    count  = constants.stringToFloat(buffer) * v_count;
                                    buffer = "";
                                    continue;
                                }
                                buffer = buffer + cri.ToString();
                            }
                            else
                            {
                                seccion = constants.stringToInt(buffer);
                                buffer  = "";

                                string[] y = claves_cristales[m_c].Split('-');
                                if (y.Length > 0)
                                {
                                    c_clave = y[0];
                                    if (y.Length > 1)
                                    {
                                        count = constants.stringToFloat(y[1]) * v_count;
                                    }
                                }
                                var cristal = (from x in listas.lista_costo_corte_e_instalado where x.clave == c_clave select x).SingleOrDefault();

                                if (cristal != null)
                                {
                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            if (modulo.cs == true)
                                            {
                                                insertarMateriales(2, c_clave, cristal.articulo, count, 0, ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                insertarMateriales(2, c_clave, cristal.articulo, count, 0, (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                        else
                                        {
                                            if (modulo.cs == true)
                                            {
                                                updateMateriales(c_clave, count, 0, ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                updateMateriales(c_clave, count, 0, (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                    }
                                }

                                m_c++;
                            }
                        }
                        //

                        buffer  = "";
                        count   = 0;
                        seccion = -1;
                        c_clave = "";
                        m_c     = 0;

                        claves_herrajes.Clear();
                        foreach (char x in v.claves_herrajes)
                        {
                            if (x == ',')
                            {
                                claves_herrajes.Add(buffer);
                                buffer = string.Empty;
                                continue;
                            }
                            buffer = buffer + x.ToString();
                        }

                        //herrajes
                        foreach (char h in modulo.id_herraje)
                        {
                            if (h != ',')
                            {
                                if (h == ':')
                                {
                                    c_clave = buffer;
                                    buffer  = "";
                                    continue;
                                }
                                if (h == '$')
                                {
                                    count  = constants.stringToFloat(buffer) * v_count;
                                    buffer = "";
                                    continue;
                                }
                                buffer = buffer + h.ToString();
                            }
                            else
                            {
                                seccion = constants.stringToInt(buffer);
                                buffer  = "";

                                string[] y = claves_herrajes[m_c].Split('-');
                                if (y.Length > 0)
                                {
                                    c_clave = y[0];
                                    if (y.Length > 1)
                                    {
                                        count = constants.stringToFloat(y[1]) * v_count;
                                    }
                                }
                                var herrajes = (from s in listas.herrajes where s.clave == c_clave select s).SingleOrDefault();

                                if (herrajes != null)
                                {
                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            insertarMateriales(3, c_clave, herrajes.articulo, count, 0, 0);
                                        }
                                        else
                                        {
                                            updateMateriales(c_clave, count, 0, 0);
                                        }
                                    }
                                }

                                m_c++;
                            }
                        }
                        //

                        buffer  = "";
                        count   = 0;
                        dir     = "";
                        seccion = -1;
                        c_clave = "";
                        m_c     = 0;

                        claves_otros.Clear();
                        foreach (char x in v.claves_otros)
                        {
                            if (x == ',')
                            {
                                claves_otros.Add(buffer);
                                buffer = string.Empty;
                                continue;
                            }
                            buffer = buffer + x.ToString();
                        }

                        //otros
                        foreach (char o in modulo.id_otros)
                        {
                            if (o != ',')
                            {
                                if (o == ':')
                                {
                                    c_clave = buffer;
                                    buffer  = "";
                                    continue;
                                }
                                if (o == '-')
                                {
                                    count  = constants.stringToFloat(buffer) * v_count;
                                    buffer = "";
                                    continue;
                                }
                                if (o == '$')
                                {
                                    dir    = buffer;
                                    buffer = "";
                                    continue;
                                }
                                buffer = buffer + o.ToString();
                            }
                            else
                            {
                                seccion = constants.stringToInt(buffer);
                                buffer  = "";

                                string[] y = claves_otros[m_c].Split('-');
                                if (y.Length > 0)
                                {
                                    c_clave = y[0];
                                    if (y.Length > 1)
                                    {
                                        count = constants.stringToFloat(y[1]) * v_count;
                                    }
                                }
                                var otros = (from x in listas.otros where x.clave == c_clave select x).SingleOrDefault();

                                if (otros != null)
                                {
                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            if (modulo.cs == true)
                                            {
                                                insertarMateriales(4, c_clave, otros.articulo, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                insertarMateriales(4, c_clave, otros.articulo, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                        else
                                        {
                                            if (modulo.cs == true)
                                            {
                                                updateMateriales(c_clave, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                updateMateriales(c_clave, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                    }
                                }

                                m_c++;
                            }
                        }
                        //

                        count   = 0;
                        dir     = "";
                        seccion = -1;
                        c_clave = "";

                        new_items.Clear();
                        foreach (char x in v.news)
                        {
                            if (x == ';')
                            {
                                new_items.Add(buffer);
                                buffer = string.Empty;
                                continue;
                            }
                            buffer = buffer + x.ToString();
                        }

                        string[] nw;
                        int      concept = 0;
                        //news
                        foreach (string n in new_items)
                        {
                            nw      = n.Split(',');
                            concept = constants.stringToInt(nw[0]);
                            if (concept == 1)
                            {
                                //Values
                                c_clave = nw[1];
                                count   = constants.stringToFloat(nw[2]) * v_count;
                                dir     = nw[3];
                                seccion = constants.stringToInt(nw[4]);
                                acabado = nw[5];
                                //------------------------------------------------------>
                                var perfiles = (from x in listas.perfiles where x.clave == c_clave select x).SingleOrDefault();

                                if (perfiles != null)
                                {
                                    if (acabado == "")
                                    {
                                        acabado = v.acabado_perfil;
                                    }

                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave && x.acabado == acabado select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            insertarMateriales(1, c_clave, perfiles.articulo, count, dir == "largo" ? arr[seccion, 0] * count : arr[seccion, 1] * count, 0, acabado, (float)perfiles.largo);
                                        }
                                        else
                                        {
                                            updateMateriales(c_clave, count, dir == "largo" ? arr[seccion, 0] * count : arr[seccion, 1] * count, 0, acabado);
                                        }
                                        ///Cortes
                                        insertarCortes(c_clave, perfiles.articulo, modulo_id, v.ubicacion, dir == "largo" ? arr[seccion, 0] * count : arr[seccion, 1], (float)perfiles.largo, acabado, count);
                                    }
                                }
                            }
                            else if (concept == 2)
                            {
                                //Values
                                c_clave = nw[1];
                                count   = constants.stringToFloat(nw[2]) * v_count;
                                dir     = nw[3];
                                seccion = constants.stringToInt(nw[4]);
                                acabado = nw[5];
                                //------------------------------------------------------>
                                var cristal = (from x in listas.lista_costo_corte_e_instalado where x.clave == c_clave select x).SingleOrDefault();

                                if (cristal != null)
                                {
                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            if (modulo.cs == true)
                                            {
                                                insertarMateriales(2, c_clave, cristal.articulo, count, 0, ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                insertarMateriales(2, c_clave, cristal.articulo, count, 0, (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                        else
                                        {
                                            if (modulo.cs == true)
                                            {
                                                updateMateriales(c_clave, count, 0, ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                updateMateriales(c_clave, count, 0, (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (concept == 3)
                            {
                                //Values
                                c_clave = nw[1];
                                count   = constants.stringToFloat(nw[2]) * v_count;
                                dir     = nw[3];
                                seccion = constants.stringToInt(nw[4]);
                                acabado = nw[5];
                                //------------------------------------------------------>
                                var herrajes = (from s in listas.herrajes where s.clave == c_clave select s).SingleOrDefault();

                                if (herrajes != null)
                                {
                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            insertarMateriales(3, c_clave, herrajes.articulo, count, 0, 0);
                                        }
                                        else
                                        {
                                            updateMateriales(c_clave, count, 0, 0);
                                        }
                                    }
                                }
                            }
                            else if (concept == 4)
                            {
                                //Values
                                c_clave = nw[1];
                                count   = constants.stringToFloat(nw[2]) * v_count;
                                dir     = nw[3];
                                seccion = constants.stringToInt(nw[4]);
                                acabado = nw[5];
                                //------------------------------------------------------>
                                var otros = (from x in listas.otros where x.clave == c_clave select x).SingleOrDefault();

                                if (otros != null)
                                {
                                    var materiales = (from x in cotizaciones.materiales_modulos where x.clave == c_clave select x).SingleOrDefault();

                                    if (count > 0)
                                    {
                                        if (materiales == null)
                                        {
                                            if (modulo.cs == true)
                                            {
                                                insertarMateriales(4, c_clave, otros.articulo, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                insertarMateriales(4, c_clave, otros.articulo, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                        else
                                        {
                                            if (modulo.cs == true)
                                            {
                                                updateMateriales(c_clave, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : ((arr[seccion, 0] * arr[seccion, 1]) * count) / 1000);
                                            }
                                            else
                                            {
                                                updateMateriales(c_clave, count, dir == "largo" ? arr[seccion, 0] * count : dir == "alto" ? arr[seccion, 1] * count : 0, otros.largo <= 0 ? 0 : otros.alto <= 0 ? 0 : (((arr[seccion, 0] / columns) * (arr[seccion, 1] / rows)) * count) / 1000);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //-----------------------> END
                    }
                }
            }
        }
Пример #23
0
 //Carga los productos
 private void loadListas()
 {
     setFiltros();
     listas_entities_pva listas = new listas_entities_pva();
     switch (comboBox1.SelectedIndex)
     {
         case 0:
             var cristal = from x in listas.lista_costo_corte_e_instalado
                           orderby x.articulo ascending
                           select new
                           {
                               Clave = x.clave,
                               Artículo = x.articulo,
                               Proveedor = x.proveedor,
                               Costo_Corte_m2 = "$" + x.costo_corte_m2,
                               Costo_Instalado = "$" + x.costo_instalado
                           };
             if (datagridviewNE1.InvokeRequired == true)
             {
                 datagridviewNE1.Invoke((MethodInvoker)delegate
                 {
                     datagridviewNE1.DataSource = null;
                     datagridviewNE1.DataSource = cristal.ToList();
                 });
             }
             else
             {
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = cristal.ToList();
             }
             break;
         case 1:
             var aluminio = from x in listas.perfiles
                            orderby x.articulo ascending
                            select new
                            {
                                Id = x.id,
                                Clave = x.clave,
                                Artículo = x.articulo,
                                Linea = x.linea,
                                Proveedor = x.proveedor,
                                Largo = x.largo + " m",
                                Crudo = "$" + x.crudo,
                                Blanco = "$" + x.blanco,
                                Hueso = "$" + x.hueso,
                                Champagne = "$" + x.champagne,
                                Gris = "$" + x.gris,
                                Negro = "$" + x.negro,
                                Brillante = "$" + x.brillante,
                                Natural = "$" + x.natural_1,
                                Madera = "$" + x.madera,
                                Chocolate = "$" + x.chocolate,
                                Acero_Inox = "$" + x.acero_inox,
                                Bronce = "$" + x.bronce
                            };
             if (datagridviewNE1.InvokeRequired == true)
             {
                 datagridviewNE1.Invoke((MethodInvoker)delegate
                 {
                     datagridviewNE1.DataSource = null;
                     datagridviewNE1.DataSource = aluminio.ToList();
                 });
             }
             else
             {
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = aluminio.ToList();
             }
             break;
         case 2:
             var herraje = from x in listas.herrajes
                           orderby x.articulo ascending
                           select new
                           {
                               Id = x.id,
                               Clave = x.clave,
                               Artículo = x.articulo,
                               Linea = x.linea,
                               Proveedor = x.proveedor,
                               Caracteristicas = x.caracteristicas,
                               Color = x.color,
                               Precio = "$" + x.precio
                           };
             if (datagridviewNE1.InvokeRequired == true)
             {
                 datagridviewNE1.Invoke((MethodInvoker)delegate
                 {
                     datagridviewNE1.DataSource = null;
                     datagridviewNE1.DataSource = herraje.ToList();
                 });
             }
             else
             {
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = herraje.ToList();
             }
             break;
         case 3:
             var data = from x in listas.otros
                        orderby x.articulo ascending
                        select new
                        {
                            Id = x.id,
                            Clave = x.clave,
                            Artículo = x.articulo,
                            Linea = x.linea,
                            Proveedor = x.proveedor,
                            Caracteristicas = x.caracteristicas,
                            Color = x.color,
                            Precio = "$" + x.precio
                        };
             if (datagridviewNE1.InvokeRequired == true)
             {
                 datagridviewNE1.Invoke((MethodInvoker)delegate
                 {
                     datagridviewNE1.DataSource = null;
                     datagridviewNE1.DataSource = data.ToList();
                 });
             }
             else
             {
                 datagridviewNE1.DataSource = null;
                 datagridviewNE1.DataSource = data.ToList();
             }
             break;
         default:
             break;
     }
 }
Пример #24
0
        private void loadList()
        {
            listas_entities_pva lista = new listas_entities_pva();
            string filter             = textBox1.Text;

            dataGridView1.DataSource = null;
            if (componente == 0)
            {
                var linea = (from x in lista.herrajes where x.id == id select x.linea).SingleOrDefault();

                if (linea != null)
                {
                    if (se == false)
                    {
                        if (filter != "")
                        {
                            var herraje = from u in lista.herrajes
                                          where u.linea == linea && (u.clave.Contains(filter) || u.articulo.Contains(filter))
                                          select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = herraje.ToList();
                        }
                        else
                        {
                            var herraje = from u in lista.herrajes
                                          where u.linea == linea
                                          select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = herraje.ToList();
                        }
                    }
                    else
                    {
                        if (filter != "")
                        {
                            var herraje = from u in lista.herrajes
                                          where u.clave.Contains(filter) || u.articulo.Contains(filter)
                                          select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = herraje.ToList();
                        }
                        else
                        {
                            var herraje = from u in lista.herrajes
                                          select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = herraje.ToList();
                        }
                    }
                }
            }
            else if (componente == 1)
            {
                var linea = (from x in lista.otros where x.id == id select x.linea).SingleOrDefault();

                if (linea != null)
                {
                    if (se == false)
                    {
                        if (filter != "")
                        {
                            var otros = from u in lista.otros
                                        where u.linea == linea && (u.clave.Contains(filter) || u.articulo.Contains(filter))
                                        select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = otros.ToList();
                        }
                        else
                        {
                            var otros = from u in lista.otros
                                        where u.linea == linea
                                        select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = otros.ToList();
                        }
                    }
                    else
                    {
                        if (filter != "")
                        {
                            var otros = from u in lista.otros
                                        where u.clave.Contains(filter) || u.articulo.Contains(filter)
                                        select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = otros.ToList();
                        }
                        else
                        {
                            var otros = from u in lista.otros
                                        select new
                            {
                                Id        = u.id,
                                Clave     = u.clave,
                                Artículo  = u.articulo,
                                Linea     = u.linea,
                                Proveedor = u.proveedor,
                                Color     = u.color,
                                Precio    = "$" + u.precio
                            };
                            dataGridView1.DataSource = null;
                            dataGridView1.DataSource = otros.ToList();
                        }
                    }
                }
            }
            else if (componente == 2)
            {
                if (filter != "")
                {
                    var cristales = from x in lista.lista_costo_corte_e_instalado
                                    where x.clave.Contains(filter) || x.articulo.Contains(filter)
                                    select new
                    {
                        Clave           = x.clave,
                        Artículo        = x.articulo,
                        Proveedor       = x.proveedor,
                        Costo_Corte_m2  = "$" + x.costo_corte_m2,
                        Costo_Instalado = "$" + x.costo_instalado
                    };
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = cristales.ToList();
                }
                else
                {
                    var cristales = from x in lista.lista_costo_corte_e_instalado
                                    select new
                    {
                        Clave           = x.clave,
                        Artículo        = x.articulo,
                        Proveedor       = x.proveedor,
                        Costo_Corte_m2  = "$" + x.costo_corte_m2,
                        Costo_Instalado = "$" + x.costo_instalado
                    };
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = cristales.ToList();
                }
            }
            else if (componente == 3)
            {
                if (filter != "")
                {
                    var perfiles = from x in lista.perfiles
                                   where x.clave.Contains(filter) || x.articulo.Contains(filter)
                                   select new
                    {
                        Id         = x.id,
                        Clave      = x.clave,
                        Artículo   = x.articulo,
                        Linea      = x.linea,
                        Proveedor  = x.proveedor,
                        Largo      = x.largo + " m",
                        Crudo      = "$" + x.crudo,
                        Blanco     = "$" + x.blanco,
                        Hueso      = "$" + x.hueso,
                        Champagne  = "$" + x.champagne,
                        Gris       = "$" + x.gris,
                        Negro      = "$" + x.negro,
                        Brillante  = "$" + x.brillante,
                        Natural    = "$" + x.natural_1,
                        Madera     = "$" + x.madera,
                        Chocolate  = "$" + x.chocolate,
                        Acero_Inox = "$" + x.acero_inox,
                        Bronce     = "$" + x.bronce
                    };
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = perfiles.ToList();
                }
                else
                {
                    var perfiles = from x in lista.perfiles
                                   select new
                    {
                        Id         = x.id,
                        Clave      = x.clave,
                        Artículo   = x.articulo,
                        Linea      = x.linea,
                        Proveedor  = x.proveedor,
                        Largo      = x.largo + " m",
                        Crudo      = "$" + x.crudo,
                        Blanco     = "$" + x.blanco,
                        Hueso      = "$" + x.hueso,
                        Champagne  = "$" + x.champagne,
                        Gris       = "$" + x.gris,
                        Negro      = "$" + x.negro,
                        Brillante  = "$" + x.brillante,
                        Natural    = "$" + x.natural_1,
                        Madera     = "$" + x.madera,
                        Chocolate  = "$" + x.chocolate,
                        Acero_Inox = "$" + x.acero_inox,
                        Bronce     = "$" + x.bronce
                    };
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = perfiles.ToList();
                }
            }
            lista.Dispose();
        }
Пример #25
0
        //Cargar Todo
        private void loadAll()
        {
            cotizaciones_local  cotizaciones = new cotizaciones_local();
            listas_entities_pva listas       = new listas_entities_pva();

            var modulos = from x in cotizaciones.modulos_cotizaciones where x.sub_folio == constants.sub_folio && x.merge_id <= 0 orderby x.orden ascending select x;

            if (modulos != null)
            {
                int c     = 0;
                int count = modulos.Count();
                progressBar1.Maximum = modulos.Count();
                sqlDateBaseManager sql   = new sqlDateBaseManager();
                DataTable          table = sql.selectProduccionTable(folio);

                //Vars
                string[]        y           = null;
                string          descripcion = string.Empty;
                string[]        items       = new string[] { "No asignado", "Vista por fuera", "Vista por dentro", "Apertura por fuera", "Apertura por dentro", "Apertura por ambos lados" };
                bool            t           = false;
                List <string>   cris_list   = new List <string>();
                List <string[]> herrajes_l  = new List <string[]>();
                string          c_clave     = string.Empty;
                string          buffer      = string.Empty;
                bool            n_c         = false;
                string          cristales   = string.Empty;
                string[]        _k          = null;
                string          herrajes    = string.Empty;
                string[]        _x          = null;

                foreach (var x in modulos)
                {
                    try {
                        //obtener claves cristales new
                        string[] news = x.news.Split(';');
                        foreach (string k in news)
                        {
                            string[] o = k.Split(',');
                            if (o[0] == "2")
                            {
                                n_c = false;
                                foreach (string p in cris_list)
                                {
                                    if (p == o[1])
                                    {
                                        n_c = true;
                                        break;
                                    }
                                }

                                if (n_c == false)
                                {
                                    cris_list.Add(o[1]);
                                }
                            }
                        }
                        //obtener claves cristales (no-repetir)
                        foreach (char cri in x.claves_cristales)
                        {
                            if (cri != ',')
                            {
                                if (cri != '-' && t == false)
                                {
                                    buffer = buffer + cri.ToString();
                                }
                                else
                                {
                                    t = true;
                                }
                            }
                            else
                            {
                                t       = false;
                                n_c     = false;
                                c_clave = buffer;
                                buffer  = string.Empty;
                                foreach (string p in cris_list)
                                {
                                    if (p == c_clave)
                                    {
                                        n_c = true;
                                        break;
                                    }
                                }

                                if (n_c == false)
                                {
                                    cris_list.Add(c_clave);
                                }
                            }
                        }
                        //--------------------------------------------------------->

                        //obtener nombre de cristales
                        foreach (string p in cris_list)
                        {
                            var g = (from n in listas.lista_precio_corte_e_instalado where n.clave == p select n).SingleOrDefault();

                            if (g != null)
                            {
                                if (cristales.Length == 0)
                                {
                                    cristales = g.articulo;
                                }
                                else
                                {
                                    cristales = cristales + "\n" + g.articulo;
                                }
                            }
                        }
                        //-------------------------------------------------------------->

                        //Color del anodizado
                        string acabado = x.acabado_perfil;
                        string clr     = "";
                        var    colores = (from p in listas.colores_aluminio where p.clave == acabado select p).SingleOrDefault();

                        if (colores != null)
                        {
                            clr = " - " + colores.color;
                        }
                        //

                        string mosquitero = string.Empty;
                        string elevacion  = string.Empty;

                        if (x.articulo.Contains("C/M") == true)
                        {
                            mosquitero = "\nIncluye Mosquitero.";
                        }
                        else if (x.articulo.Contains("S/M") == true)
                        {
                            mosquitero = "\nSin Mosquitero.";
                        }

                        if (acabado != "")
                        {
                            acabado = "\n-Acabado: " + x.acabado_perfil + clr;
                        }
                        else
                        {
                            acabado = "";
                        }

                        if (x.diseño != "CM")
                        {
                            if (cristales.Length > 0)
                            {
                                descripcion = "-Linea: " + x.linea + acabado + "\n-Cristal:\n" + cristales + "\n-Descripción:\n" + x.descripcion + mosquitero;
                            }
                            else
                            {
                                descripcion = "-Linea: " + x.linea + acabado + "\n-Descripción:\n" + x.descripcion + mosquitero;
                            }
                        }
                        else
                        {
                            string[] k = x.claves_otros.Split(',');
                            foreach (string r in k)
                            {
                                string[] z = r.Split('-');
                                if (z.Length == 2)
                                {
                                    string cl   = z[0];
                                    float  cant = constants.stringToFloat(z[1]);
                                    var    ot   = (from p in listas.otros where p.clave == cl select p).SingleOrDefault();

                                    if (ot != null)
                                    {
                                        if (ot.linea == "motores" && cant > 0)
                                        {
                                            elevacion = "\nCortina Motorizada.";
                                            break;
                                        }
                                        else
                                        {
                                            elevacion = "\nCortina Manual.";
                                        }
                                    }
                                }
                            }
                            string[] modelo = x.articulo.Split('-');
                            if (modelo.Length > 1)
                            {
                                descripcion = "-Linea: " + x.linea + "\n-Modelo: " + modelo[1] + acabado + "\n-Descripción:\n" + x.descripcion + mosquitero + elevacion;
                            }
                            else
                            {
                                descripcion = "-Linea: " + x.linea + "\n-Modelo: " + x.articulo + acabado + "\n-Descripción:\n" + x.descripcion + mosquitero + elevacion;
                            }
                        }

                        if (x.modulo_id == -2)
                        {
                            descripcion = x.descripcion;
                        }
                    }
                    catch (Exception err)
                    {
                        constants.errorLog(err.ToString());
                        MessageBox.Show(this, "[Error] se ha presentado un problema al cargar datos, puede que la información no se haya cargado correctamente.", constants.msg_box_caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    //ADD
                    //----------------------------------------------------------------------------------------------------------------------->
                    y = x.clave.Split('-');
                    try {
                        //get Herrajes ------------------------------------------------------------------------------------------------------>
                        if (!checkBox1.Checked)
                        {
                            if (x.modulo_id == -1)
                            {
                                int q      = x.id;
                                var merged = from n in cotizaciones.modulos_cotizaciones where n.merge_id == q && n.sub_folio == constants.sub_folio select n;
                                foreach (var n in merged)
                                {
                                    _k = n.claves_herrajes.Split(',');
                                    foreach (string m in _k.Where(s => s != string.Empty))
                                    {
                                        _x = m.Split('-');
                                        if (_x.Length >= 2)
                                        {
                                            if (constants.stringToFloat(_x[1]) > 0)
                                            {
                                                if (herrajes_l.FirstOrDefault(s => s[0] == _x[0]) == null)
                                                {
                                                    herrajes_l.Add(new string[] { _x[0], _x[1] });
                                                }
                                                else
                                                {
                                                    herrajes_l.FirstOrDefault(s => s[0] == _x[0])[1] = (constants.stringToFloat(herrajes_l.FirstOrDefault(s => s[0] == _x[0])[1].ToString()) + constants.stringToFloat(_x[1])).ToString();
                                                }
                                            }
                                        }
                                    }
                                    if (n.news.Length > 0)
                                    {
                                        _k = n.news.Split(';');
                                        foreach (string m in _k.Where(s => s != string.Empty))
                                        {
                                            _x = m.Split(',');
                                            if (_x.Length > 0)
                                            {
                                                if (_x[0] == "3")
                                                {
                                                    if (constants.stringToFloat(_x[2]) > 0)
                                                    {
                                                        if (herrajes_l.FirstOrDefault(s => s[0] == _x[1]) == null)
                                                        {
                                                            herrajes_l.Add(new string[] { _x[1], _x[2] });
                                                        }
                                                        else
                                                        {
                                                            herrajes_l.FirstOrDefault(s => s[0] == _x[1])[1] = (constants.stringToFloat(herrajes_l.FirstOrDefault(s => s[0] == _x[1])[1].ToString()) + constants.stringToFloat(_x[2])).ToString();
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else if (x.modulo_id > 0)
                            {
                                _k = x.claves_herrajes.Split(',');
                                foreach (string m in _k.Where(s => s != string.Empty))
                                {
                                    _x = m.Split('-');
                                    if (_x.Length >= 2)
                                    {
                                        if (constants.stringToFloat(_x[1]) > 0)
                                        {
                                            if (herrajes_l.FirstOrDefault(s => s[0] == _x[0]) == null)
                                            {
                                                herrajes_l.Add(new string[] { _x[0], _x[1] });
                                            }
                                            else
                                            {
                                                herrajes_l.FirstOrDefault(s => s[0] == _x[0])[1] = (constants.stringToFloat(herrajes_l.FirstOrDefault(s => s[0] == _x[0])[1].ToString()) + constants.stringToFloat(_x[1])).ToString();
                                            }
                                        }
                                    }
                                }
                                if (x.news.Length > 0)
                                {
                                    _k = x.news.Split(';');
                                    foreach (string m in _k.Where(s => s != string.Empty))
                                    {
                                        _x = m.Split(',');
                                        if (_x.Length > 0)
                                        {
                                            if (_x[0] == "3")
                                            {
                                                if (constants.stringToFloat(_x[2]) > 0)
                                                {
                                                    if (herrajes_l.FirstOrDefault(s => s[0] == _x[1]) == null)
                                                    {
                                                        herrajes_l.Add(new string[] { _x[1], _x[2] });
                                                    }
                                                    else
                                                    {
                                                        herrajes_l.FirstOrDefault(s => s[0] == _x[1])[1] = (constants.stringToFloat(herrajes_l.FirstOrDefault(s => s[0] == _x[1])[1].ToString()) + constants.stringToFloat(_x[2])).ToString();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            _x = null;

                            foreach (string[] n in herrajes_l)
                            {
                                string clave = n[0];
                                var    l     = (from r in listas.herrajes where r.clave == clave select r).SingleOrDefault();
                                if (l != null)
                                {
                                    herrajes = herrajes + "-" + clave + " : " + l.articulo + " #" + n[1] + "\n";
                                }
                            }
                        }
                        //---------------------------------------------------------------------------------------------------------------------------->

                        if (y.Length == 2)
                        {
                            int _v        = constants.stringToInt(y[1]);
                            var get_match = (from v in table.AsEnumerable() where v.Field <int>("m_id") == _v select v).FirstOrDefault();

                            if (get_match != null)
                            {
                                _k = null;
                                _k = get_match.Field <string>("parameters").Split(',');
                                if (_k.Length == 2)
                                {
                                    setDataTable(get_match.Field <int>("id"), x.pic, _v, "L: " + x.largo + "\nA: " + x.alto, (float)x.cantidad, x.ubicacion, descripcion, items.FirstOrDefault(s => s == _k[0]) != null ? _k[0] : "No asignado", items.FirstOrDefault(s => s == _k[1]) != null ? _k[1] : "No asignado", get_match.Field <string>("observaciones"), herrajes);
                                }
                                else
                                {
                                    setDataTable(get_match.Field <int>("id"), x.pic, _v, "L: " + x.largo + "\nA: " + x.alto, (float)x.cantidad, x.ubicacion, descripcion, "No asignado", "No asignado", get_match.Field <string>("observaciones"), herrajes);
                                }
                            }
                            else
                            {
                                setDataTable(-1, x.pic, _v, "L: " + x.largo + "\nA: " + x.alto, (float)x.cantidad, x.ubicacion, descripcion, "No asignado", "No asignado", "", herrajes);
                            }
                        }
                        else
                        {
                            setDataTable(-1, x.pic, -1, "L: " + x.largo + "\nA: " + x.alto, (float)x.cantidad, x.ubicacion, descripcion, "No asignado", "No asignado", "", herrajes);
                        }
                    }
                    catch (Exception err)
                    {
                        constants.errorLog(err.ToString());
                        MessageBox.Show(this, "[Error] se ha presentado un problema al cargar datos, intente de nuevo.", constants.msg_box_caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    cris_list.Clear();
                    herrajes_l.Clear();
                    herrajes    = string.Empty;
                    cristales   = string.Empty;
                    descripcion = string.Empty;
                    c++;
                    backgroundWorker1.ReportProgress(c);
                }
                //End loop
                checkRows();
            }
        }
Пример #26
0
        public void setNewItem(int cp, string clave, string operacion, float cantidad = -1)
        {
            listas_entities_pva listas = new listas_entities_pva();

            if (datagridviewNE1.InvokeRequired)
            {
                datagridviewNE1.Invoke((MethodInvoker) delegate
                {
                    if (cp == 1)
                    {
                        var perfiles = (from x in listas.perfiles where x.clave == clave select x).SingleOrDefault();
                        if (perfiles != null)
                        {
                            datagridviewNE1.Rows.Add(cp, clave, perfiles.articulo, cantidad, operacion);
                        }
                    }
                    else if (cp == 2)
                    {
                        var cristales = (from x in listas.lista_costo_corte_e_instalado where x.clave == clave select x).SingleOrDefault();
                        if (cristales != null)
                        {
                            datagridviewNE1.Rows.Add(cp, clave, cristales.articulo, cantidad, operacion);
                        }
                    }
                    else if (cp == 3)
                    {
                        var herrajes = (from x in listas.herrajes where x.clave == clave select x).SingleOrDefault();
                        if (herrajes != null)
                        {
                            datagridviewNE1.Rows.Add(cp, clave, herrajes.articulo, cantidad, operacion);
                        }
                    }
                    else if (cp == 4)
                    {
                        var otros = (from x in listas.otros where x.clave == clave select x).SingleOrDefault();
                        if (otros != null)
                        {
                            datagridviewNE1.Rows.Add(cp, clave, otros.articulo, cantidad, operacion);
                        }
                    }

                    foreach (DataGridViewRow x in datagridviewNE1.Rows)
                    {
                        if (x.Cells[4].Value.ToString() != "")
                        {
                            foreach (DataGridViewCell n in x.Cells)
                            {
                                if (n.OwningColumn.HeaderText != "cantidad")
                                {
                                    n.Style.BackColor = Color.Yellow;
                                }
                            }
                        }
                        else
                        {
                            foreach (DataGridViewCell n in x.Cells)
                            {
                                if (n.OwningColumn.HeaderText != "cantidad")
                                {
                                    n.Style.BackColor = Color.LightGreen;
                                }
                            }
                        }
                    }
                });
            }
            else
            {
                if (cp == 1)
                {
                    var perfiles = (from x in listas.perfiles where x.clave == clave select x).SingleOrDefault();
                    if (perfiles != null)
                    {
                        datagridviewNE1.Rows.Add(cp, clave, perfiles.articulo, cantidad, operacion);
                    }
                }
                else if (cp == 2)
                {
                    var cristales = (from x in listas.lista_costo_corte_e_instalado where x.clave == clave select x).SingleOrDefault();
                    if (cristales != null)
                    {
                        datagridviewNE1.Rows.Add(cp, clave, cristales.articulo, cantidad, operacion);
                    }
                }
                else if (cp == 3)
                {
                    var herrajes = (from x in listas.herrajes where x.clave == clave select x).SingleOrDefault();
                    if (herrajes != null)
                    {
                        datagridviewNE1.Rows.Add(cp, clave, herrajes.articulo, cantidad, operacion);
                    }
                }
                else if (cp == 4)
                {
                    var otros = (from x in listas.otros where x.clave == clave select x).SingleOrDefault();
                    if (otros != null)
                    {
                        datagridviewNE1.Rows.Add(cp, clave, otros.articulo, cantidad, operacion);
                    }
                }

                foreach (DataGridViewRow x in datagridviewNE1.Rows)
                {
                    if (x.Cells[4].Value.ToString() != "")
                    {
                        foreach (DataGridViewCell n in x.Cells)
                        {
                            if (n.OwningColumn.HeaderText != "cantidad")
                            {
                                n.Style.BackColor = Color.Yellow;
                            }
                        }
                    }
                    else
                    {
                        foreach (DataGridViewCell n in x.Cells)
                        {
                            if (n.OwningColumn.HeaderText != "cantidad")
                            {
                                n.Style.BackColor = Color.LightGreen;
                            }
                        }
                    }
                }
            }
        }
Пример #27
0
        private void insertListaPerfilesCuprum(int id, string clave, string articulo, string linea, string proveedor, float largo, float ancho, float per_a, float crudo, float blanco, float hueso, float champagne, float gris, float negro, float brillante, float natural, float madera, float peso, float chocolate, float acero_inox, float bronce, string moneda)
        {
            listas = new listas_entities_pva();
            float tc = constants.tc;

            try
            {
                if (moneda != "MXN")
                {
                    var k = new perfile()
                    {
                        id               = id,
                        clave            = clave,
                        articulo         = articulo,
                        linea            = linea,
                        proveedor        = proveedor,
                        largo            = Math.Round(largo, 2),
                        ancho_perfil     = Math.Round(ancho, 2),
                        perimetro_dm2_ml = Math.Round(per_a, 2),
                        crudo            = Math.Round(crudo * tc, 2),
                        blanco           = Math.Round(blanco * tc, 2),
                        hueso            = Math.Round(hueso * tc, 2),
                        champagne        = Math.Round(champagne * tc, 2),
                        gris             = Math.Round(gris * tc, 2),
                        negro            = Math.Round(negro * tc, 2),
                        brillante        = Math.Round(brillante * tc, 2),
                        natural_1        = Math.Round(natural * tc, 2),
                        madera           = Math.Round(madera * tc, 2),
                        chocolate        = Math.Round(chocolate * tc, 2),
                        acero_inox       = Math.Round(acero_inox * tc, 2),
                        bronce           = Math.Round(bronce * tc, 2),
                        kg_peso_lineal   = Math.Round(peso, 2),
                        moneda           = moneda
                    };
                    listas.perfiles.Add(k);
                    listas.SaveChanges();
                }
                else
                {
                    var k = new perfile()
                    {
                        id               = id,
                        clave            = clave,
                        articulo         = articulo,
                        linea            = linea,
                        proveedor        = proveedor,
                        largo            = Math.Round(largo, 2),
                        ancho_perfil     = Math.Round(ancho, 2),
                        perimetro_dm2_ml = Math.Round(per_a, 2),
                        crudo            = Math.Round(crudo, 2),
                        blanco           = Math.Round(blanco, 2),
                        hueso            = Math.Round(hueso, 2),
                        champagne        = Math.Round(champagne, 2),
                        gris             = Math.Round(gris, 2),
                        negro            = Math.Round(negro, 2),
                        brillante        = Math.Round(brillante, 2),
                        natural_1        = Math.Round(natural, 2),
                        madera           = Math.Round(madera, 2),
                        chocolate        = Math.Round(chocolate, 2),
                        acero_inox       = Math.Round(acero_inox, 2),
                        bronce           = Math.Round(bronce, 2),
                        kg_peso_lineal   = Math.Round(peso, 2),
                        moneda           = moneda
                    };
                    listas.perfiles.Add(k);
                    listas.SaveChanges();
                }
            }
            catch (Exception err)
            {
                constants.errorLog(err.ToString());
            }
        }