public bool Delete(string empresaid, tb_ad_local_stock BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbMeLocalStock_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool CierreDePeriodo(string empresaid, tb_ad_local_stock BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbMeLocalStock_CierreMes", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                 cmd.Parameters.Add("@grabacp", SqlDbType.Char, 2).Value = BE.grabacp;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_ad_local_stock BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbMeLocalStock_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;
                 cmd.Parameters.Add("@productname", SqlDbType.VarChar, 60).Value = BE.productname;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public bool Update(string empresaid, tb_ad_local_stock BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbMeLocalStock_UPDATE", cnx))
                {

                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                        cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                        cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;
                        cmd.Parameters.Add("@stockini01", SqlDbType.Decimal).Value = BE.stockini01;
                        cmd.Parameters.Add("@stockini02", SqlDbType.Decimal).Value = BE.stockini02;
                        cmd.Parameters.Add("@stockini03", SqlDbType.Decimal).Value = BE.stockini03;
                        cmd.Parameters.Add("@stockini04", SqlDbType.Decimal).Value = BE.stockini04;
                        cmd.Parameters.Add("@stockini05", SqlDbType.Decimal).Value = BE.stockini05;
                        cmd.Parameters.Add("@stockini06", SqlDbType.Decimal).Value = BE.stockini06;
                        cmd.Parameters.Add("@stockini07", SqlDbType.Decimal).Value = BE.stockini07;
                        cmd.Parameters.Add("@stockini08", SqlDbType.Decimal).Value = BE.stockini08;
                        cmd.Parameters.Add("@stockini09", SqlDbType.Decimal).Value = BE.stockini09;
                        cmd.Parameters.Add("@stockini10", SqlDbType.Decimal).Value = BE.stockini10;
                        cmd.Parameters.Add("@stockini11", SqlDbType.Decimal).Value = BE.stockini11;
                        cmd.Parameters.Add("@stockini12", SqlDbType.Decimal).Value = BE.stockini12;
                        cmd.Parameters.Add("@valorini01", SqlDbType.Decimal).Value = BE.valorini01;
                        cmd.Parameters.Add("@valorini02", SqlDbType.Decimal).Value = BE.valorini02;
                        cmd.Parameters.Add("@valorini03", SqlDbType.Decimal).Value = BE.valorini03;
                        cmd.Parameters.Add("@valorini04", SqlDbType.Decimal).Value = BE.valorini04;
                        cmd.Parameters.Add("@valorini05", SqlDbType.Decimal).Value = BE.valorini05;
                        cmd.Parameters.Add("@valorini06", SqlDbType.Decimal).Value = BE.valorini06;
                        cmd.Parameters.Add("@valorini07", SqlDbType.Decimal).Value = BE.valorini07;
                        cmd.Parameters.Add("@valorini08", SqlDbType.Decimal).Value = BE.valorini08;
                        cmd.Parameters.Add("@valorini09", SqlDbType.Decimal).Value = BE.valorini09;
                        cmd.Parameters.Add("@valorini10", SqlDbType.Decimal).Value = BE.valorini10;
                        cmd.Parameters.Add("@valorini11", SqlDbType.Decimal).Value = BE.valorini11;
                        cmd.Parameters.Add("@valorini12", SqlDbType.Decimal).Value = BE.valorini12;
                        cmd.Parameters.Add("@stockini", SqlDbType.Decimal).Value = BE.stockini;
                        cmd.Parameters.Add("@valorini", SqlDbType.Decimal).Value = BE.valorini;
                        cmd.Parameters.Add("@stock", SqlDbType.Decimal).Value = BE.stock;
                        cmd.Parameters.Add("@valoractual", SqlDbType.Decimal).Value = BE.valoractual;
                        cmd.Parameters.Add("@pendingreso", SqlDbType.Decimal).Value = BE.pendingreso;
                        cmd.Parameters.Add("@pendsalida", SqlDbType.Decimal).Value = BE.pendsalida;
                        cmd.Parameters.Add("@costopromed", SqlDbType.Decimal).Value = BE.costopromed;
                        cmd.Parameters.Add("@costoultimo", SqlDbType.Decimal).Value = BE.costoultimo;
                        cmd.Parameters.Add("@codigoubic", SqlDbType.Char, 5).Value = BE.codigoubic;
                        cmd.Parameters.Add("@cantingreso", SqlDbType.Decimal).Value = BE.cantingreso;
                        cmd.Parameters.Add("@impoingreso", SqlDbType.Decimal).Value = BE.impoingreso;
                        cmd.Parameters.Add("@cantsalida", SqlDbType.Decimal).Value = BE.cantsalida;
                        cmd.Parameters.Add("@imposalida", SqlDbType.Decimal).Value = BE.imposalida;
                        cmd.Parameters.Add("@nivelreposicion", SqlDbType.Decimal).Value = BE.nivelreposicion;
                    }
                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public bool ReorgAnioMes(string empresaid, tb_ad_local_stock BE)
 {
     return tablaDA.ReorgAnioMes(empresaid, BE);
 }
 public bool Update(string empresaid, tb_ad_local_stock BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public DataSet GetAll_productostockxlocal(string empresaid, tb_ad_local_stock BE)
 {
     return tablaDA.GetAll_productostockxlocal(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_ad_local_stock BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public bool CierreDePeriodo(string empresaid, tb_ad_local_stock BE)
 {
     return tablaDA.CierreDePeriodo(empresaid, BE);
 }
예제 #10
0
        private void ValidaTabladetallemovmov(String xproductid)
        {
            Decimal xprecio = 0, xprecunit = 0, xcantidad = 0, xcostoprom = 0, tipcamb = 0;
            var desct1 = 0;
            Decimal imporfac = 0;
            Decimal import = 0;
            Decimal totimpx = 0;

            griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productname"].Value = string.Empty;
            txt_stock.Text = "0";
            txt_valor.Text = "0";
            griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precunit"].Value = "0";
            griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importfac"].Value = "0";

            if (xproductid.Trim().Length == 13)
            {
                var BL = new tb_ad_local_stockBL();
                var BE = new tb_ad_local_stock();
                var DT = new DataTable();

                BE.moduloid = modulo;
                BE.local = local;
                BE.productid = xproductid;

                DT = BL.GetAll(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().PadLeft(1, '0'));
                    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);

                    if (almacaccionid.Substring(0, 1) == "2")
                    {
                        xprecventa = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["precventa"]).ToString("###,###,##0.000000"));
                        xprecio = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000"));
                        txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000");
                        xcostoprom = Convert.ToDecimal(DT.Rows[0]["costopromed"].ToString().Trim().PadLeft(1, '0'));
                    }
                    else
                    {
                        if (almacaccionid.Substring(0, 1) == "1")
                        {
                            xcostoultimo = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000"));
                            xprecio = Convert.ToDecimal(Convert.ToDecimal(DT.Rows[0]["costoultimo"]).ToString("###,###,##0.000000"));
                            txt_valor.Text = Convert.ToDecimal(DT.Rows[0]["costoultimo"].ToString().Trim().PadLeft(1, '0')).ToString("###,###,##0.0000");
                        }
                    }

                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precventa"].Value = xprecventa;
                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["costoultimo"].Value = xcostoultimo;
                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["costopromed"].Value = xcostoprom;

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

                    if (moneda.SelectedValue.ToString() == "S")
                    {
                        xprecunit = xprecio;
                    }
                    else
                    {
                        xprecunit = xprecio / tipcamb;
                    }

                    _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 = xprecunit;
                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["importe"].Value = Math.Round(xcantidad * xprecunit, 6);
                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["dtotimpto"].Value = totimpx;

                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["cantidad"].Value = xcantidad;
                    griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["precunit"].Value = xprecunit;
                    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);
            }
        }
예제 #11
0
        private void btn_actualizar_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow fila in griddetallemov.Rows)
            {
                var xproductid = griddetallemov.Rows[fila.Index].Cells["productid"].Value.ToString();
                if (xproductid.Trim().Length == 13)
                {
                    var BL = new tb_ad_local_stockBL();
                    var BE = new tb_ad_local_stock();
                    var DT = new DataTable();

                    BE.moduloid = modulo;
                    BE.productid = xproductid;

                    DT = BL.GetAll(EmpresaID, BE).Tables[0];

                    if (DT.Rows.Count > 0)
                    {
                        griddetallemov.Rows[fila.Index].Cells["productname"].Value = DT.Rows[0]["productname"].ToString().Trim();
                    }
                    else
                    {
                        MessageBox.Show("Producto no existe !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Producto no existe !!! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #12
0
        private void Tabla_DetGuia()
        {
            Decimal xxprecventa = 0, xxcostoultimo = 0, xxstock = 0, xxcostopromed = 0;
            griddetallemov.AutoGenerateColumns = false;

            var BL = new tb_ad_movimientosBL();
            var BE = new tb_ad_movimientos();
            var dt = new DataTable();

            BE.moduloid = modulo;
            BE.local = local;
            BE.tipodoc = tipguia.Text.ToString();
            BE.serdoc = serguia.Text.Trim();
            BE.numdoc = numguia.Text;

            dt = BL.GetAll(EmpresaID, BE).Tables[0];

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow fila in dt.Rows)
                {
                    var BL2 = new tb_ad_local_stockBL();
                    var BE2 = new tb_ad_local_stock();
                    var dt2 = new DataTable();

                    BE2.moduloid = modulo;
                    BE2.local = local;
                    BE2.productid = fila["productid"].ToString();

                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];

                    if (dt2.Rows.Count > 0)
                    {
                        if (almacaccionid.Trim() == "20" || almacaccionid.Trim() == "21")
                        {
                            lbl_valor.Text = "Cost.Prom";
                            xxprecventa = Convert.ToDecimal(dt2.Rows[0]["precventa"]);
                            xxcostopromed = Convert.ToDecimal(dt2.Rows[0]["costopromed"]);
                        }
                        else
                        {
                            if (almacaccionid.Trim() == "10" || almacaccionid.Trim() == "11")
                            {
                                lbl_valor.Text = "Cost.Ultm";
                                xxcostoultimo = Convert.ToDecimal(dt2.Rows[0]["costoultimo"]);
                            }
                        }
                        xxstock = Convert.ToDecimal(dt2.Rows[0]["stock"]);
                        if (xxstock == 0)
                        {
                            xxstock = Convert.ToDecimal(dt2.Rows[0]["stockini"]);
                        }
                    }

                    row = Tabladetallemov.NewRow();
                    row["itemref"] = fila["itemref"].ToString();
                    row["items"] = fila["items"].ToString();
                    row["productid"] = fila["productid"].ToString().Trim();
                    row["productname"] = fila["productname"].ToString().Trim();

                    var cantidad = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);

                    row["stock"] = xxstock;

                    row["precventa"] = xxprecventa;
                    row["costoultimo"] = xxcostoultimo;
                    row["costopromed"] = xxcostopromed;

                    row["cantidad"] = cantidad;
                    row["cantidad_old"] = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);
                    row["precunit"] = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6);
                    var precunit = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6);
                    Decimal importe;
                    importe = cantidad * precunit;

                    row["importfac"] = importe;
                    row["valor"] = Math.Round(Convert.ToDecimal(fila["valor"]), 6);
                    row["importe"] = Math.Round(Convert.ToDecimal(fila["importe"]), 6);
                    row["totimpto"] = Math.Round(Math.Round(Convert.ToDecimal(fila["importe"]), 6) * (Convert.ToDecimal(18) / 100), 6);
                    row["almacaccionid"] = almacaccionid.Trim();
                    Tabladetallemov.Rows.Add(row);
                    griddetallemov.DataSource = Tabladetallemov;
                }

                _RecalculoGrid();
            }
            else
            {
                return;
            }
        }
