private void cod_productid_TextChanged(object sender, EventArgs e) { if (cod_productid.Text.Length == 13) { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); var dt = new DataTable(); BE.moduloid = modulo.ToString(); BE.local = local.ToString(); BE.productid = cod_productid.Text.ToString().Trim(); BE.moneda = moneda.ToString(); BE.tipodoc = tipodoc.ToString(); BE.tcamb = tcamb; dt = BL.GetPrecCostoUltimo(VariablesPublicas.EmpresaID, BE).Tables[0]; foreach (DataRow fila in dt.Rows) { row = DataDetalleProductos.NewRow(); row["productid"] = fila["productid"].ToString(); row["productname"] = fila["productname"].ToString(); row["precunit"] = fila["precunit"].ToString(); DataDetalleProductos.Rows.Add(row); calcular_totales(); } dgb_listaproductos.DataSource = DataDetalleProductos; limpiar(); } }
private void Insert() { try { if (productid.Text.Trim().Length != 13) { MessageBox.Show("Código de producto invalido !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (productname.Text.Trim().Length == 0) { MessageBox.Show("Ingrese nombre de producto !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (unmed.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (unmedenvase.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (unidenvase.Text == "") { MessageBox.Show("Ingrese Equivalente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); BE.moduloid = modulo.Trim(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); BE.item = item.Text.Trim(); BE.productid = productid.Text.Trim(); BE.productname = productname.Text.Trim().ToUpper(); BE.nserie = nserie.Text.ToString(); BE.productidold = "0"; if (unmed.SelectedValue != null) BE.unmed = unmed.SelectedValue.ToString(); BE.precioenvase = Convert.ToDecimal(precioenvase.Text.Trim().PadLeft(1, '0')); if (unmedenvase.SelectedValue != null) BE.unmedenvase = unmedenvase.SelectedValue.ToString(); else unmedenvase.Text = ""; BE.procedenciaid = cenestado.SelectedIndex.ToString(); BE.unidenvase = Convert.ToDecimal(unidenvase.Text.Trim()); BE.unmedpeso = unmedpeso.Text.Trim().ToUpper(); BE.peso = Convert.ToDecimal(peso.Text.Trim().PadLeft(0, '0')); BE.status = "0"; BE.usuar = VariablesPublicas.Usuar.Trim(); // Asignando el valor de la imagen // Stream usado como buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se guarda la imagen en el buffer if (go_foto.Image != null) { go_foto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } // Se extraen los bytes del buffer para asignarlos como valor para el // parámetro. BE.Foto = ms.GetBuffer(); if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos grabados correctamente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cod_productid_TextChanged(object sender, EventArgs e) { if (cod_productid.Text.Length == 13) { //Consultaremos la Query Para Cargar los Productos tb_me_productos BE = new tb_me_productos(); tb_me_productosBL BL = new tb_me_productosBL(); DataTable dt = new DataTable(); BE.moduloid = modulo.ToString(); BE.local = local.ToString(); BE.productid = cod_productid.Text.ToString().Trim(); BE.moneda = moneda.ToString(); BE.listaprecid = listaprecid; dt = BL.GetPrecList(VariablesPublicas.EmpresaID, BE).Tables[0]; foreach (DataRow fila in dt.Rows) { row = DataDetalleProductos.NewRow(); row["productid"] = fila["productid"].ToString(); row["productname"] = fila["productname"].ToString(); row["precunit"] = fila["precunit"].ToString(); DataDetalleProductos.Rows.Add(row); calcular_totales(); } dgb_listaproductos.DataSource = DataDetalleProductos; limpiar(); } }
private void form_cargar_datos(String posicion) { try { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); DataTable dt = new DataTable(); BE.moduloid = modulo; if (productid.Text.Trim().Length > 0) { BE.productid = productid.Text.Trim(); } BE.posicion = posicion.Trim(); dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { limpiar_documento(); ssModo = "EDIT"; lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim(); lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim(); grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim(); gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim(); subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim(); subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim(); item.Text = dt.Rows[0]["item"].ToString().Trim(); productid.Text = dt.Rows[0]["productid"].ToString().Trim(); productname.Text = dt.Rows[0]["productname"].ToString().Trim(); nserie.Text = dt.Rows[0]["nserie"].ToString().Trim(); // Agregado cenestado.SelectedIndex = Convert.ToInt32(dt.Rows[0]["procedenciaid"]); if (dt.Rows[0]["unmed"].ToString().Trim().Length > 0) unmed.SelectedValue = dt.Rows[0]["unmed"].ToString().Trim(); precioenvase.Text = dt.Rows[0]["precioenvase"].ToString().Trim().PadLeft(1, '0'); if (dt.Rows[0]["unmedenvase"].ToString().Trim().Length > 0) unmedenvase.SelectedValue = dt.Rows[0]["unmedenvase"].ToString().Trim(); else unmedenvase.SelectedIndex = -1; unidenvase.Text = dt.Rows[0]["unidenvase"].ToString().Trim(); unmedpeso.Text = dt.Rows[0]["unmedpeso"].ToString().Trim(); peso.Text = dt.Rows[0]["peso"].ToString().Trim().PadLeft(1, '0'); String foto = dt.Rows[0]["foto"].ToString(); if (dt.Rows[0]["foto"].ToString() != "") { byte[] MyData1 = null; MyData1 = (byte[])(dt.Rows[0]["foto"]); if (MyData1 != null && MyData1.Length != 0) { go_foto.Visible = true; go_foto.Image = null; System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se utiliza el MemoryStream para extraer la imagen ms.Write(MyData1, 0, MyData1.Length); go_foto.Image = Image.FromStream(ms); } else { go_foto.Visible = false; go_foto.ImageLocation = ""; } } else { go_foto.Visible = false; go_foto.ImageLocation = ""; } subgrupoid.Enabled = false; productid.Enabled = true; btn_editar.Enabled = true; btn_eliminar.Enabled = true; btn_imprimir.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_log.Enabled = true; btn_salir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void get_nuevo_producto() { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); DataTable DT = new DataTable(); BE.moduloid = moduloid.Text.Trim(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); DT = BL.GetAll_nuevocodprod(EmpresaID, BE).Tables[0]; try { item.Text = Convert.ToString(Convert.ToInt16(DT.Rows[0]["item"].ToString().Substring(10, 3)) + 1).PadLeft(3, '0'); productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } catch { item.Text = "000"; productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } if (productid.Text.Trim().Length == 13) { generar_denominacion(); form_bloqueado(true); productname.Focus(); btn_cancelar.Enabled = true; btn_grabar.Enabled = true; btn_log.Enabled = true; } }
private void btn_CargarProductos_Click(object sender, EventArgs e) { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = modulo.ToString(); BE.filtro = "3"; TablaListaPrecios = BL.GetAll(EmpresaID, BE).Tables[0]; if (TablaListaPrecios.Rows.Count > 0) { dgb_listaPrecios.DataSource = TablaListaPrecios; btn_exportar.Enabled = true; btn_CargarProductos.Enabled = false; btn_importar.Enabled = false; TablaListaPrecios.AcceptChanges(); MessageBox.Show("Carga de Productos Completada...!!!"); } }
private void Delete() { try { if (productid.Text.Trim().Length != 13) { MessageBox.Show("Código de producto invalido !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); BE.moduloid = modulo.Trim(); BE.productid = productid.Text.Trim(); BE.status = "9"; BE.usuar = VariablesPublicas.Usuar.Trim(); if (BL.Delete(EmpresaID, BE)) { SEGURIDAD_LOG("E"); MessageBox.Show("Datos eliminados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); NIVEL_FORMS(); limpiar_documento(); form_bloqueado(false); subgrupoid.Enabled = false; productid.Enabled = true; btn_nuevo.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_salir.Enabled = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_excel_Click(object sender, EventArgs e) { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var TablaMov_ordprod = new DataTable(); BE.moduloid = modulo.Trim(); BE.filtro = "2"; TablaMov_ordprod = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (TablaMov_ordprod.Rows.Count > 0) { ExportarExcel(TablaMov_ordprod); } }
private void btn_notepad_Click(object sender, EventArgs e) { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); var dt = new DataTable(); BE.moduloid = modulo.ToString(); dt = BL.GetAll_Pocket(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { String strDestinationFile; strDestinationFile = @"C:\ErpBapSoftNet_almacen\tb_me_productos.txt"; TextWriter tw = new StreamWriter(strDestinationFile); foreach (DataRow row in dt.Rows) { var items = new List<string>(); foreach (DataColumn col in dt.Columns) { items.Add(row[col.ColumnName].ToString()); } var linea = string.Join("|", items.ToArray()); tw.WriteLine(linea); } tw.Close(); MessageBox.Show("Proceso Terminado", "Información"); } }
private void Update() { try { if (productid.Text.Trim().Length != 13) { MessageBox.Show("Código de producto invalido !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (productname.Text.Trim().Length == 0) { MessageBox.Show("Ingrese nombre de producto !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (unmed.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (unmedenvase.SelectedIndex == -1) { MessageBox.Show("Seleccione la unidad de medida !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (unidenvase.Text == string.Empty) { MessageBox.Show("Ingrese Equivalente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = moduloiddes.SelectedValue.ToString(); if (moduloiddes.SelectedValue.ToString() == "0000") { MessageBox.Show("Seleccione Almacen", "Information"); return; } BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); BE.item = item.Text.Trim(); BE.productid = productid.Text.Trim(); BE.productname = productname.Text.Trim().ToUpper(); BE.productidold = productidold.Text.Trim().ToUpper(); BE.titulo = titulo.Text.Trim().ToUpper(); BE.compo = compo.Text.Trim().ToUpper(); BE.colorid = colorid.Text.Trim(); BE.colorname = colorname.Text.Trim().ToUpper(); if (unmed.SelectedValue != null) { BE.unmed = unmed.SelectedValue.ToString(); } if (unmedenvase.SelectedValue != null) { BE.unmedenvase = unmedenvase.SelectedValue.ToString(); } BE.procedenciaid = procedenciaid.SelectedIndex.ToString(); BE.unidenvase = Convert.ToDecimal(unidenvase.Text.Trim()); BE.status = estado.SelectedIndex.ToString(); BE.usuar = VariablesPublicas.Usuar.Trim(); BE.nserie = nserie.Text.ToString(); var ms = new System.IO.MemoryStream(); if (modulo == "0500") { if (go_foto.Image != null) { go_foto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } } BE.Foto = ms.GetBuffer(); if (BL.Update(EmpresaID, BE)) { SEGURIDAD_LOG("M"); MessageBox.Show("Datos Modificado Correctamente !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Update_Foto() { try { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = moduloiddes.SelectedValue.ToString(); if (moduloiddes.SelectedValue.ToString() == "0000") { MessageBox.Show("Seleccione Almacen", "Information"); return; } BE.local = localdes.SelectedValue.ToString(); BE.productid = productid.Text.Trim(); BE.docname = _nombreFoto.ToString(); var ms = new System.IO.MemoryStream(); if (modulo == "0500") { if (go_foto.Image != null) { go_foto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } } BE.Foto = ms.GetBuffer(); BL.Update_Foto(EmpresaID, BE); } catch (Exception) { throw; } }
private void Llenar_Datos() { if (cbo_moduloides.SelectedIndex != -1 && cbo_moduloides.SelectedValue.ToString() != "0000" && cbo_moduloides.SelectedValue.ToString() != "0200") { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); BE.moduloid = cbo_moduloides.SelectedValue.ToString(); BE.productname = txtbusqueda.Text.Trim(); BE.filtro = "4"; Tablaproducto = BL.GetAll(EmpresaID, BE).Tables[0]; if (Tablaproducto.Rows.Count > 0) { MDI_dgb_productos.DataSource = Tablaproducto; } else { MDI_dgb_productos.DataSource = Tablaproducto; } } else { } }
private void get_nuevo_producto() { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var DT = new DataTable(); BE.moduloid = cbo_moduloides.SelectedValue.ToString(); BE.lineaid = lineaid.Text.Trim(); BE.grupoid = grupoid.Text.Trim(); BE.subgrupoid = subgrupoid.Text.Trim(); DT = BL.GetAll_nuevocodprod(EmpresaID, BE).Tables[0]; try { item.Text = DT.Rows[0]["item"].ToString().Substring(10, 3); productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } catch (Exception ex) { item.Text = "000"; productid.Text = lineaid.Text + grupoid.Text + subgrupoid.Text + item.Text; } if (productid.Text.Trim().Length == 13) { generar_denominacion(); form_bloqueado(true); titulo.Focus(); btn_cancelar.Enabled = true; btn_grabar.Enabled = true; btn_log.Enabled = true; } }
private void form_cargar_datos(String posicion) { try { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var dt = new DataTable(); BE.moduloid = moduloiddes.SelectedValue.ToString(); if (productid.Text.Trim().Length > 0) { BE.productid = productid.Text.Trim(); } BE.posicion = posicion.Trim(); dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { limpiar_documento(); ssModo = "EDIT"; lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim(); lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim(); grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim(); gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim(); subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim(); subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim(); item.Text = dt.Rows[0]["item"].ToString().Trim(); productid.Text = dt.Rows[0]["productid"].ToString().Trim(); productname.Text = dt.Rows[0]["productname"].ToString().Trim(); nom_producto = dt.Rows[0]["productname"].ToString().Trim(); productidold.Text = dt.Rows[0]["productidold"].ToString().Trim(); titulo.Text = dt.Rows[0]["titulo"].ToString().Trim(); compo.Text = dt.Rows[0]["compo"].ToString().Trim(); colorid.Text = dt.Rows[0]["colorid"].ToString().Trim(); colorname.Text = dt.Rows[0]["colorname"].ToString().Trim(); procedenciaid.SelectedIndex = Convert.ToInt32(dt.Rows[0]["paisid"]); txt_paisname.Text = dt.Rows[0]["paisname"].ToString().Trim(); nserie.Text = dt.Rows[0]["nserie"].ToString().Trim(); estado.SelectedIndex = Convert.ToInt32(dt.Rows[0]["status"]); if (dt.Rows[0]["unmed"].ToString().Trim().Length > 0) { unmed.SelectedValue = dt.Rows[0]["unmed"].ToString().Trim(); } if (dt.Rows[0]["unmedenvase"].ToString().Trim().Length > 0) { unmedenvase.SelectedValue = dt.Rows[0]["unmedenvase"].ToString().Trim(); } else { unmedenvase.SelectedIndex = -1; } unidenvase.Text = dt.Rows[0]["unidenvase"].ToString().Trim(); _nombreFoto = dt.Rows[0]["docname"].ToString().ToString(); dt.Rows[0]["foto"].ToString(); if (dt.Rows[0]["foto"].ToString() != string.Empty) { var MyData1 = (byte[])null; MyData1 = (byte[])(dt.Rows[0]["foto"]); if (MyData1 != null && MyData1.Length != 0) { vmContenidoFile = MyData1; go_foto.Visible = true; go_foto.Image = null; var ms = new System.IO.MemoryStream(); ms.Write(MyData1, 0, MyData1.Length); go_foto.Image = Image.FromStream(ms); } else { go_foto.Visible = false; go_foto.ImageLocation = string.Empty; } } else { go_foto.Visible = false; go_foto.ImageLocation = string.Empty; } subgrupoid.Enabled = false; productid.Enabled = true; btn_editar.Enabled = true; btn_eliminar.Enabled = true; btn_imprimir.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_log.Enabled = true; btn_salir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ValidaProducto() { if (productid.Text.Trim().Length == 13) { var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); var dt = new DataTable(); BE.moduloid = modulo; BE.productid = productid.Text.Trim(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim(); lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim(); grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim(); gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim(); subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim(); subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim(); productid.Text = dt.Rows[0]["productid"].ToString().Trim(); productname.Text = dt.Rows[0]["productname"].ToString().Trim(); } else { productid.Text = string.Empty; productname.Text = string.Empty; } } else { productid.Text = string.Empty; productname.Text = string.Empty; } }
private void btn_busqueda_Click(object sender, EventArgs e) { try { tb_me_productosBL BL = new tb_me_productosBL(); tb_me_productos BE = new tb_me_productos(); // DataTable TablaProducto = new DataTable(); BE.moduloid = modulo; BE.productname = txt_criterio.Text.Trim().ToUpper(); Tablaproducto = BL.GetAll(EmpresaID, BE).Tables[0]; if (Tablaproducto.Rows.Count > 0) { btn_imprimir.Enabled = true; dgb_productos.DataSource = Tablaproducto; //dgb_productos.Rows[0].Selected = false; //dgb_productos.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private DataTable Movimiento_producto() { try { var TablaProducto = new DataTable("Producto"); var BL = new tb_me_productosBL(); var BE = new tb_me_productos(); BE.moduloid = moduloid.Trim(); TablaProducto = BL.GetReport(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0]; if (TablaProducto != null) { return TablaProducto; } else { return null; } } catch (Exception ex) { return null; } }
private void CargarDetalle(String xxproductid) { Decimal xprecio = 0, xvalor = 0, xcantidad = 0, tipcamb = 0; var desct1 = 0; Decimal imporfac = 0; Decimal import = 0; Decimal totimpx = 0; if (xxproductid.Trim().Length == 13) { var BE = new tb_me_productos(); var BL = new tb_me_productosBL(); var dt = new DataTable(); BE.moduloid = modulo; BE.local = local; BE.productid = xxproductid; BE.moneda = moneda.SelectedValue.ToString(); BE.tcamb = Convert.ToDecimal(tcamb.Text); BE.tipodoc = tipodoc.SelectedValue.ToString(); dt = BL.GetPrecCostoUltimo(VariablesPublicas.EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productid"].Value = dt.Rows[0]["productid"].ToString().Trim(); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productname"].Value = dt.Rows[0]["productname"].ToString().Trim(); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["unmed"].Value = dt.Rows[0]["unmed"].ToString().Trim(); Decimal lsStock = 0, dtCantidad = 0, mvCantidad = 0, dtstock = 0; lsStock = Convert.ToDecimal(dt.Rows[0]["stock"].ToString().Trim()); dtCantidad = Convert.ToDecimal(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value); mvCantidad = Convert.ToDecimal(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad_old"].Value); if (almacaccionid.Substring(0, 1) == "1") { dtstock = lsStock + dtCantidad - mvCantidad; } else { if (almacaccionid.Substring(0, 1) == "2") { dtstock = lsStock - dtCantidad + mvCantidad; } } griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["stock_old"].Value = lsStock; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["stock"].Value = dtstock; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["dalmacaccionid"].Value = almacaccionid.ToString().Trim(); txt_stock.Text = Convert.ToString(dtstock); xprecio = Convert.ToDecimal(dt.Rows[0]["precunit"].ToString().Trim()); xcantidad = Convert.ToDecimal(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value); imporfac = Math.Round(xcantidad * Convert.ToDecimal(xprecio), 6); tipcamb = Convert.ToDecimal(tcamb.Text.Trim()); if (tipcamb <= 0) { tipcamb = 1; } //El Precio ya Lo Traigo sea Dolar O Soles xvalor = xprecio; _cal_Igv(); desct1 = 0; import = imporfac * (1 - (desct1 / 100)); //if (Equivalencias.Left(cbo_incprec.Text.Trim(), 1) == "S") //{ // totimpx = Math.Round(import * (Convert.ToDecimal(igv) / (100 + Convert.ToDecimal(igv))), 6); //} //else //{ totimpx = Math.Round(import * (Convert.ToDecimal(igv) / 100), 6); //} griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["valor"].Value = xvalor; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importe"].Value = Math.Round(xcantidad * xvalor, 6); griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["dtotimpto"].Value = totimpx; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precioanterior"].Value = xprecio; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value = xcantidad; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precunit"].Value = xprecio; griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importfac"].Value = Math.Round(imporfac, 2); Tabladetallemov.AcceptChanges(); griddetallemov.CurrentCell = griddetallemov.Rows[griddetallemov.RowCount - 1].Cells["cantidad"]; } else { MessageBox.Show("Producto no existe en Tabla Local Stock !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Producto no Existe !!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }