public void Valida2()
        {
            string      lsCriterio     = "";
            ClsDividirC dividirCodCaja = new ClsDividirC();

            string[] formatoC  = { "H", "P", "L", "D", "Q", "W" };
            string   lsMensaje = "";

            if (dividirCodCaja.DividirC(codigoCaja, formatoC))
            {
                lsCriterio = "WHERE WERKS = '" + dividirCodCaja.Centro + "'";
                CLSCatCentroCollection colCentros = new CLSCatCentroBAL().MostrarCatCentroBAL(lsCriterio);
                if (colCentros.Count > 0)
                {
                    CLSCatCentro centro = colCentros[0];
                    if ((centro.TipoCentro).Equals("0G00"))
                    {
                        centroC    = dividirCodCaja.Centro;
                        lsCriterio = "WHERE IDTarima = '" + tarima + "' AND WERKS = '" + centroC + "' ";
                        ClsCatZMasterCollection zMasColl = new ClsCatZMasterBAL().ConsultarZMasterBAL(lsCriterio);
                        if (zMasColl.Count > 0)
                        {
                            ClsCatZMaster zMaz = zMasColl[0];

                            if (!((zMaz.CentroDestino).Equals("")))
                            {
                                textTarima.SelectAll();
                                lsMensaje = "La tarima se encuentra en centro " + zMaz.CentroDestino;
                                textTarima.Focus();
                                throw new Exception(lsMensaje);
                            }

                            if (!((zMaz.AlmacenDestino).Equals("")))
                            {
                                textTarima.SelectAll();
                                lsMensaje = "La tarima se encuentra en almacen " + zMaz.AlmacenDestino;
                                textTarima.Focus();
                                throw new Exception(lsMensaje);
                            }

                            if (!((zMaz.UbicacionDestino).Equals("")))
                            {
                                textTarima.SelectAll();
                                lsMensaje = "La tarima se encuentra en ubicacion " + zMaz.UbicacionDestino;
                                textTarima.Focus();
                                throw new Exception(lsMensaje);
                            }
                        }
                    }
                }
            }
            else
            {
                textTarima.SelectAll();
                lsMensaje = "Codigo no valido";
                textTarima.Focus();
                throw new Exception(lsMensaje);
            }
        }
        private void ValidarDatos()
        {
            ClsNumCaja numCaja = new ClsNumCaja();

            //datos llenos
            if (textHu.Text.Trim().Length == 0 && textTarima.Text.Trim().Length == 0)
            {
                lsMensaje = "Ingresar al menos un campo";
                textHu.Focus();
                throw new Exception(lsMensaje);
            }

            //Datos de tarima llenos
            if (textTarima.Text.ToString().Trim().Length != 0)
            {
                nuevosRenglones = 39;

                if (textTarima.Text.Trim().Length < 10)
                {
                    lsMensaje = "Código incorrrecto";
                    base.MostrarError(lsMensaje);
                }
                else
                {
                    //comprueba que tenga un tamaño 10
                    if (textTarima.Text.Trim().Length == 10)
                    {
                        //comprueba que sea numerico char x char
                        for (int x = 0; x <= textTarima.Text.Length - 1; x++)
                        {
                            if (!char.IsDigit(textTarima.Text[x]))
                            {
                                lsMensaje = "Código incorrrecto";
                                base.MostrarError(lsMensaje);
                            }
                        }
                        lsCodTarima = textTarima.Text;
                    }


                    lsCriterio = "where IDTarima=" + lsCodTarima + "order by MATNR";

                    ClsCatZMasterCollection zMasterCollection;

                    zMasterCollection = (new ClsCatZMasterBAL().ConsultarZMasterBAL(lsCriterio));

                    if (zMasterCollection.Count != 0)
                    {
                        lsMensaje = "Tarima Encontrada";
                        base.MostrarMensaje(lsMensaje);

                        IEnumerator lista = zMasterCollection.GetEnumerator();

                        //ClsCatZMaster zMaster = (ClsCatZMaster)lista.Current;

                        while (lista.MoveNext())
                        {
                            ClsCatZMaster zMaster = (ClsCatZMaster)lista.Current;

                            lsFechaArmado = zMaster.FechaCreacion.ToString();
                            lsTotalCajas  = zMasterCollection.Count.ToString();
                            //lsMatnrTarima = zMaster.Matnr.ToString();
                            lsCentroCo = zMaster.Werks.ToString();
                        }

                        lsFechaArmado = lsFechaArmado.Substring(0, 10).ToString();
                        ClsTabTemZMasterCollection tablaTempCol = new ClsTabTemZMasterCollection();

                        aValoresTotales = new string[nuevosRenglones, 2];

                        #region Blancos
                        aValoresTotales[6, 0] = "&G_MATNR01&";
                        aValoresTotales[6, 1] = " ";

                        aValoresTotales[7, 0] = "&G_MAKTX01&";
                        aValoresTotales[7, 1] = " ";

                        aValoresTotales[8, 0] = "&GV_PESO01&";
                        aValoresTotales[8, 1] = " ";

                        aValoresTotales[9, 0] = "&GV_CAJA01&";
                        aValoresTotales[9, 1] = " ";

                        aValoresTotales[10, 0] = "&G_MATNR02&";
                        aValoresTotales[10, 1] = " ";

                        aValoresTotales[11, 0] = "&G_MAKTX02&";
                        aValoresTotales[11, 1] = " ";

                        aValoresTotales[12, 0] = "&GV_PESO02&";
                        aValoresTotales[12, 1] = " ";

                        aValoresTotales[13, 0] = "&GV_CAJA02&";
                        aValoresTotales[13, 1] = " ";

                        aValoresTotales[14, 0] = "&G_MATNR03&";
                        aValoresTotales[14, 1] = " ";

                        aValoresTotales[15, 0] = "&G_MAKTX03&";
                        aValoresTotales[15, 1] = " ";

                        aValoresTotales[16, 0] = "&GV_PESO03&";
                        aValoresTotales[16, 1] = " ";

                        aValoresTotales[17, 0] = "&GV_CAJA03&";
                        aValoresTotales[17, 1] = " ";

                        aValoresTotales[18, 0] = "&G_MATNR04&";
                        aValoresTotales[18, 1] = " ";

                        aValoresTotales[19, 0] = "&G_MAKTX04&";
                        aValoresTotales[19, 1] = " ";

                        aValoresTotales[20, 0] = "&GV_PESO04&";
                        aValoresTotales[20, 1] = " ";

                        aValoresTotales[21, 0] = "&GV_CAJA04&";
                        aValoresTotales[21, 1] = " ";

                        aValoresTotales[22, 0] = "&G_MATNR05&";
                        aValoresTotales[22, 1] = " ";

                        aValoresTotales[23, 0] = "&G_MAKTX05&";
                        aValoresTotales[23, 1] = " ";

                        aValoresTotales[24, 0] = "&GV_PESO05&";
                        aValoresTotales[24, 1] = " ";

                        aValoresTotales[25, 0] = "&GV_CAJA05&";
                        aValoresTotales[25, 1] = " ";

                        aValoresTotales[26, 0] = "&G_MATNR06&";
                        aValoresTotales[26, 1] = " ";

                        aValoresTotales[27, 0] = "&G_MAKTX06&";
                        aValoresTotales[27, 1] = " ";

                        aValoresTotales[28, 0] = "&GV_PESO06&";
                        aValoresTotales[28, 1] = " ";

                        aValoresTotales[29, 0] = "&GV_CAJA06&";
                        aValoresTotales[29, 1] = " ";

                        aValoresTotales[30, 0] = "&G_MATNR07&";
                        aValoresTotales[30, 1] = " ";

                        aValoresTotales[31, 0] = "&G_MAKTX07&";
                        aValoresTotales[31, 1] = " ";

                        aValoresTotales[32, 0] = "&GV_PESO07&";
                        aValoresTotales[32, 1] = " ";

                        aValoresTotales[33, 0] = "&GV_CAJA07&";
                        aValoresTotales[33, 1] = " ";

                        aValoresTotales[34, 0] = "&G_MATNR08&";
                        aValoresTotales[34, 1] = " ";

                        aValoresTotales[35, 0] = "&G_MAKTX08&";
                        aValoresTotales[35, 1] = " ";

                        aValoresTotales[36, 0] = "&GV_PESO08&";
                        aValoresTotales[36, 1] = " ";

                        aValoresTotales[37, 0] = "&GV_CAJA08&";
                        aValoresTotales[37, 1] = " ";
                        #endregion

                        /*for (int i = 0; i < zMasterCollection.Count; i++ )
                         * {*/
                        ClsTabTemZMasterCollection tabTempCol = new ClsTabTemZMasterCollection();

                        tarima2D = lsCodTarima;

                        string criterio0 = "WHERE (ZMASTER.WERKS = '" + lsCentroCo + "') AND (IDTarima = '" + lsCodTarima + "')";

                        ClsCatZMasterCollection etiquetaMaster = new ClsCatZMasterBAL().ConsultarZMasterBAL(criterio0);
                        IEnumerator             recorredor     = etiquetaMaster.GetEnumerator();
                        while (recorredor.MoveNext())
                        {
                            ClsCatZMaster claseTarima = (ClsCatZMaster)recorredor.Current;
                            cajasTarima = cajasTarima + "|H" + claseTarima.IdCaja + "|P" + claseTarima.Matnr + "|L" + claseTarima.Charg + "|D" +
                                          String.Format("{0:d}", claseTarima.FechaProduccion) + "|Q" + claseTarima.Cantidad + "|W" + claseTarima.Werks + "@";
                        }

                        tabTempCol = new ClsTabTemZMasterBAL().ConsultarMaterialesZMasterBAL(criterio0);
                        IEnumerator lista1  = tabTempCol.GetEnumerator();
                        int         valores = 5;
                        int         caja    = 1;

                        while (lista1.MoveNext())
                        {
                            ClsTabTemZMaster mastersilla = new ClsTabTemZMaster();
                            mastersilla = (ClsTabTemZMaster)lista1.Current;

                            lsMatnr = mastersilla.Matnr;
                            ClsTabTemZMasterCollection ZMaster;

                            string criterio = "INNER JOIN MARA ON ZMASTER.MATNR = MARA.MATNR ";
                            criterio = criterio + "WHERE (IDTarima = '" + lsCodTarima + "') ";
                            criterio = criterio + "AND (ZMASTER.MATNR = '" + lsMatnr + "')";
                            criterio = criterio + "AND (MARA.WERKS = '" + lsCentroCo + "')";
                            criterio = criterio + "AND (ZMASTER.WERKS = '" + lsCentroCo + "')";

                            ZMaster = new ClsTabTemZMasterBAL().ConsultaZMasterBAL(criterio);
                            IEnumerator lista2 = ZMaster.GetEnumerator();
                            int         cajas  = 0;
                            double      peso   = 0.0;
                            while (lista2.MoveNext())
                            {
                                ClsTabTemZMaster clase = (ClsTabTemZMaster)lista2.Current;
                                lsMatnr01   = clase.Matnr;
                                lsDescMatnr = clase.Descripcion;
                                cajas++;
                                peso = peso + clase.Cantidad;
                            }

                            liTotalCajasMatnr01 = cajas;
                            liTotalKilos        = peso;
                            totalKilosGral      = totalKilosGral + liTotalKilos;

                            valores++;
                            aValoresTotales[valores, 0] = "&G_MATNR0" + caja + "&";
                            aValoresTotales[valores, 1] = lsMatnr01;
                            valores++;
                            aValoresTotales[valores, 0] = "&G_MAKTX0" + caja + "&";
                            aValoresTotales[valores, 1] = lsDescMatnr;
                            valores++;
                            aValoresTotales[valores, 0] = "&GV_PESO0" + caja + "&";
                            aValoresTotales[valores, 1] = liTotalKilos.ToString();
                            valores++;
                            aValoresTotales[valores, 0] = "&GV_CAJA0" + caja + "&";
                            aValoresTotales[valores, 1] = liTotalCajasMatnr01.ToString();
                            caja++;
                        }

                        //liTotalKilos = Convert.ToDecimal(liTotalKilos) + Convert.ToDecimal(zMasterCollection[i].Cantidad.ToString());
                        //int x = 1;

                        //if (zMasterCollection[i].Matnr.ToString() != zMasterCollection[1].Matnr.ToString())
                        //{
                        //    liTotalKilosMatnr02 = Convert.ToDecimal(liTotalKilosMatnr02) + Convert.ToDecimal(zMasterCollection[i].Cantidad.ToString());
                        //    liTotalCajasMatnr02 = liTotalCajasMatnr02 + x;
                        //    lsMatnr02 = zMasterCollection[i].Matnr;
                        //}
                        //else
                        //{
                        //    tablaTemp.Matnr = zMasterCollection[i].Matnr;
                        //    liTotalKilosMatnr01 = Convert.ToDecimal(liTotalKilosMatnr01) + Convert.ToDecimal(zMasterCollection[i].Cantidad.ToString());
                        //    liTotalCajasMatnr01 = liTotalCajasMatnr01 + x;


                        //    ClsMARACollection maraCollection;
                        //    maraCollection = (new ClsMARABAL().ConsultarMARABAL("where MATNR ='" + lsMatnr01 + "'"));
                        //    if (maraCollection.Count != 0)
                        //    {
                        //        IEnumerator lista1 = maraCollection.GetEnumerator();
                        //        while (lista1.MoveNext())
                        //        {
                        //            ClsMARA mara = (ClsMARA)lista1.Current;
                        //            lsDescMatnrTarima01 = mara.Maktx.ToString();
                        //        }
                        //    }
                        //}
                        //}


                        //       DialogResult result = MessageBox.Show("Los Datos a Imprimir son :  Num Tarima: " + lsCodTarima +
                        //", Fecha Armado: " + lsFechaArmado + ",\n Total Cajas: " + lsTotalCajas +
                        //", Total Kilos: " + liTotalKilos + ",\n " +
                        // " Cajas Ma: " + liTotalCajasMatnr01 + "****** Material: " + lsMatnr01 +
                        //"****** Descripcion: " + lsDescMatnrTarima01 + "****** kilos: " + liTotalKilosMatnr01 +"\n" +
                        // " Cajas Ma: " + liTotalCajasMatnr02 + "****** Material: " + lsMatnr02 +
                        //"****** Descripcion: " + lsDescMatnrTarima02 + "****** kilos: " + liTotalKilosMatnr02
                        //, "Tarima", MessageBoxButtons.YesNo);

                        /*if (result == DialogResult.YeS)
                         * {*/
                        MessageBox.Show("Imprimiendo Etiqueta");

                        string ruta          = ClsFunciones.ObtenerValorEntorno(Variables.SistemaOperativo);
                        string nombreArchivo = ruta + "Tarima.zpl";

                        ImprimirEtiquetaGenericaTarimas(nombreArchivo, GetImpresoraDefecto());

                        /*}
                         * else if (result == DialogResult.No)
                         * {
                         *
                         * }*/
                    }
                    else
                    {
                        lsMensaje = "No se encuentra la Tarima";
                        base.MostrarError(lsMensaje);
                    }
                }
            }
            // Caja
            else if (textHu.Text.ToString().Trim().Length != 0)
            {
                if (textHu.Text.Trim().Length < 10)
                {
                    lsMensaje = "Código incorrrecto";
                    base.MostrarError(lsMensaje);
                }
                else
                {
                    //comprueba que tenga un tamaño 10
                    if (textHu.Text.Trim().Length == 10)
                    {
                        //comprueba que sea numerico char x char
                        for (int x = 0; x <= textHu.Text.Length - 1; x++)
                        {
                            if (!char.IsDigit(textHu.Text[x]))
                            {
                                //  lbCajaCorrecto = false;
                                lsMensaje = "Código incorrrecto";
                                //break;
                                base.MostrarError(lsMensaje);
                            }
                        }

                        lsCodHU = textHu.Text;
                    }
                    else
                    {
                        //si no tiene 10 digitos es un codigo se comprueba que sea codigo 2d
                        if (textHu.Text.Substring(0, 1).Equals("H"))
                        {
                            ClsDividirC divCodigo = new ClsDividirC();
                            //H1001009875|P134303C1|L0014399446|D24/04/2012|Q     30.0 |W0R00
                            string[] formatoC = { "H", "P", "L", "D", "Q", "W" };
                            if (divCodigo.DividirC(textHu.Text, formatoC))
                            {
                                lsCodHU        = divCodigo.NumCaja;
                                lsLote         = divCodigo.NumLoteProd;
                                lsMatnr        = divCodigo.NumParete;
                                lsFechaCaja    = Convert.ToDateTime(divCodigo.FechProd);
                                lsPesoNetoCaja = divCodigo.Cant;
                                lsCentroCo     = divCodigo.Centro;
                            }
                        }
                    }

                    lsCriterio = "where EXIDV= '" + lsCodHU + "' and MOV_HU='X'";

                    ClsZTPPLogsCollection zLogsCollection;
                    zLogsCollection = (new ClsZTPPLogsBAL().ConsultarZTPPLogsBAL(lsCriterio));

                    if (zLogsCollection.Count != 0)
                    {
                        IEnumerator lista = zLogsCollection.GetEnumerator();

                        while (lista.MoveNext())
                        {
                            ClsZTPPLogs zLogs = (ClsZTPPLogs)lista.Current;

                            lsCentroCo     = zLogs.Werks.ToString();
                            lsMatnr        = zLogs.Matnr.ToString();
                            lsFechaCaja    = zLogs.Fecha;
                            lsAufnr        = zLogs.Aufnr.ToString();
                            lsPesoNetoCaja = zLogs.Vemng.ToString();
                        }

                        lsTipo = lsMatnr.Substring(0, 2);


                        switch (lsTipo)
                        {
                        case "11":
                            textoTipo = "VACIO";
                            break;

                        case "12":
                            textoTipo = "CONGELADO";
                            break;

                        case "13":
                            textoTipo = "FRESCO";
                            break;

                        default:
                            string lsMensaje1;
                            lsMensaje1 = "Tipo de producto no valido";
                            throw new Exception(lsMensaje1);
                        }

                        lsCriterio = "as zt inner join OPCS as o on zt.AUFNR = o.AUFNR where zt.AUFNR ='" + lsAufnr + "' and zt.MOV_HU='X' AND (zt.WERKS = '" +
                                     lsCentroCo + "') AND (EXIDV = '" + lsCodHU + "')";

                        zLogsCollection = new ClsZTPPLogsBAL().ObtenerChargReimpresionBAL(lsCriterio);

                        if (zLogsCollection.Count != 0)
                        {
                            lsLote = zLogsCollection[0].Charg;
                        }

                        ClsMARACollection maraCollection;
                        maraCollection = (new ClsMARABAL().ConsultarMARABAL("where MATNR ='" + lsMatnr + "' and WERKS = '" + lsCentroCo + "'"));
                        if (maraCollection.Count != 0)
                        {
                            IEnumerator lista1 = maraCollection.GetEnumerator();
                            while (lista1.MoveNext())
                            {
                                ClsMARA mara = (ClsMARA)lista1.Current;
                                lsDescMatnr = mara.Maktx.ToString();
                                lsEtiar     = mara.Etiar;
                                lsEtifo     = mara.Etifo;
                            }
                        }

                        fechaCad = numCaja.regresaFecha(lsMatnr, Convert.ToDateTime(lsFechaCaja), lsCentroCo);

                        lsMensaje = "Caja Encontrada";
                        base.MostrarMensaje(lsMensaje);
                    }
                    else
                    {
                        lsMensaje = "No se encontra la Caja";
                        base.MostrarError(lsMensaje);
                    }
                }
            }
        }
