Exemplo n.º 1
0
        private void cmdBuscar_Click(object sender, EventArgs e)
        {
            bool tipocatencontrado = false;
            bool tipodieencontrado = false;
            bool insertar = true;
            gb_CamposAdicionales.Enabled = true;
            this.Cursor = Cursors.WaitCursor;             //cambiamos el cursor a un cursor de espera
            if (gb_CamposAdicionales.Controls.Count > 0)  //si el groupbox de campos adicionales contiene controles, tenemos que borrarlos para el siguiente registro.
            {
                gb_CamposAdicionales.Controls.Clear();    //borramos controle
                gb_CamposAdicionales.Height = 100;        //reseteamos altura
                gb_CamposAdicionales.Width = 240;         //reseteamos anchura
            }
            if (gb_Extra.Controls.Count > 0)  //si el groupbox de campos adicionales contiene controles, tenemos que borrarlos para el siguiente registro.
            {
                gb_Extra.Controls.Clear();    //borramos controle
                gb_Extra.Height = 100;        //reseteamos altura
                gb_Extra.Width = 240;         //reseteamos anchura
            }
            etq = new Etiqueta_P(lbl_IntroClavProd.Text);   //nueva instracia de Etiqueta etq con la nueva clave de prodcto (buscar en ESPECIFICACIONES.xls)
            columnasPorUsar = new List<Etiqueta_P.Campos>();         //inicializamos una nueva lista de las columnas que usa esa etiqueta

            if (!obtenerDatosGenerales())                 //si se obtiene un valor falso, la clave no existe
            {
                this.Cursor = Cursors.Default;            //regresamos el cursor al default
                return;                                   //exit
            }
            else                                          //si es verdadero el booleano que regresa 'obtenerDatosGenerales()'
            {
                etiquetasNO = etq.SeparadorDeEtiquetas();
                TodasLasEtiquetas = new Dictionary<int, int>();
                TodasLasEtiquetasFinales = new Dictionary<int, int>();
                TodasLasEtiquetasFinales2 = new Dictionary<int, int>();
                TodasLasEtiquetas = etq.obtenerTipos();
                foreach (KeyValuePair<int, int> TipyVarEtqs in TodasLasEtiquetas)
                {
                    if (TipyVarEtqs.Key == 14 || TipyVarEtqs.Key == 16)
                    {
                        foreach (KeyValuePair<int, int> EtiquetasTIPVAR in ListadeEtiquetas)
                        {
                            if ((EtiquetasTIPVAR.Key == TipyVarEtqs.Key) && (EtiquetasTIPVAR.Value == TipyVarEtqs.Value))
                                insertar = false;
                        }
                        if (insertar == true)
                        {
                            try
                            {
                                ListadeEtiquetas.Add(TipyVarEtqs.Key, TipyVarEtqs.Value);
                            }
                            catch { }
                        }

                    }
                }
                foreach (KeyValuePair<int, int> TipyVarEtqs in ListadeEtiquetas)
                {
                    if (TipyVarEtqs.Key == 14)
                        tipocatencontrado = true;
                    if (TipyVarEtqs.Key == 16)
                        tipodieencontrado = true;
                }
                if (tipocatencontrado == true && tipodieencontrado == true)
                {
                    foreach (KeyValuePair<int, int> TipyVarEtqs in TodasLasEtiquetas)
                    {
                        if (TipyVarEtqs.Key == 16)
                        {
                            TodasLasEtiquetasFinales.Add(14, 1);
                            TodasLasEtiquetasFinales2.Add(14, 1);
                        }
                        else
                        {
                            TodasLasEtiquetasFinales.Add(TipyVarEtqs.Key, TipyVarEtqs.Value);
                            TodasLasEtiquetasFinales2.Add(TipyVarEtqs.Key, TipyVarEtqs.Value);
                        }
                    }
                }
                else
                {
                    foreach (KeyValuePair<int, int> TipyVarEtqs in TodasLasEtiquetas)
                    {
                        TodasLasEtiquetasFinales.Add(TipyVarEtqs.Key, TipyVarEtqs.Value);
                        TodasLasEtiquetasFinales2.Add(TipyVarEtqs.Key, TipyVarEtqs.Value);
                    }
                }

                etq.obtenerIdiomaPallet(etq.TipoPallet, etq.VarPallet);
                columnasPorUsar = etq.obtenerCampos(TodasLasEtiquetasFinales);
                etq.EtiquetasMultiples = true;

                LlenarDGVPESOS();
                this.crearCamposAdicionales();

                if (etq.ColorEtiquetaPallet != "")
                {
                    if (DiccionarioColores.ContainsKey(etq.ColorEtiquetaPallet.ToUpper()))
                    {
                        pnColor1.BackColor = DiccionarioColores[etq.ColorEtiquetaPallet];
                        pnColor2.BackColor = DiccionarioColores[etq.ColorEtiquetaPallet];
                        if (etq.ColorEtiquetaPallet.ToUpper().Contains("_"))
                        {
                            pnColor1.Visible = false;
                            pnColor2.Visible = false;
                            string[] splits = etq.ColorEtiquetaPallet.ToUpper().Split('_');
                            string colorEtiqueta = splits[0];
                            string colorPunto = splits[1];
                            this.dibujarPuntoDeColor(colorPunto, colorEtiqueta);
                        }

                    }
                }
                else
                {
                    pnColor1.Visible = false;
                    pnColor2.Visible = false;
                }
                gb_CamposAdicionales.Visible = true;      //mostramos el grupbox
                gb_Extra.Visible = true;
                cmd_AgregarLista.Visible = true;
            }
            this.Cursor = Cursors.Default;                //regresamos el cursor al default
            filasEditadas = new List<int>();
            llenarDatosDeRegistro();
            idsRegistrosCajas.Add(int.Parse(IDregistro));
            dgv_Pesos.Rows.Clear();
            LotesdespachoyProduccion();
            cmd_AgregarLista.Visible = true;
            cmd_AgregarLista.Focus();
        }
Exemplo n.º 2
0
        private void crearCamposAdicionales()
        {
            int x = 10, y = 25;
            int x2 = 500;
            int contador = 0;
            etq = new Etiqueta_P(CProduct);
            if (etq.obtenerGenerales(etq.ClaveProducto))
            {
                foreach (KeyValuePair<string, string> campo in RegistroP)
                {
                    Label lbl = new Label();
                    TextBox txt = new TextBox();
                    ComboBox comboDirecc = new ComboBox();
                    txt.KeyDown += new KeyEventHandler(enter_tabChange);
                    contador++;
                    if (diccionario_propiedadesEtq.ContainsKey(campo.Key))
                    {
                        if (diccionario_propiedadesEtq[campo.Key] == "Etiqueta.Direccion") //el campo es una direccion
                        {
                            comboDirecc.Name = campo.Key;
                            comboDirecc.ForeColor = Color.Black;
                            comboDirecc.BackColor = Color.White;
                            comboDirecc.Location = new Point(x2, y);
                            if (etq.obtenerDireccionCliente(etq.ClaveProducto))
                            {
                                string dir = "";
                                foreach (Etiqueta_P.Estructura_Direccion direc in etq.DireccionesCliente)
                                {
                                    if (direc.pais == "")
                                        dir += direc.id.ToString() + ":  " + direc.destinatario + " | " + direc.direccion + "  " + direc.ciudad + ".  " + direc.codPostal;
                                    else
                                        dir += direc.id.ToString() + ":  " + direc.destinatario + " | " + direc.direccion + "  " + direc.ciudad + ",  " + direc.pais + ".  " + direc.codPostal;

                                    comboDirecc.Items.Add(dir);
                                    dir = "";
                                }
                            }
                            gb_CamposAdicionales.Controls.Add(comboDirecc);

                            comboDirecc.Enabled = true;
                            comboDirecc.DropDownStyle = ComboBoxStyle.DropDownList;
                            comboDirecc.SelectedIndexChanged += new EventHandler(direccionSeleccionada);
                            txt.KeyDown += new KeyEventHandler(enter_tabChange);
                            int max = 0, actual = 0;
                            if (comboDirecc.Items.Count > 0)
                            {
                                foreach (string dir in comboDirecc.Items)
                                {
                                    actual = (int)dir.Length;
                                    if (actual > max)
                                        max = actual;
                                }
                                comboDirecc.DropDownWidth = max * 6;
                                comboDirecc.SelectedIndex = 0;
                            }
                            else
                                comboDirecc.DropDownWidth = 150;

                            comboDirecc.Width = 200;

                            Button nueva = new Button();
                            nueva.TabStop = false;
                            nueva.Name = "cmdNuevaDireccion";
                            nueva.Width = comboDirecc.Width;
                            nueva.Height = comboDirecc.Height;
                            nueva.Location = new Point(comboDirecc.Location.X, comboDirecc.Location.Y + comboDirecc.Height + 10);
                            nueva.Text = "Nueva Dirección";
                            nueva.Click += new EventHandler(crearNuevaDireccion);
                            gb_CamposAdicionales.Controls.Add(nueva);
                            lbl.BringToFront();
                            lbl.AutoSize = true;
                            lbl.ForeColor = Color.Black;
                            lbl.Text = diccionario_relaciones[campo.Key];
                            lbl.Location = new Point(x, y);
                            gb_CamposAdicionales.Controls.Add(lbl);
                        }
                        else if (diccionario_propiedadesEtq[campo.Key] == "Etiqueta.Tara")
                        {
                            txt.Name = campo.Key;
                            txt.Text = campo.Value;
                            taraglobal = double.Parse(campo.Value, System.Globalization.CultureInfo.InvariantCulture);
                            txt.ForeColor = Color.Black;
                            txt.BackColor = NaranjaFuerte;
                            txt.Location = new Point(x2, y);
                            gb_CamposAdicionales.Controls.Add(txt);
                            Label tara_unidades = new Label();
                            tara_unidades.Name = "lblUnidadesTara";
                            tara_unidades.ForeColor = Color.Black;
                            tara_unidades.BackColor = Color.Transparent;
                            tara_unidades.Location = new Point(x2, y);
                            tara_unidades.Text = unidadeS;
                            gb_CamposAdicionales.Controls.Add(tara_unidades);
                            lbl.BringToFront();
                            lbl.AutoSize = true;
                            lbl.ForeColor = Color.Black;
                            lbl.Text = diccionario_relaciones[campo.Key];
                            lbl.Location = new Point(x, y);
                            gb_CamposAdicionales.Controls.Add(lbl);
                        }
                        else if (diccionario_propiedadesEtq[campo.Key] == "Etiqueta.PesoNeto")
                        {
                            txt.Name = campo.Key;
                            txt.Text = campo.Value;
                            sumatotaldepesosnetos = double.Parse(campo.Value, System.Globalization.CultureInfo.InvariantCulture);
                            txt.ForeColor = Color.Black;
                            txt.BackColor = NaranjaFuerte;
                            txt.Location = new Point(x2, y);
                            gb_CamposAdicionales.Controls.Add(txt);
                            txt.Leave += new EventHandler(Calculo_tara2);
                            Label pesoneto_unidades = new Label();
                            pesoneto_unidades.Name = "lblUnidadesPesoNeto";
                            pesoneto_unidades.ForeColor = Color.Black;
                            pesoneto_unidades.BackColor = Color.Transparent;
                            pesoneto_unidades.Location = new Point(x2, y);
                            pesoneto_unidades.Visible = true;
                            pesoneto_unidades.Text = unidadeS;
                            gb_CamposAdicionales.Controls.Add(pesoneto_unidades);
                            lbl.BringToFront();
                            lbl.AutoSize = true;
                            lbl.ForeColor = Color.Black;
                            lbl.Text = diccionario_relaciones[campo.Key];
                            lbl.Location = new Point(x, y);
                            gb_CamposAdicionales.Controls.Add(lbl);
                        }
                        else if (diccionario_propiedadesEtq[campo.Key] == "Etiqueta.PesoBruto")
                        {
                            txt.Name = campo.Key;
                            txt.Text = campo.Value;
                            sumatotalpesosbrutos = double.Parse(campo.Value, System.Globalization.CultureInfo.InvariantCulture);
                            txt.ForeColor = Color.Black;
                            txt.BackColor = NaranjaFuerte;
                            txt.Location = new Point(x2, y);
                            gb_CamposAdicionales.Controls.Add(txt);
                            txt.Leave += new EventHandler(Calculo_tara1);
                            Label pesobruto_unidades = new Label();
                            pesobruto_unidades.Name = "lblUnidadesPesoBruto";
                            pesobruto_unidades.ForeColor = Color.Black;
                            pesobruto_unidades.BackColor = Color.Transparent;
                            pesobruto_unidades.Location = new Point(x2, y);
                            pesobruto_unidades.Text = unidadeS;
                            gb_CamposAdicionales.Controls.Add(pesobruto_unidades);
                            lbl.BringToFront();
                            lbl.AutoSize = true;
                            lbl.ForeColor = Color.Black;
                            lbl.Text = diccionario_relaciones[campo.Key];
                            lbl.Location = new Point(x, y);
                            gb_CamposAdicionales.Controls.Add(lbl);
                        }
                        else
                        {
                            txt.Name = campo.Key;
                            txt.Text = campo.Value;
                            txt.ForeColor = Color.Black;
                            txt.BackColor = NaranjaFuerte;
                            txt.Location = new Point(x2, y);
                            gb_CamposAdicionales.Controls.Add(txt);
                            lbl.BringToFront();
                            lbl.AutoSize = true;
                            lbl.ForeColor = Color.Black;
                            lbl.Text = diccionario_relaciones[campo.Key];
                            lbl.Location = new Point(x, y);
                            gb_CamposAdicionales.Controls.Add(lbl);

                        }
                    }
                    else
                    {
                        txt.Name = campo.Key;
                        txt.Text = campo.Value;
                        txt.ForeColor = Color.Black;
                        txt.BackColor = NaranjaFuerte;
                        txt.Location = new Point(x2, y);
                        gb_CamposAdicionales.Controls.Add(txt);
                        lbl.BringToFront();
                        lbl.AutoSize = true;
                        lbl.ForeColor = Color.Black;
                        lbl.Text = diccionario_relaciones[campo.Key];
                        lbl.Location = new Point(x, y);
                        gb_CamposAdicionales.Controls.Add(lbl);
                    }

                }
                this.acomodarControlesDeGroupBox(gb_CamposAdicionales);
            }
            else
                MessageBox.Show("Error, no se pudo accesar al registro", "Consulta a aseguramiento de calidad");
        }