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 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); } }