Beispiel #3
0
        private void ValidarDatos()
        {
            bool   lbCentroCorrecto  = true;
            bool   lbAlmacenCorrecto = true;
            bool   lbCajaCorrecto    = true;
            string lsMensaje         = "";
            string criterio;

            try
            {
                if (textCentro.Text.Trim().Length == 0)
                {
                    lbCentroCorrecto = false;
                }

                criterio = "WHERE WERKS = '" + textCentro.Text + "'";
                CLSCatCentroCollection centrosColeccion;
                centrosColeccion = (new CLSCatCentroBAL()).MostrarCatCentroBAL(criterio);

                if (centrosColeccion.Count == 0)
                {
                    lbCentroCorrecto = false;
                }
                if (lbCentroCorrecto == false)
                {
                    textCentro.SelectAll();
                    textCentro.Focus();
                    textAlmacen.Text = Variables.Blanco;
                    textCaja.Text    = Variables.Blanco;
                    lsMensaje        = "El centro no existe";
                    throw new Exception(lsMensaje);
                }
            }
            catch
            {
                throw;
            }


            try
            {
                if (textAlmacen.Text.Trim().Length == 0)
                {
                    lbAlmacenCorrecto = false;
                }
                //if (textBascula.Text.Trim().StartsWith("0") == false)
                criterio = "WHERE LGORT = '" + textAlmacen.Text + "' AND WERKS = '" + textCentro.Text + "'";
                ClsCatAlmacenCollection almacenColeccion;
                almacenColeccion = (new ClsCatAlmacenBAL()).ConsultarAlmacenesBAL(criterio);

                if (almacenColeccion.Count == 0)
                {
                    lbAlmacenCorrecto = false;
                }
                if (lbAlmacenCorrecto == false)
                {
                    textAlmacen.SelectAll();
                    lsMensaje     = "El almacén no existe";
                    textCaja.Text = Variables.Blanco;
                    textAlmacen.Focus();

                    throw new Exception(lsMensaje);
                }
            }
            catch
            {
                throw;
            }

            try
            {
                if (textCaja.Text.Trim().Length < 10)
                {
                    lbCajaCorrecto = false;
                    lsMensaje      = "Código incorrrecto";
                }
                else
                {
                    //comprueba que tenga un tamaño 10
                    if (textCaja.Text.Trim().Length == 10)
                    {
                        //comprueba que sea numerico char x char
                        for (int x = 0; x <= textCaja.Text.Length - 1; x++)
                        {
                            if (!(char.IsDigit(textCaja.Text[x])))
                            {
                                lbCajaCorrecto = false;
                                lsMensaje      = "Código incorrrecto";
                                break;
                            }
                        }


                        //busca si ya existe en la coleccion
                        caja = textCaja.Text;
                        if (lbCajaCorrecto)
                        {
                            if (BuscarEnColeccion(caja))
                            {
                                lbCajaCorrecto = false;
                                lsMensaje      = "La caja ya existe";
                            }
                            //buscar en ztpp_logs
                            string lsCriterio             = " WHERE EXIDV = " + textCaja.Text;
                            ClsZTPPLogsCollection colLogs = new ClsZTPPLogsBAL().ConsultarZTPPLogsBAL(lsCriterio);

                            if (colLogs.Count == 0)
                            {
                                lbCajaCorrecto = false;
                                lsMensaje      = "El código " + textCaja.Text + " no existe en ZtppLogs";
                            }
                        }
                    }
                    else
                    {
                        //si  tiene > 10 digitos es un codigo se comprueba que sea codigo 2d
                        if (textCaja.Text.Substring(0, 1).Equals("H"))
                        {
                            divCodigo = new ClsDividirC();
                            //H8500000142|P134303C1|L0014399446|D24/04/2012|Q     30.0 |W0R00
                            //H8500000143|P134303C1|L0014399446|D24/04/2012|Q     30.0 |W0R00
                            //H8500000144|P134303C1|L0014399446|D24/04/2012|Q     30.0 |W0R00
                            //H8500000145|P134303C1|L0014399446|D24/04/2012|Q     30.0 |W0R00
                            string[] formatoC = { "H", "P", "L", "D", "Q", "W" };
                            if (divCodigo.DividirC(textCaja.Text, formatoC))
                            {
                                string centroCo = divCodigo.Centro;
                                caja = divCodigo.NumCaja;
                                if (BuscarEnColeccion(caja))
                                {
                                    lbCajaCorrecto = false;
                                    lsMensaje      = "La caja ya existe";
                                }
                                else
                                {
                                    if ((textCentro.Text).Equals(centroCo))
                                    {
                                    }
                                    else
                                    {
                                        lbCajaCorrecto = false;
                                        lsMensaje      = "El centro no coincide";
                                    }
                                }
                            }
                            else
                            {
                                lbCajaCorrecto = false;
                                lsMensaje      = "Código incorrrecto";
                                textCaja.Text  = Variables.Blanco;
                            }
                        }
                        else
                        {
                            lbCajaCorrecto = false;
                            lsMensaje      = "Código incorrrecto";
                            textCaja.Text  = Variables.Blanco;
                        }
                    }
                    //aqui sale
                }

                if (lbCajaCorrecto == false)
                {
                    textCaja.SelectAll();
                    textCaja.Text = Variables.Blanco;
                    textCaja.Focus();
                    throw new Exception(lsMensaje);
                }
                else
                {
                    Agregar();
                    //AgregarACollection();
                    dgvLista.Rows.Add(caja);
                }
            }
            catch
            {
                throw;
            }
        }