private void pbRegresar_Click(object sender, EventArgs e) { var index = dgDetallePed.CurrentRowIndex; if (index >= 0) { art = det.First(o => o.num_par == int.Parse(dgDetallePed[index, 6].ToString())); var query = "UPDATE DETALLEPEDIDOMERC SET PEND = 0, CANCELADO = CASE WHEN CODIGO_BARRA = '' THEN 1 END " + "WHERE CVE_DOC = '" + art.cve_doc + "' AND CVE_ART = '" + art.cve_art + "' "; Program.GetExecute(query, 100); art.cantpendiente = 0; 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.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.First(o => o.cve_ubi == art.ubicacion); art.orden = orb.orden; query = "UPDATE DETALLEPEDIDO SET SURTIDO = " + ((art.surtido) ? "1" : "0") + ", CANTPENDIENTE = " + art.cantpendiente + " 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); var mostrardet = det.Where(o => o.cantpendiente > 0).ToList(); dgDetallePed.DataSource = Program.ToDataTable <DetallePedidos>(mostrardet, "detallePedidos"); } }
private void FrmSurtit_Load(object sender, EventArgs e) { CargaUbicaciones(); mostrardet = det.Where(o => o.surtido == false).ToList(); lblPedido.Text = ped.cve_doc.Trim(); lblCliente.Text = ped.cliente.Trim(); lblComentario.Text = ""; art = mostrardet.FirstOrDefault(); artFirst = art; artLast = mostrardet.LastOrDefault(); lblPendientes.Text = mostrardet.Count.ToString(); cargaDatos(); txtCodigo.Focus(); }
private void pbSig_Click(object sender, EventArgs e) { if (art != null) { if (art.num_par == artLast.num_par) { art = artFirst; } else { art = Program.GetNext <DetallePedidos>(mostrardet, art); } cargaDatos(); } }
private void FrmCancelacion_Load(object sender, EventArgs e) { CargaUbicaciones(); CargaEmpaque(); detmerc = CargaDetalleMerc(); mostrardet = det.Where(o => o.devuelto == false).ToList(); lblPedido.Text = ped.cve_doc.Trim(); lblComentario.Text = ""; art = mostrardet.FirstOrDefault(); artFirst = art; artLast = mostrardet.LastOrDefault(); lblPendientes.Text = mostrardet.Count.ToString(); cargaDatos(); txtCodigo.Focus(); }
private void pbFinal_Click(object sender, EventArgs e) { if (art.mas > 0) { art.sw = true; 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.sw ? 0 : 1)) - (art.cantsurtido + art.cantpendiente); var ubiant = 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.First(o => o.cve_ubi == art.ubicacion); art.orden = orb.orden; mostrardet = det.Where(o => o.surtido == false).ToList(); mostrardet = mostrardet.OrderBy(o => o.orden).ToList(); art = mostrardet.FirstOrDefault(); artFirst = art; artLast = mostrardet.LastOrDefault(); lblPendientes.Text = mostrardet.Count.ToString(); cargaDatos(); //pbSig_Click(sender, e); } }
private void actualizaDet() { var query = ""; try { 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 (txtCant.ReadOnly) { query = "UPDATE DETALLEPEDIDOMERC SET Cancelado = " + (mrc.cancelado ? "1" : "0") + ", " + "CANT = " + mrc.cant + " WHERE CVE_DOC = '" + mrc.cve_doc + "' AND CONSEC = " + mrc.consec.ToString() + " and ISNULL(CANCELADO,0) = 0 " + "DECLARE @CONSEC_PADRE INT " + "SELECT @CONSEC_PADRE = ISNULL(CONSEC_PADRE,0) FROM DETALLEPEDIDOMERC WHERE CVE_DOC = '" + mrc.cve_doc + "' AND CONSEC = " + mrc.consec.ToString() + " UPDATE DETALLEPEDIDOMERC SET TOTART = TOTART - 1 WHERE CVE_DOC = '" + mrc.cve_doc + "' AND CONSEC = @CONSEC_PADRE " + "update DETALLEPEDIDOMERC set CANCELADO = CASE WHEN TotArt = 0 THEN 1 ELSE 0 END where (LTRIM(CVE_DOC) = '" + mrc.cve_doc + "') and CONSEC = @CONSEC_PADRE " + " DECLARE @CONSEC_PADRE2 INT " + "SELECT @CONSEC_PADRE2 = ISNULL(CONSEC_PADRE,0) FROM DETALLEPEDIDOMERC WHERE CVE_DOC = '" + mrc.cve_doc + "' AND CONSEC = @CONSEC_PADRE AND TOTART = 0 " + "UPDATE DETALLEPEDIDOMERC SET TOTART = TOTART - 1 WHERE CVE_DOC = '" + art.cve_doc + "' AND CONSEC = @CONSEC_PADRE2 " + "update DETALLEPEDIDOMERC set CANCELADO = CASE WHEN TotArt = 0 THEN 1 ELSE 0 END where (LTRIM(CVE_DOC) = '" + mrc.cve_doc + "') and CONSEC = @CONSEC_PADRE2 " + "UPDATE DETALLEPEDIDO SET CANTSURTIDO = CANTSURTIDO - " + txtCant.Value.ToString() + ", SURTIDO = 0 WHERE CVE_DOC = '" + mrc.cve_doc + "' AND NUM_PAR = " + mrc.num_par.ToString() + " UPDATE INVENTARIO SET EXIST = EXIST + " + txtCant.Value.ToString() + " WHERE CVE_ART = '" + mrc.cve_art + "' " + "update PEDIDO set PORC_SURTIDO = r.porc from PEDIDO p join ( " + "select CVE_DOC, (sum(CAST(ISNULL(SURTIDO,0) AS float)) / CAST(count(ISNULL(SURTIDO,0)) as float)) * 100.0 porc from DETALLEPEDIDO " + "where CVE_DOC = '" + mrc.cve_doc + "' group by CVE_DOC) as r ON p.CVE_DOC = r.CVE_DOC "; Program.GetExecute(query, 2); var cnt = (double)txtCant.Value; art.cantdevuelto += (((art.cant - art.cantdevuelto) >= cnt) ? cnt : (art.cant - art.cantdevuelto)); art.con = (art.sel > 0) ? (int)((art.cant - (int)(art.cantdevuelto + art.cantpendiente) - 1) / art.sel) : 0; art.cantdiferencia = art.cant - (art.sel * art.con) - (art.cantdevuelto + art.cantpendiente); art.devuelto = (art.cant == (art.cantdevuelto + art.cantpendiente)); art.exist = (art.exist + cnt); var ubiant = art.ubicacion; art.ubicacion = (art.sel == 0 && art.con == 0) ? art.ctrl_alm : ((art.con > 0) ? art.ctrl_alm : ((art.masters_ubi == "") ? art.ctrl_alm : art.masters_ubi)); //art.ubicacion = (art.cantdiferencia > art.mas) ? ((art.masters_ubi != "") ? art.masters_ubi : art.ctrl_alm) : art.ctrl_alm; var orb = orbi.First(o => o.cve_ubi == art.ubicacion); art.orden = orb.orden; var cvedoc = art.cve_doc.Trim(); query = "UPDATE DETALLEPEDIDODEV SET CANTDEVUELTO = " + art.cantdevuelto + ", DEVUELTO = " + ((art.devuelto) ? "1" : "0") + " WHERE LTRIM(CVE_DOC) = '" + cvedoc + "' AND NUM_PAR = " + art.num_par.ToString(); Program.GetExecute(query, 2); if (art.cantdiferencia == 0 || ubiant != art.ubicacion) { mostrardet = det.Where(o => o.devuelto == false).ToList(); mostrardet = mostrardet.OrderBy(o => o.orden).ToList(); art = mostrardet.FirstOrDefault(); artFirst = art; artLast = mostrardet.LastOrDefault(); lblPendientes.Text = mostrardet.Count.ToString(); } detmerc = CargaDetalleMerc(); cargaDatos(); txtCodigo.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message + query, "SWYRA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
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(); } } }
private void actualizaDet() { var linea = ""; 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; } try { linea = "1"; if (txtCant.ReadOnly) { linea = "2"; if (art.cantsurtido < art.cant) { linea = "3"; art.cantsurtido += (double)txtCant.Value; linea = "4"; art.con = (art.sel > 0) ? (int)((art.cant - (int)(art.cantsurtido + art.cantpendiente) - 1) / art.sel) : 0; linea = "5"; art.cantdiferencia = art.cant - (art.sel * art.con) - (art.cantsurtido + art.cantpendiente); linea = "6"; art.surtido = (art.cant == (art.cantsurtido + art.cantpendiente)); linea = "7"; art.exist = (art.exist - (double)txtCant.Value); } else { linea = "8"; txtCant.Value = 0; linea = "9"; art.cantdiferencia = 0.0; linea = "10"; art.cantsurtido = art.cant; linea = "11"; art.surtido = true; } linea = "12"; var ubiant = art.ubicacion; linea = "13"; art.ubicacion = ((art.sw) ? ((art.masters_ubi == "" || 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))); linea = "14"; var orb = orbi.Find(o => o.cve_ubi == art.ubicacion); linea = "15"; art.orden = (orb == null) ? 0 :orb.orden; linea = "16"; var confirmar = "IF EXISTS( SELECT * FROM DETALLEPEDIDOMERC WHERE CVE_DOC = '" + art.cve_doc + "' AND CODIGO_BARRA = '" + lastCB + "' AND ISNULL(CANCELADO,0) = 0 AND ISNULL(CONSEC_PADRE,0) = 0) " + "UPDATE DETALLEPEDIDOMERC SET CANT = CANT + " + txtCant.Value.ToString() + ", " + "lote = (isnull(lote,'') + case when isnull(lote,'') <> '' then ';' else '' end + '" + Lote + "') " + "WHERE CVE_DOC = '" + art.cve_doc + "' AND CODIGO_BARRA = '" + lastCB + "' ELSE "; linea = "17"; var query = "DECLARE @consec INT " + "SELECT @consec = (ISNULL(MAX(CONSEC),-1) + 1) FROM DETALLEPEDIDOMERC " + "WHERE CVE_DOC = '" + art.cve_doc + "' " + ((double)txtCant.Value == 1.0 ? confirmar : "") + "INSERT DETALLEPEDIDOMERC (CVE_DOC, CONSEC, NUM_PAR, CVE_ART, CODIGO_BARRA, CANT, lote) " + "VALUES ('" + art.cve_doc + "', @consec, " + art.num_par.ToString() + ", '" + art.cve_art + "', '" + lastCB + "', " + txtCant.Value.ToString() + ", '" + Lote + "') " + "UPDATE DETALLEPEDIDO SET CANTSURTIDO = " + art.cantsurtido + ", SURTIDO = " + ((art.surtido) ? "1" : "0") + " WHERE CVE_DOC = '" + art.cve_doc + "' AND NUM_PAR = " + art.num_par.ToString() + " UPDATE INVENTARIO SET EXIST = EXIST - " + txtCant.Value.ToString() + " WHERE CVE_ART = '" + art.cve_art + "' " + "update PEDIDO set PORC_SURTIDO = r.porc from PEDIDO p join ( " + "select CVE_DOC, (sum(CAST(ISNULL(SURTIDO,0) AS float)) / CAST(count(ISNULL(SURTIDO,0)) 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 "; linea = "18"; Program.GetExecute(query, 2); linea = "19"; Lote = ""; linea = "20"; if (art.cantdiferencia == 0 || ubiant != art.ubicacion) { linea = "21"; mostrardet = det.Where(o => o.surtido == false).ToList(); linea = "22"; mostrardet = mostrardet.OrderBy(o => o.orden).ToList(); linea = "23"; art = mostrardet.FirstOrDefault(); linea = "24"; artFirst = art; linea = "25"; artLast = mostrardet.LastOrDefault(); linea = "26"; lblPendientes.Text = mostrardet.Count.ToString(); } linea = "27"; cargaDatos(); linea = "28"; txtCodigo.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message + " linea : " + linea, "SWYRA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }