private void CargaInformacion() { try { pbrCarga.Value = 0; pbrCarga.Minimum = 0; this.Cursor = Cursors.Default; pbrCarga.Maximum = dt.Rows.Count; for (var i = 0; i <= dt.Rows.Count - 1; i++) { ProductoListaPrecio productoListaPrecio = new ProductoListaPrecio(); pbrCarga.Refresh(); pbrCarga.Value = pbrCarga.Value + 1; lblPorcentajeCarga.Text = Convert.ToInt32(pbrCarga.Value * 100 / (double)pbrCarga.Maximum) + "%"; DataRow row = dt.Rows[i]; productoListaPrecio.CODIGO_PRODUCTO_LISTA = Convert.ToInt32(row[0]); productoListaPrecio.PRECIO_LISTA = Convert.ToDecimal(row[4]); productoListaPrecio.LIMITE_VENTA = Convert.ToInt32(row[5]); productoListaPrecio.ES_PRINCIPAL = row[6].ToString() == "1" ? true : false; productoListaPrecio.PERMITE_DIGITAR = row[7].ToString() == "1" ? true : false; productoListaPrecio.SUMA_VALOR_PUBLICO = row[8].ToString() == "1" ? true : false; productoListaPrecio.SUMA_LLEGAR_ESCALA = row[9].ToString() == "1" ? true : false; productoListaPrecio.SE_APLICA_ESCALA = row[10].ToString() == "1" ? true : false; productoListaPrecio.APLICA_SUPERA_MONTO_MIN = row[11].ToString() == "1" ? true : false; productoListaPrecio.SUMA_NETO = row[12].ToString() == "1" ? true : false; productoListaPrecio.ES_ACCESORIO = row[13].ToString() == "1" ? true : false; productoListaPrecio.PORCENTAJE_IVA = Convert.ToDecimal(row[14]); productoListaPrecio.COSTO_PRODUCTO = Convert.ToDecimal(row[15]); productoListaPrecio.PUNTOS = Convert.ToInt32(row[16]); productoListaPrecio.ESFALTANTE_ANUNCIADO = row[17].ToString() == "1" ? true : false; productoListaPrecio.TIPO_PRODUCTO = "STANDARD"; productoListaPrecio.PRECIO_CATALOGO = Convert.ToDecimal(row[18]); ServicePedidos.updPreciosProdcuto(productoListaPrecio); } MessageBox.Show("Archivo cargado exitosamente", "Carga de Información", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); lblPorcentajeCarga.Text = null; pbrCarga.Value = 0; pbrCarga.Minimum = 0; pbrCarga.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void btnGrabar_Click(object sender, EventArgs e) { if (validaCampos()) { try { string strResult; double iva = Convert.ToInt32(txtIvaProducto.Text); ProductoListaPrecio productoListaPrecio = new ProductoListaPrecio(); productoListaPrecio.CODIGO_PRODUCTO_LISTA = clsConnection.intCodigoProducto; productoListaPrecio.PRECIO_LISTA = Convert.ToDecimal(txtPrecioVenta.Text); productoListaPrecio.PRECIO_CATALOGO = Convert.ToDecimal(txtPrecioVenta.Text); productoListaPrecio.LIMITE_VENTA = Convert.ToInt32(txtLimiteVenta.Text); productoListaPrecio.COSTO_PRODUCTO = Convert.ToDecimal(txtCostoProd.Text); productoListaPrecio.PORCENTAJE_IVA = Convert.ToDecimal(iva / 100); productoListaPrecio.TIPO_PRODUCTO = Convert.ToString(cboTipoProducto.SelectedValue); productoListaPrecio.PUNTOS = Convert.ToInt32(txtPuntosOtorga.Text); if (rdbSiPrincipal.Checked) { productoListaPrecio.ES_PRINCIPAL = true; } else if (rdbNoPrincipal.Checked) { productoListaPrecio.ES_PRINCIPAL = false; } if (rdbSidigita.Checked) { productoListaPrecio.PERMITE_DIGITAR = true; } else if (rdbNoDigita.Checked) { productoListaPrecio.PERMITE_DIGITAR = false; } if (rdbSiValorPublico.Checked) { productoListaPrecio.SUMA_VALOR_PUBLICO = true; } else if (rdbNoValorPublico.Checked) { productoListaPrecio.SUMA_VALOR_PUBLICO = false; } if (rdbSiLlegaEscala.Checked) { productoListaPrecio.SUMA_LLEGAR_ESCALA = true; } else if (rdbNoLlegaEscala.Checked) { productoListaPrecio.SUMA_LLEGAR_ESCALA = false; } if (rdbSiNeto.Checked) { productoListaPrecio.SUMA_NETO = true; } else if (rdbNoNeto.Checked) { productoListaPrecio.SUMA_NETO = false; } if (rdbSiAplicaEscala.Checked) { productoListaPrecio.SE_APLICA_ESCALA = true; } else if (rdbNoAplicaEscala.Checked) { productoListaPrecio.SE_APLICA_ESCALA = false; } if (rdbSiMontoMinimo.Checked) { productoListaPrecio.APLICA_SUPERA_MONTO_MIN = true; } else if (rdbNoMontoMinimo.Checked) { productoListaPrecio.APLICA_SUPERA_MONTO_MIN = false; } if (rdbSiAccesorio.Checked) { productoListaPrecio.ES_ACCESORIO = true; } else if (rdbNoAccesorio.Checked) { productoListaPrecio.ES_ACCESORIO = false; } if (rdbSiFaltante.Checked) { productoListaPrecio.ESFALTANTE_ANUNCIADO = true; } else if (rdbNoFaltante.Checked) { productoListaPrecio.ESFALTANTE_ANUNCIADO = false; } strResult = Convert.ToString(ServicePedidos.updPreciosProdcuto(productoListaPrecio)); if (Information.IsNumeric(strResult)) { if (Convert.ToInt32(strResult) == 1) { MessageBox.Show("Registro Actualizado exitosamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Error al grabar en la Base de Datos, contacte al Administrador del Sistema", "Error BD", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error al generar archivo", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } }