예제 #1
0
파일: FrmEmpaque.cs 프로젝트: JCMDIAZ/SWYRA
        private void pbImprimir_Click(object sender, EventArgs e)
        {
            if (valExistencias() > 0)
            {
                Close(); return;
            }

            DialogResult dr = DialogResult.OK;

            if (validaExisMerc(2))
            {
                FrmSurtir4 frmConf = new FrmSurtir4();
                frmConf.lblCom.Text = "El Pedido ya tiene impreso las etiquetas.";
                frmConf.label1.Text = "¿DESEAS IMPRIMIRLO DE NUEVO?";
                dr = frmConf.ShowDialog();
                frmConf.Close();
            }

            if (dr == DialogResult.OK)
            {
                var query2 = "UPDATE DETALLEPEDIDOMERC SET CANCELADO = 1 WHERE LTRIM(CVE_DOC) = '" + ped.cve_doc.Trim() +
                             "' AND ISNULL(TIPOPAQUETE,'') <> '' AND ISNULL(TotArt,0) = 0 AND ISNULL(CANCELADO,0) = 0";
                Program.GetExecute(query2, 51);

                ActualizaPedido();
                cargaPaquetes("CONSEC_EMPAQUE");
                cargaDetalleMerc();

                // Printer IP Address and communication port
                string ipAddress = Program.ipImpEti();
                int    port      = 9100;

                // ZPL Command(s)
                string ZPLString = GeneraEtiqueta();

                try
                {
                    // Open connection
                    TcpClient client = new TcpClient();
                    client.Connect(ipAddress, port);

                    // Write ZPL String to connection
                    StreamWriter writer = new StreamWriter(client.GetStream());
                    writer.Write(ZPLString);
                    writer.Flush();

                    // Close Connection
                    writer.Close();
                    client.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Impresora no disponible, favor de validar", "SWYRA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return;
                }

                try
                {
                    var query = "UPDATE DETALLEPEDIDOMERC SET ULTIMO = 1 WHERE (LTRIM(CVE_DOC) = '" + ped.cve_doc.Trim() + "') AND (CODIGO_BARRA <> '') " +
                                "AND (ISNULL(CANCELADO, 0) = 0) AND (ISNULL(TIPOPAQUETE,'') NOT IN ('', 'ATADOS', 'TARIMA')) AND (ISNULL(ULTIMO,0) = 0) ";
                    Program.GetExecute(query, 8);
                    MessageBox.Show("Impresion Exitosa", "SWYRA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    pbConcluir.Visible = validaExisMerc(2);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "SWYRA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                pbConcluir.Visible = validaExisMerc(2);
            }
        }
예제 #2
0
파일: FrmSurtit.cs 프로젝트: JCMDIAZ/SWYRA
        private void pbIncompleto_Click(object sender, EventArgs e)
        {
            if (ValidaCambios())
            {
                MessageBox.Show("Existen cambios en el PEDIDO, por lo que el último movimiento no se registro, se regresara al menú anterior", "SWYRA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                this.Close();
                return;
            }
            if (art != null)
            {
                FrmSurtir4 frmConf = new FrmSurtir4();
                frmConf.lblCom.Text = "El artículo (" + art.cve_art + ") " + art.descr + " lo consideras INCOMPLETO, con " + art.cantdiferencia + " piezas restantes.";
                var dr = frmConf.ShowDialog();
                frmConf.Close();
                if (dr == DialogResult.OK)
                {
                    var query = "IF EXISTS(SELECT * FROM DETALLEPEDIDOMERC WHERE CVE_DOC = '" + art.cve_doc + "' AND CVE_ART = '" + art.cve_art + "' AND ISNULL(CANCELADO,0) = 0 ) " +
                                "BEGIN DECLARE @MAXCONSEC INT SELECT @MAXCONSEC = CONSEC FROM DETALLEPEDIDOMERC " +
                                "WHERE CVE_DOC = '" + art.cve_doc + "' AND CVE_ART = '" + art.cve_art + "' AND ISNULL(CANCELADO,0) = 0 " +
                                "UPDATE DETALLEPEDIDOMERC SET PEND = " + art.cantdiferencia +
                                " WHERE CVE_DOC = '" + art.cve_doc + "' AND CVE_ART = '" + art.cve_art + "' AND CONSEC = @MAXCONSEC " +
                                "END ELSE BEGIN DECLARE @consec INT SELECT @consec = (ISNULL(MAX(CONSEC),-1) + 1) FROM DETALLEPEDIDOMERC " +
                                "WHERE CVE_DOC = '" + art.cve_doc + "' " +
                                "INSERT DETALLEPEDIDOMERC (CVE_DOC, CONSEC, NUM_PAR, CVE_ART, CODIGO_BARRA, CANT, PEND) " +
                                "VALUES ('" + art.cve_doc + "', @consec, " + art.num_par + ", '" + art.cve_art + "', '', 0, " + art.cantdiferencia + ") END";
                    Program.GetExecute(query, 100);

                    var df = art.cantdiferencia;

                    if (art.cantsurtido < art.cant)
                    {
                        art.cantdiferencia = art.cant - art.cantsurtido;
                    }
                    else
                    {
                        art.cantdiferencia = 0;
                    }
                    art.cantpendiente  = art.cantpendiente + art.cantdiferencia;
                    art.con            = (art.sel > 0) ? (int)((art.cant - (int)(art.cantsurtido + art.cantpendiente) - 1) / art.sel) : 0;
                    art.cantdiferencia = art.cant - (art.sel * art.con) - (art.cantsurtido + art.cantpendiente);
                    art.surtido        = (art.cant == (art.cantsurtido + art.cantpendiente));
                    art.ubicacion      = art.ubicacion = ((art.sw) ? ((art.masters_ubi == "") ? art.ctrl_alm : art.masters_ubi) : (art.sel == 0 && art.con == 0) ? art.ctrl_alm : ((art.con > 0) ? art.ctrl_alm : ((art.masters_ubi == "") ? art.ctrl_alm : art.masters_ubi)));
                    var orb = orbi.Find(o => o.cve_ubi == art.ubicacion);
                    art.orden = (orb == null) ? 0 : orb.orden;

                    query =
                        "UPDATE DETALLEPEDIDO SET SURTIDO = " + ((art.surtido) ? "1" : "0") + ", CANTPENDIENTE = ISNULL(CANTPENDIENTE,0) + " + df +
                        " WHERE CVE_DOC = '" + art.cve_doc + "' AND NUM_PAR = " + art.num_par.ToString() + " " +
                        "update PEDIDO set PORC_SURTIDO = r.porc from PEDIDO p join ( " +
                        "select CVE_DOC, (sum(CAST(ISNULL(SURTIDO,0) AS float)) / CAST(count(SURTIDO) as float)) * 100.0 porc from DETALLEPEDIDO " +
                        "where CVE_DOC = '" + art.cve_doc + "' group by CVE_DOC) as r ON p.CVE_DOC = r.CVE_DOC ";
                    Program.GetExecute(query, 3);
                    Lote = "";

                    mostrardet         = det.Where(o => o.surtido == false).ToList();
                    art                = mostrardet.FirstOrDefault();
                    artFirst           = art;
                    artLast            = mostrardet.LastOrDefault();
                    lblPendientes.Text = mostrardet.Count.ToString();
                    cargaDatos();
                }
            }
        }