예제 #13
0
        private void data_Tabladetallemovmov_referencia()
        {
            try
            {
                Decimal xxprecventa = 0;
                Decimal xxcostoultimo = 0;
                Decimal xxstock = 0;
                Decimal xxcostopromed = 0;
                griddetallemov.AutoGenerateColumns = false;

                var BL = new tb_ad_movimientosBL();
                var BE = new tb_ad_movimientos();
                var dt = new DataTable();
                BE.moduloid = modulo;
                BE.local = local;
                BE.tipodoc = tipfac.Text.Trim();
                BE.serdoc = serfac.Text.Trim().PadLeft(4, '0');
                BE.numdoc = numfac.Text.Trim().PadLeft(6, '0');

                dt = null; //BL.GetAll_datosdetalle(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    statcostopromed = dt.Rows[0]["statcostopromed"].ToString();
                    tiptransac = dt.Rows[0]["tiptransac"].ToString();
                    incprec = dt.Rows[0]["incprec"].ToString().Trim();
                }

                if (Tabladetallemov != null)
                {
                    Tabladetallemov.Clear();
                }

                foreach (DataRow fila in dt.Rows)
                {
                    var BL2 = new tb_ad_local_stockBL();
                    var BE2 = new tb_ad_local_stock();
                    var dt2 = new DataTable();
                    BE2.moduloid = modulo;
                    BE2.productid = fila["productid"].ToString();
                    dt2.Clear();
                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];

                    if (dt2.Rows.Count > 0)
                    {

                        if (almacaccionid.Trim() == "20" || almacaccionid.Trim() == "21")
                        {
                            lbl_valor.Text = "Cost.Prom";
                            xxprecventa = 0;
                            xxcostopromed = Convert.ToDecimal(dt2.Rows[0]["costopromed"]);
                        }
                        else
                        {
                            if (almacaccionid.Trim() == "10" || almacaccionid.Trim() == "11")
                            {
                                lbl_valor.Text = "Cost.Ultm";
                                xxcostoultimo = Convert.ToDecimal(dt2.Rows[0]["costoultimo"]);
                            }
                        }
                        xxstock = Convert.ToDecimal(dt2.Rows[0]["stock"]);
                    }

                    row = Tabladetallemov.NewRow();
                    row["itemref"] = fila["itemref"].ToString();
                    row["items"] = fila["items"].ToString();
                    row["productid"] = fila["productid"].ToString().Trim();
                    row["productname"] = fila["productname"].ToString().Trim();
                    row["rollo"] = fila["rollo"].ToString();
                    row["stock"] = xxstock;
                    row["stock_old"] = xxstock;
                    row["precventa"] = xxprecventa;
                    row["costoultimo"] = xxcostoultimo;
                    row["costopromed"] = xxcostopromed;

                    var cantidad = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);
                    var cantidadcta = Math.Round(Convert.ToDecimal(fila["cantidadcta"]), 4);
                    Decimal total;
                    total = cantidad - cantidadcta;

                    row["cantidad"] = total;

                    row["cantidad_old"] = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);
                    row["precunit"] = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6);
                    row["importfac"] = Math.Round(Convert.ToDecimal(fila["importfac"]), 2);
                    row["valor"] = Math.Round(Convert.ToDecimal(fila["valor"]), 6);
                    row["importe"] = Math.Round(Convert.ToDecimal(fila["importe"]), 6);
                    row["totimpto"] = Math.Round(Math.Round(Convert.ToDecimal(fila["importe"]), 6) * (Convert.ToDecimal(18) / 100), 6);
                    row["almacaccionid"] = almacaccionid.Trim();
                    row["unmed"] = fila["unmed"].ToString().Trim();
                    row["ubicacion"] = fila["ubicacion"].ToString().Trim();
                    row["nostock"] = xnostock;
                    Tabladetallemov.Rows.Add(row);
                }
                griddetallemov.DataSource = Tabladetallemov;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }