public bool llenarDatos() { ClasePreciosItems objPrecios = new ClasePreciosItems(iIdProducto); sSqlQuery = ""; sSqlQuery += "select count (*) cuenta" + Environment.NewLine; sSqlQuery += "from cv403_precios_productos PR inner join" + Environment.NewLine; sSqlQuery += "cv401_productos P on PR.id_producto = P.id_producto" + Environment.NewLine; sSqlQuery += "and PR.estado='A'" + Environment.NewLine; sSqlQuery += "and P.estado = 'A'" + Environment.NewLine; sSqlQuery += "where id_lista_precio = 4" + Environment.NewLine; sSqlQuery += "and P.id_producto = " + iIdProducto; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSqlQuery); if (bRespuesta == true) { cuenta = Convert.ToInt32(dtConsulta.Rows[0].ItemArray[0]); precios = new ClasePreciosItems[cuenta]; if (cuenta != 0) { sSqlQuery = ""; sSqlQuery += "select PR.valor" + Environment.NewLine; sSqlQuery += "from cv403_precios_productos PR inner join" + Environment.NewLine; sSqlQuery += "cv401_productos P on PR.id_producto = P.id_producto" + Environment.NewLine; sSqlQuery += "and PR.estado = 'A'" + Environment.NewLine; sSqlQuery += "and P.estado = 'A'" + Environment.NewLine; sSqlQuery += "where id_lista_precio = 4" + Environment.NewLine; sSqlQuery += "and P.id_producto = " + iIdProducto + Environment.NewLine; sSqlQuery += "order by secuencia"; DataTable dtAyuda = new DataTable(); dtAyuda.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtAyuda, sSqlQuery); if (bRespuesta == true) { for (int i = 0; i < cuenta; i++) { objPrecios = new ClasePreciosItems(iIdProducto); objPrecios.sPreciosItems = dtAyuda.Rows[i].ItemArray[0].ToString(); precios[i] = objPrecios; } return(true); } else { return(false); } } else { return(false); } } else { return(false); } }
private void boton_productosExtras(object sender, EventArgs e) { Orden ord = Owner as Orden; int subindice; botonSel6 = sender as Button; //botonSel6.BackColor = Color.Yellow; precios = new Clases.ClasePreciosItems(Convert.ToInt32(botonSel6.AccessibleName)); int existe = 0; float cantidad = 0; float valoru = 0; try { if (precios.llenarDatos() == true) { subindice = int.Parse(botonSel6.Tag.ToString()); for (int i = 0; i < ord.dgvPedido.Rows.Count; i++) { if (ord.dgvPedido.Rows[i].Cells["producto"].Value.Equals(botonSel6.Text.ToString().Trim())) { cantidad = float.Parse(ord.dgvPedido.Rows[i].Cells["cantidad"].Value.ToString().Trim()); cantidad = cantidad + 1; ord.dgvPedido.Rows[i].Cells["cantidad"].Value = cantidad; valoru = float.Parse(ord.dgvPedido.Rows[i].Cells["valuni"].Value.ToString().Trim()); ord.dgvPedido.Rows[i].Cells["valor"].Value = cantidad * valoru * Program.factorPrecio; Program.factorPrecio = 1; existe = 1; } } if (existe == 0) { int x = 0; x = ord.dgvPedido.Rows.Add(); ord.dgvPedido.Rows[x].Cells["cod"].Value = 2; ord.dgvPedido.Rows[x].Cells["producto"].Value = botonSel6.Text.ToString().Trim(); sNombreProducto_P = botonSel6.Text.ToString().Trim(); ord.dgvPedido.Rows[x].Cells["cantidad"].Value = 1; ord.dgvPedido.Rows[x].Cells["guardada"].Value = 0; ord.dgvPedido.Rows[x].Cells["idProducto"].Value = modificadores.modificadores[subindice].sIdModificador; ord.dgvPedido.Rows[x].Cells["cortesia"].Value = 0; ord.dgvPedido.Rows[x].Cells["motivoCortesia"].Value = ""; ord.dgvPedido.Rows[x].Cells["cancelar"].Value = 0; ord.dgvPedido.Rows[x].Cells["motivoCancelacion"].Value = ""; ord.dgvPedido.Rows[x].Cells["colIdMascara"].Value = ""; ord.dgvPedido.Rows[x].Cells["colSecuenciaImpresion"].Value = iSecuencia.ToString(); ord.dgvPedido.Rows[x].Cells["colOrdenamiento"].Value = ""; ord.dgvPedido.Rows[x].Cells["colIdOrden"].Value = ""; sPagaIva_P = botonSel6.AccessibleDescription.ToString().Trim(); ord.dgvPedido.Rows[x].Cells["pagaIva"].Value = sPagaIva_P; if (sPagaIva_P == "") { ord.dgvPedido.Rows[x].DefaultCellStyle.ForeColor = Color.Blue; ord.dgvPedido.Rows[x].Cells["cantidad"].ToolTipText = sNombreProducto_P.Trim().ToUpper() + " PAGA IVA"; ord.dgvPedido.Rows[x].Cells["producto"].ToolTipText = sNombreProducto_P.Trim().ToUpper() + " PAGA IVA"; ord.dgvPedido.Rows[x].Cells["valor"].ToolTipText = sNombreProducto_P.Trim().ToUpper() + " PAGA IVA"; } else { ord.dgvPedido.Rows[x].DefaultCellStyle.ForeColor = Color.Purple; ord.dgvPedido.Rows[x].Cells["cantidad"].ToolTipText = sNombreProducto_P.Trim().ToUpper() + " NO PAGA IVA"; ord.dgvPedido.Rows[x].Cells["producto"].ToolTipText = sNombreProducto_P.Trim().ToUpper() + " NO PAGA IVA"; ord.dgvPedido.Rows[x].Cells["valor"].ToolTipText = sNombreProducto_P.Trim().ToUpper() + " NO PAGA IVA"; } cantidad = float.Parse("1"); ord.dgvPedido.Rows[x].Cells["valuni"].Value = precios.precios[0].sPreciosItems; valoru = float.Parse(precios.precios[0].sPreciosItems); ord.dgvPedido.Rows[x].Cells["valor"].Value = Math.Round((cantidad * valoru * Program.factorPrecio), 2); Program.factorPrecio = 1; if (Program.factorPrecio != 1) { ord.dgvPedido.Rows[x].Cells["cantidad"].Value = 0.5; cantidad = 0.5f; } Program.factorPrecio = 1; } } ord.calcularTotales(); } catch (Exception) { ok.LblMensaje.Text = "No hay precio en este producto "; ok.ShowInTaskbar = false; ok.ShowDialog(); } }