コード例 #1
0
ファイル: frmScan.cs プロジェクト: rhernandezopengate/open
        private void TxtOrden_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((int)e.KeyChar == (int)Keys.Enter)
            {
                string orden = this.txtOrden.Text;
                string picker;
                ctrlScan = new scanController();
                if (ctrlScan.ExisteOrden(orden))
                {
                    if (ctrlScan.OrdenCerrada(orden))
                    {
                        do
                        {
                            SystemSounds.Beep.Play();

                            picker = Microsoft.VisualBasic.Interaction.InputBox("ESCANEAR CODIGO DE PICKER QUE SURTIO LA ORDEN", "CODIGO DE PICKER");

                            string pickerValidacion = ListaPicker().Where(x => x.Equals(picker.ToUpper())).FirstOrDefault();

                            if (pickerValidacion == null)
                            {
                                picker = string.Empty;
                            }
                        } while (picker.Equals(string.Empty));

                        ListaInicial          = ctrlScan.DetalleOrden(orden);
                        ListaQR               = new List <codigoqrordenes>();
                        ListaErrores          = new List <erroresordenes>();
                        lblOrdenId.Text       = ctrlScan.IdOrdenByOrden(orden).ToString();
                        lblPicker.Text        = picker.ToUpper();
                        this.txtOrden.Enabled = false;
                        this.dataGridView1.AutoGenerateColumns = false;
                        this.dataGridView1.DataSource          = ListaInicial;
                    }
                    else
                    {
                        SystemSounds.Asterisk.Play();

                        MessageBox.Show("ORDEN CERRADA");

                        this.txtOrden.Text = "";
                        this.txtOrden.Focus();
                    }
                }
                else
                {
                    SystemSounds.Asterisk.Play();
                    MessageBox.Show("ORDEN NO EXISTE");
                    this.txtOrden.Text = "";
                    this.txtOrden.Focus();
                }
                e.Handled = true;
            }
        }
コード例 #2
0
ファイル: frmScan.cs プロジェクト: rhernandezopengate/open
        private async void TxtProducto_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((int)e.KeyChar == (int)Keys.Enter)
            {
                ctrlScan = new scanController();
                string producto = this.txtProducto.Text.ToUpper();
                string orden    = this.txtOrden.Text.ToUpper();
                if (ctrlScan.ExisteSKU(producto))
                {
                    if (ctrlScan.IsKit(producto))
                    {
                        if (ctrlScan.CantidadKitCorrecta(producto, ListaInicial))
                        {
                            foreach (var item in ctrlScan.ListaKit(producto))
                            {
                                int cantidadEscaneados = (int)ListaInicial.Where(x => x.SKU.Equals(item.skus.Sku)).Sum(x => x.CantidadEscaneos);
                                int cantidadAgregar    = cantidadEscaneados + (int)item.Cantidad;

                                var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(item.skus.Sku)).FirstOrDefault();
                                cantidadEscaneado.CantidadEscaneos = cantidadAgregar;
                            }
                        }
                        else
                        {
                            SystemSounds.Asterisk.Play();
                            string respuesta;

                            do
                            {
                                respuesta = Microsoft.VisualBasic.Interaction.InputBox("LA CANTIDAD DEL PAH O KIT ES MAYOR A LA SOLICITADA EN LA ORDEN");
                            } while (respuesta.ToUpper() != "OK");

                            ErrorSobrante();
                        }

                        this.dataGridView1.DataSource = null;
                        this.dataGridView1.DataSource = ListaInicial;
                        this.txtProducto.Text         = "";
                        this.txtProducto.Focus();

                        if (ListaInicial.Sum(x => x.CantidadEscaneos) == (ListaInicial.Sum(x => x.cantidad) * -1))
                        {
                            //Cerrar Orden
                            string guia;

                            SystemSounds.Beep.Play();

                            do
                            {
                                guia = Microsoft.VisualBasic.Interaction.InputBox("ESCANEAR GUIA");

                                if (guia != string.Empty)
                                {
                                    if (guia.ToUpper().Equals("NA"))
                                    {
                                        SystemSounds.Asterisk.Play();
                                        MessageBox.Show("ESTA ORDEN NO SE PUEDE CERRAR, SIN LA GUIA CORRECTA, DEBE LIMPIAR LA ORDEN Y COMENZAR NUEVAMENTE.");
                                        break;
                                    }
                                    else if (guia.ToUpper().Equals("M"))
                                    {
                                        //Cerrar Orden
                                        bool qr = await ctrlScan.CapturaQR(ListaQR);

                                        bool error = await ctrlScan.CapturaErrores(ListaErrores);

                                        bool agregarauditor = await ctrlScan.AgregarAuditor(orden, this.lblAuditor.Text);

                                        bool cerrarorden = await ctrlScan.CerrarOrdenSinGuia(orden, this.lblPicker.Text.ToUpper());

                                        Limpiar();
                                        break;
                                    }
                                    else
                                    {
                                        if (ctrlScan.ExisteGuia(guia))
                                        {
                                            if (ctrlScan.GuiaOrden(orden, guia))
                                            {
                                                //Cerrar Orden
                                                bool qr = await ctrlScan.CapturaQR(ListaQR);

                                                bool error = await ctrlScan.CapturaErrores(ListaErrores);

                                                bool agregarauditor = await ctrlScan.AgregarAuditor(orden, this.lblAuditor.Text);

                                                bool cerrarorden = await ctrlScan.CerrarOrden(orden, this.lblPicker.Text.ToUpper());

                                                Limpiar();
                                            }
                                            else
                                            {
                                                SystemSounds.Asterisk.Play();

                                                MessageBox.Show("GUIA NO PERTENECE A LA ORDEN");
                                                guia = string.Empty;
                                                ErrorGuiaIncorrecta();
                                            }
                                        }
                                        else
                                        {
                                            SystemSounds.Asterisk.Play();
                                            MessageBox.Show("GUIA NO EXISTE");
                                            guia = string.Empty;
                                        }
                                    }
                                }
                            }while (guia.Equals(string.Empty));
                        }
                    }
                    else
                    {
                        if (ctrlScan.SKUPerteneceOrden(orden, producto))
                        {
                            int cantidadBD         = (int)ListaInicial.Where(x => x.SKU.Equals(producto)).Sum(x => x.cantidad * -1);
                            int cantidadEscaneados = (int)ListaInicial.Where(x => x.SKU.Equals(producto)).Sum(x => x.CantidadEscaneos);

                            if (ctrlScan.IsQRCode(producto))
                            {
                                int cantidadAgregar = cantidadEscaneados + 1;

                                if (cantidadAgregar <= cantidadBD)
                                {
                                    string qrcode;
                                    SystemSounds.Beep.Play();
                                    do
                                    {
                                        qrcode = Microsoft.VisualBasic.Interaction.InputBox("ESCANEAR CODIGO QR");

                                        if (qrcode != string.Empty)
                                        {
                                            if (qrcode.Length < 15)
                                            {
                                                SystemSounds.Asterisk.Play();
                                                MessageBox.Show("CODIGO QR NO VALIDO");
                                                qrcode = string.Empty;
                                            }
                                            else
                                            {
                                                var validarqr = ListaQR.Where(x => x.CodigoQR.Equals(qrcode)).FirstOrDefault();

                                                if (validarqr == null)
                                                {
                                                    var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(producto)).FirstOrDefault();
                                                    cantidadEscaneado.CantidadEscaneos = cantidadAgregar;

                                                    codigoqrordenes codigoqrordenes = new codigoqrordenes();
                                                    codigoqrordenes.CodigoQR   = qrcode;
                                                    codigoqrordenes.Ordenes_Id = int.Parse(lblOrdenId.Text);
                                                    ListaQR.Add(codigoqrordenes);
                                                }
                                                else
                                                {
                                                    SystemSounds.Asterisk.Play();
                                                    MessageBox.Show("EL CODIGO QR NO PUEDE ESTAR REPETIDO");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            SystemSounds.Asterisk.Play();
                                            MessageBox.Show("EL CODIGO QR NO PUEDE ESTAR VACIO");
                                        }
                                    } while (qrcode.Equals(string.Empty));
                                }
                                else
                                {
                                    string respuesta;

                                    do
                                    {
                                        SystemSounds.Asterisk.Play();
                                        respuesta = Microsoft.VisualBasic.Interaction.InputBox("YA SE HA COMPLETADO EL ESCANEO DE ESTE SKU");
                                    } while (respuesta.ToUpper() != "OK");

                                    ErrorSobrante();
                                }
                            }
                            else if (ctrlScan.IsQTYManual(producto))
                            {
                                string qty;
                                do
                                {
                                    qty = Microsoft.VisualBasic.Interaction.InputBox("CAPTURE LA CANTIDAD DE SKUS");

                                    int cantidadAgregar = cantidadEscaneados + int.Parse(qty);

                                    if (cantidadAgregar <= cantidadBD)
                                    {
                                        var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(producto)).FirstOrDefault();
                                        cantidadEscaneado.CantidadEscaneos = cantidadAgregar;
                                    }
                                    else
                                    {
                                        string respuesta;
                                        do
                                        {
                                            SystemSounds.Asterisk.Play();
                                            respuesta = Microsoft.VisualBasic.Interaction.InputBox("LA CANTIDAD DE SKUS NO PUEDE SER MAYOR A LA DE LA ORDEN");
                                        } while (respuesta.ToUpper() != "OK");

                                        ErrorSobrante();
                                    }
                                } while (qty.Equals(string.Empty));
                            }
                            else
                            {
                                int cantidadAgregar = cantidadEscaneados + 1;

                                if (cantidadAgregar <= cantidadBD)
                                {
                                    var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(producto)).FirstOrDefault();
                                    cantidadEscaneado.CantidadEscaneos = cantidadAgregar;
                                }
                                else
                                {
                                    string respuesta;

                                    do
                                    {
                                        SystemSounds.Asterisk.Play();
                                        respuesta = Microsoft.VisualBasic.Interaction.InputBox("YA SE HA COMPLETADO EL ESCANEO DE ESTE SKU");
                                    } while (respuesta.ToUpper() != "OK");

                                    ErrorSobrante();
                                }
                            }

                            this.dataGridView1.DataSource = null;
                            this.dataGridView1.DataSource = ListaInicial;
                            this.txtProducto.Text         = "";
                            this.txtProducto.Focus();

                            if (ListaInicial.Sum(x => x.CantidadEscaneos) == (ListaInicial.Sum(x => x.cantidad) * -1))
                            {
                                string guia;
                                SystemSounds.Beep.Play();
                                do
                                {
                                    guia = Microsoft.VisualBasic.Interaction.InputBox("ESCANEAR GUIA");

                                    if (guia != string.Empty)
                                    {
                                        if (guia.ToUpper().Equals("NA"))
                                        {
                                            SystemSounds.Asterisk.Play();
                                            MessageBox.Show("ESTA ORDEN NO SE PUEDE CERRAR, SIN LA GUIA CORRECTA, DEBE LIMPIAR LA ORDEN Y COMENZAR NUEVAMENTE.");
                                            break;
                                        }
                                        else if (guia.ToUpper().Equals("M"))
                                        {
                                            //Cerrar Orden
                                            bool qr = await ctrlScan.CapturaQR(ListaQR);

                                            bool error = await ctrlScan.CapturaErrores(ListaErrores);

                                            bool agregarauditor = await ctrlScan.AgregarAuditor(orden, this.lblAuditor.Text);

                                            bool cerrarorden = await ctrlScan.CerrarOrdenSinGuia(orden, this.lblPicker.Text.ToUpper());

                                            Limpiar();
                                            break;
                                        }
                                        else
                                        {
                                            if (ctrlScan.ExisteGuia(guia))
                                            {
                                                if (ctrlScan.GuiaOrden(orden, guia))
                                                {
                                                    //Cerrar Orden
                                                    bool qr = await ctrlScan.CapturaQR(ListaQR);

                                                    bool error = await ctrlScan.CapturaErrores(ListaErrores);

                                                    bool agregarauditor = await ctrlScan.AgregarAuditor(orden, this.lblAuditor.Text);

                                                    bool cerrarorden = await ctrlScan.CerrarOrden(orden, this.lblPicker.Text.ToUpper());

                                                    Limpiar();
                                                }
                                                else
                                                {
                                                    SystemSounds.Asterisk.Play();
                                                    MessageBox.Show("GUIA NO PERTENECE A LA ORDEN");
                                                    guia = string.Empty;
                                                    ErrorGuiaIncorrecta();
                                                }
                                            }
                                            else
                                            {
                                                SystemSounds.Asterisk.Play();
                                                MessageBox.Show("GUIA NO EXISTE");
                                                guia = string.Empty;
                                            }
                                        }
                                    }
                                }while (guia.Equals(string.Empty));
                            }
                        }
                        else
                        {
                            string respuesta;

                            do
                            {
                                SystemSounds.Asterisk.Play();
                                respuesta = Microsoft.VisualBasic.Interaction.InputBox("ESTE SKU NO PERTENECE A LA ORDEN");
                            } while (respuesta.ToUpper() != "OK");

                            ErrorSkuIncorrecto();
                            this.txtProducto.Text = "";
                            this.txtProducto.Focus();
                        }
                    }
                }
                else if (ctrlScan.IsBenevidesCode(producto))
                {
                    string skuvalido = ctrlScan.SkuValidoDesdeBenavides(producto);
                    if (ctrlScan.SKUPerteneceOrden(orden, skuvalido))
                    {
                        int cantidadBD         = (int)ListaInicial.Where(x => x.SKU.Equals(skuvalido)).Sum(x => x.cantidad * -1);
                        int cantidadEscaneados = (int)ListaInicial.Where(x => x.SKU.Equals(skuvalido)).Sum(x => x.CantidadEscaneos);

                        if (ctrlScan.IsQRCode(skuvalido))
                        {
                            int cantidadAgregar = cantidadEscaneados + 1;

                            if (cantidadAgregar <= cantidadBD)
                            {
                                string qrcode;
                                SystemSounds.Beep.Play();
                                do
                                {
                                    qrcode = Microsoft.VisualBasic.Interaction.InputBox("ESCANEAR CODIGO QR");

                                    if (qrcode != string.Empty)
                                    {
                                        if (qrcode.Length < 15)
                                        {
                                            SystemSounds.Asterisk.Play();
                                            MessageBox.Show("CODIGO QR NO VALIDO");
                                            qrcode = string.Empty;
                                        }
                                        else
                                        {
                                            var validarqr = ListaQR.Where(x => x.CodigoQR.Equals(qrcode)).FirstOrDefault();

                                            if (validarqr == null)
                                            {
                                                var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(skuvalido)).FirstOrDefault();
                                                cantidadEscaneado.CantidadEscaneos = cantidadAgregar;

                                                codigoqrordenes codigoqrordenes = new codigoqrordenes();
                                                codigoqrordenes.CodigoQR   = qrcode;
                                                codigoqrordenes.Ordenes_Id = int.Parse(lblOrdenId.Text);
                                                ListaQR.Add(codigoqrordenes);
                                            }
                                            else
                                            {
                                                SystemSounds.Asterisk.Play();
                                                MessageBox.Show("EL CODIGO QR NO PUEDE ESTAR REPETIDO");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        SystemSounds.Asterisk.Play();
                                        MessageBox.Show("EL CODIGO QR NO PUEDE ESTAR VACIO");
                                    }
                                } while (qrcode.Equals(string.Empty));
                            }
                            else
                            {
                                string respuesta;

                                do
                                {
                                    SystemSounds.Asterisk.Play();
                                    respuesta = Microsoft.VisualBasic.Interaction.InputBox("YA SE HA COMPLETADO EL ESCANEO DE ESTE SKU");
                                } while (respuesta.ToUpper() != "OK");

                                ErrorSobrante();
                            }
                        }
                        else if (ctrlScan.IsQTYManual(skuvalido))
                        {
                            string qty;
                            do
                            {
                                qty = Microsoft.VisualBasic.Interaction.InputBox("CAPTURE LA CANTIDAD DE SKUS");

                                int cantidadAgregar = cantidadEscaneados + int.Parse(qty);

                                if (cantidadAgregar <= cantidadBD)
                                {
                                    var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(skuvalido)).FirstOrDefault();
                                    cantidadEscaneado.CantidadEscaneos = cantidadAgregar;
                                }
                                else
                                {
                                    string respuesta;
                                    do
                                    {
                                        SystemSounds.Asterisk.Play();
                                        respuesta = Microsoft.VisualBasic.Interaction.InputBox("LA CANTIDAD DE SKUS NO PUEDE SER MAYOR A LA DE LA ORDEN");
                                    } while (respuesta.ToUpper() != "OK");

                                    ErrorSobrante();
                                }
                            } while (qty.Equals(string.Empty));
                        }
                        else
                        {
                            int cantidadAgregar = cantidadEscaneados + 1;

                            if (cantidadAgregar <= cantidadBD)
                            {
                                var cantidadEscaneado = ListaInicial.Where(x => x.SKU.Equals(skuvalido)).FirstOrDefault();
                                cantidadEscaneado.CantidadEscaneos = cantidadAgregar;
                            }
                            else
                            {
                                string respuesta;

                                do
                                {
                                    SystemSounds.Asterisk.Play();
                                    respuesta = Microsoft.VisualBasic.Interaction.InputBox("YA SE HA COMPLETADO EL ESCANEO DE ESTE SKU");
                                } while (respuesta.ToUpper() != "OK");

                                ErrorSobrante();
                            }
                        }

                        this.dataGridView1.DataSource = null;
                        this.dataGridView1.DataSource = ListaInicial;
                        this.txtProducto.Text         = "";
                        this.txtProducto.Focus();

                        if (ListaInicial.Sum(x => x.CantidadEscaneos) == (ListaInicial.Sum(x => x.cantidad) * -1))
                        {
                            string guia;
                            SystemSounds.Beep.Play();
                            do
                            {
                                guia = Microsoft.VisualBasic.Interaction.InputBox("ESCANEAR GUIA");

                                if (guia != string.Empty)
                                {
                                    if (guia.ToUpper().Equals("NA"))
                                    {
                                        SystemSounds.Asterisk.Play();
                                        MessageBox.Show("ESTA ORDEN NO SE PUEDE CERRAR, SIN LA GUIA CORRECTA, DEBE LIMPIAR LA ORDEN Y COMENZAR NUEVAMENTE.");
                                        break;
                                    }
                                    else if (guia.ToUpper().Equals("M"))
                                    {
                                        //Cerrar Orden
                                        bool qr = await ctrlScan.CapturaQR(ListaQR);

                                        bool error = await ctrlScan.CapturaErrores(ListaErrores);

                                        bool agregarauditor = await ctrlScan.AgregarAuditor(orden, this.lblAuditor.Text);

                                        bool cerrarorden = await ctrlScan.CerrarOrdenSinGuia(orden, this.lblPicker.Text.ToUpper());

                                        Limpiar();
                                        break;
                                    }
                                    else
                                    {
                                        if (ctrlScan.ExisteGuia(guia))
                                        {
                                            if (ctrlScan.GuiaOrden(orden, guia))
                                            {
                                                //Cerrar Orden
                                                bool qr = await ctrlScan.CapturaQR(ListaQR);

                                                bool error = await ctrlScan.CapturaErrores(ListaErrores);

                                                bool agregarauditor = await ctrlScan.AgregarAuditor(orden, this.lblAuditor.Text);

                                                bool cerrarorden = await ctrlScan.CerrarOrden(orden, this.lblPicker.Text.ToUpper());

                                                Limpiar();
                                            }
                                            else
                                            {
                                                SystemSounds.Asterisk.Play();
                                                MessageBox.Show("GUIA NO PERTENECE A LA ORDEN");
                                                guia = string.Empty;
                                                ErrorGuiaIncorrecta();
                                            }
                                        }
                                        else
                                        {
                                            SystemSounds.Asterisk.Play();
                                            MessageBox.Show("GUIA NO EXISTE");
                                            guia = string.Empty;
                                        }
                                    }
                                }
                            }while (guia.Equals(string.Empty));
                        }
                    }
                    else
                    {
                        string respuesta;

                        do
                        {
                            SystemSounds.Asterisk.Play();
                            respuesta = Microsoft.VisualBasic.Interaction.InputBox("ESTE SKU NO PERTENECE A LA ORDEN");
                        } while (respuesta.ToUpper() != "OK");

                        ErrorSkuIncorrecto();
                        this.txtProducto.Text = "";
                        this.txtProducto.Focus();
                    }
                }
                else
                {
                    string respuesta;

                    do
                    {
                        SystemSounds.Asterisk.Play();
                        respuesta = Microsoft.VisualBasic.Interaction.InputBox("ESTE SKU NO EXISTE");
                    } while (respuesta.ToUpper() != "OK");

                    this.txtProducto.Text = "";
                    this.txtProducto.Focus();
                }

                e.Handled = true;
            }
        }