private void btn_busqueda_Click(object sender, EventArgs e)
        {
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();

            BE.moduloid = modulo;
            BE.productid = productid.Text.ToString();
            BE.filtro = "1";

            TablaStock = BL.GetAll_HistorialxProducto(EmpresaID, BE).Tables[0];
            if (TablaStock.Rows.Count > 0)
            {
                dgb_stock.DataSource = TablaStock;
            }
            else
            {
                dgb_stock.DataSource = TablaStock;
            }

            Dgb_historial();
        }
        private void btn_excel_Click(object sender, EventArgs e)
        {
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();
            var TablaMov_ordprod = new DataTable();
            BE.moduloid = modulo.Trim();
            BE.local = local.Trim();
            BE.fechdocini = Convert.ToDateTime(fechdocini.Text.Trim().Substring(0, 10));
            BE.fechdocfin = Convert.ToDateTime(fechdocfin.Text.Trim().Substring(0, 10));
            BE.ser_opi = serop_ini.Text.Trim();
            BE.num_opi = numop_ini.Text.Trim();
            BE.ser_opf = serop_fin.Text.Trim();
            BE.num_opf = numop_fin.Text.Trim();
            if (almacaccionid.SelectedIndex != -1 && almacaccionid.SelectedItem.ToString().Trim().Length > 0)
            {
                BE.almacaccionid = almacaccionid.SelectedValue.ToString();
            }
            BE.filtro = "1";

            TablaMov_ordprod = BL.GetAll_ConsumoxOP(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            if (TablaMov_ordprod.Rows.Count > 0)
            {
                ExportarExcel(TablaMov_ordprod);
            }
        }
        private void Dgb_ControlStock_MouseClick(object sender, MouseEventArgs e)
        {
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();

            if (dgb_mainStock.DataRowCount > 0)
            {
                var xproductid = dgb_mainStock.GetFocusedRowCellValue("productid").ToString();

                BE.moduloid = modulo;
                BE.productid = xproductid.ToString();
                BE.filtro = "2";
                TablaHistorial = BL.GetAll_KardexEstacion(EmpresaID, BE).Tables[0];
                if (TablaHistorial.Rows.Count > 0)
                {
                    Examinar_Historial.DataSource = TablaHistorial;
                }
                else
                {
                    Examinar_Historial.DataSource = TablaHistorial;
                }
            }
        }
        private void cmb_estacion_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmb_estacion.SelectedIndex != -1)
            {
                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();

                BE.moduloid = modulo;
                BE.codigo = cencosid.Text.ToString() + cmb_estacion.SelectedValue.ToString();
                BE.filtro = "1";
                TablaStock = BL.GetAll_KardexEstacion(EmpresaID, BE).Tables[0];

                if (TablaStock.Rows.Count > 0)
                {
                    Dgb_ControlStock.DataSource = TablaStock;
                }
                else
                {
                    Dgb_ControlStock.DataSource = TablaStock;
                }
            }

            if (TablaHistorial.Rows.Count > 0)
            {
                TablaHistorial.Clear();
            }
        }
        private void CargarComboEstaciones()
        {
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();
            var dt = new DataTable();

            BE.moduloid = modulo;
            BE.codigo = cencosid.Text.ToString();
            BE.filtro = "3";

            dt = BL.GetAll_KardexEstacion(EmpresaID, BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                cmb_estacion.DataSource = dt;
                cmb_estacion.DisplayMember = "estacion";
                cmb_estacion.ValueMember = "estacion";
            }
        }
        private void btn_print_Click(object sender, EventArgs e)
        {
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();

            if (cencosid.Text.ToString() == string.Empty)
            {
                MessageBox.Show("Indicar el Centro de Costo ...!!!");
                return;
            }
            if (cmb_estacion.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione una Estación ...!!!");
                return;
            }
            else
            {
                var xproductid = string.Empty;
                var xproductname = string.Empty;
                if (TablaReporte.Rows.Count > 0)
                {
                    TablaReporte.Rows.Clear();
                }
                foreach (DataRow fila in TablaStock.Rows)
                {
                    xproductid = fila["productid"].ToString();
                    xproductname = fila["productname"].ToString();
                    BE.moduloid = modulo.ToString();
                    BE.productid = xproductid.ToString();
                    BE.filtro = "2";

                    TablaHistorial = BL.GetAll_KardexEstacion(EmpresaID, BE).Tables[0];
                    if (TablaHistorial.Rows.Count > 0)
                    {
                        foreach (DataRow rows in TablaHistorial.Rows)
                        {
                            row = TablaReporte.NewRow();
                            row["cencosid"] = cencosid.Text.Trim();
                            row["cencosname"] = cencosname.Text.Trim();
                            row["estacion"] = cmb_estacion.SelectedValue.ToString();
                            row["productid"] = xproductid.ToString();
                            row["productname"] = xproductname.ToString();
                            row["fechdoc"] = rows["fechdoc"].ToString();
                            row["tipodoc"] = rows["tipodoc"].ToString();
                            row["serdoc"] = rows["serdoc"].ToString();
                            row["numdoc"] = rows["numdoc"].ToString();
                            row["cantidad"] = rows["cantidad"].ToString();
                            row["motivo"] = rows["motivo"].ToString();
                            row["perdni"] = rows["perdni"].ToString();
                            row["nombrelargo"] = rows["nombrelargo"].ToString();
                            TablaReporte.Rows.Add(row);
                        }
                    }
                }

                if (TablaReporte.Rows.Count > 0)
                {
                    var miForma = new REPORTES.Frm_reportes();
                    miForma.Table = TablaReporte;
                    miForma.Text = "Stock x Estaciones";
                    miForma.formulario = "Frm_reporte_StockEstacion";
                    miForma.ShowDialog();
                }
            }
        }
        private void ImpresionFormato131()
        {
            var TablaMov_balancestock = new DataTable("mov_balancestock");
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();

            var mes1 = Convert.ToInt32(cboPerimesini.SelectedValue.ToString());
            var mes2 = Convert.ToInt32(cboPerimesfin.SelectedValue.ToString());
            BE.moduloid = modulo;
            BE.local = local;
            BE.perianio = ((MERCADERIA.MainMercaderia)MdiParent).perianio;
            if (mes1 < 10)
            {
                BE.perimesini = "0" + Convert.ToString(cboPerimesini.SelectedValue.ToString());
            }
            else
            {
                BE.perimesini = Convert.ToString(cboPerimesini.SelectedValue.ToString());
            }

            if (mes2 < 10)
            {
                BE.perimesfin = "0" + Convert.ToString(cboPerimesfin.SelectedValue.ToString());
            }
            else
            {
                BE.perimesfin = Convert.ToString(cboPerimesfin.SelectedValue.ToString());
            }

            BE.lineaid = lineaid.Text.Trim();
            BE.grupoid = grupoid.Text.Trim();
            BE.subgrupoid = subgrupoid.Text.Trim();
            BE.productidini = productid.Text.Trim();

            var dt = new DataTable();
            dt = BL.GetAll_Balance(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            TablaMov_balancestock = dt;

            if (TablaMov_balancestock.Rows.Count == 0)
            {
                MessageBox.Show("No existe Información Procesada", "Mensaje del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var miForma = new Frm_Reportes();
                var reporteBalanceStock = new REPORTES.CR_mov_balancestock();
                miForma.Text = "Reporte Balance de Stock";

                Fech_impresion();
                reporteBalanceStock.DataDefinition.FormulaFields["empresaestable"].Text = "': " + VariablesPublicas.EmpresaEstablec.Trim() + "'";
                reporteBalanceStock.DataDefinition.FormulaFields["empresatipo"].Text = "': " + ((MERCADERIA.MainMercaderia)MdiParent).moduloname + "'";
                reporteBalanceStock.DataDefinition.FormulaFields["empresaperiodo"].Text = "': " + VariablesPublicas.N_PrimerMes1.Trim() + " " + VariablesPublicas.perianio.Trim() + "'";
                if (VariablesPublicas.N_FinMes1 == string.Empty)
                {
                    reporteBalanceStock.DataDefinition.FormulaFields["mesperifin"].Text = string.Empty;
                }
                else
                {
                    reporteBalanceStock.DataDefinition.FormulaFields["mesperifin"].Text = "'-   " + VariablesPublicas.N_FinMes1.Trim() + " " + VariablesPublicas.perianio.Trim() + "'";
                }
                reporteBalanceStock.DataDefinition.FormulaFields["fechaimpresion"].Text = "': " + VariablesPublicas.FechImpresion + "'";
                miForma.Table = TablaMov_balancestock;
                miForma.Reporte = reporteBalanceStock;
                miForma.Show();
            }
        }
        private DataTable Movimiento_mov_docsemitido()
        {
            DtReporte = new DataTable("Mov_docsemitido");
            try
            {
                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();

                BE.moduloid = moduloid.Trim();
                BE.local = local.Trim();
                if (tipdoc != null && tipdoc.Trim().Length > 0)
                {
                    BE.tipodoc = tipdoc.Trim();
                }
                BE.mottrasladointid = mottrasladointid.Trim();
                BE.ctacte = ctacte.Trim();
                BE.fechdocini = Convert.ToDateTime(fechdocini.Trim().Substring(0, 10));
                BE.fechdocfin = Convert.ToDateTime(fechdocfin.Trim().Substring(0, 10));
                BE.modcalculo = modcalculo;
                BE.accion = almacaccionid.Trim();

                DtReporte = BL.GetAll_Docsemitidos(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                if (DtReporte != null)
                {
                    return DtReporte;
                }
                else
                {
                    return DtReporte;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        private void dgb_stock_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();
                if (dgb_stock.CurrentRow != null)
                {
                    var xproductid = string.Empty;
                    xproductid = dgb_stock.Rows[e.RowIndex].Cells["productid"].Value.ToString().Trim();

                    BE.moduloid = modulo;
                    BE.productid = xproductid.ToString();
                    BE.filtro = "2";

                    TablaHistorial = BL.GetAll_HistorialxProducto(EmpresaID, BE).Tables[0];
                    if (TablaHistorial.Rows.Count > 0)
                    {
                        dgb_historial.DataSource = TablaHistorial;
                    }
                    else
                    {
                        dgb_historial.DataSource = TablaHistorial;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void Dgb_historial()
        {
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();

            BE.moduloid = modulo;
            BE.productid = productid.Text.ToString();
            BE.filtro = "2";

            TablaHistorial = BL.GetAll_HistorialxProducto(EmpresaID, BE).Tables[0];
            if (TablaHistorial.Rows.Count > 0)
            {
                dgb_historial.DataSource = TablaHistorial;
            }
            else
            {
                dgb_historial.DataSource = TablaHistorial;
            }
        }
        private void btn_print_Click(object sender, EventArgs e)
        {
            tb_60movimientosdetBL BL = new tb_60movimientosdetBL();
            tb_60movimientosdet BE = new tb_60movimientosdet();

            if (productid.Text.ToString() == "")
            {
                MessageBox.Show("Falta el Codigo de Producto ...!!!");
                return;
            }
            else
            {
                String xproductid = "", xproductname = "";
                if (TablaReporte.Rows.Count > 0) { TablaReporte.Rows.Clear(); }
                foreach (DataRow fila in TablaStock.Rows)
                {
                    xproductid = fila["productid"].ToString();
                    xproductname = fila["productname"].ToString();
                    BE.moduloid = modulo.ToString();
                    BE.productid = xproductid.ToString();
                    BE.filtro = "2";

                    TablaHistorial = BL.GetAll_KardexEstacion(EmpresaID, BE).Tables[0];
                    if (TablaHistorial.Rows.Count > 0)
                    {
                        foreach (DataRow rows in TablaHistorial.Rows)
                        {
                            ////row = TablaReporte.NewRow();
                            ////row["cencosid"] = cencosid.Text.Trim();
                            ////row["cencosname"] = cencosname.Text.Trim();
                            ////row["estacion"] = cmb_estacion.SelectedValue.ToString();
                            ////row["productid"] = xproductid.ToString();
                            ////row["productname"] = xproductname.ToString();
                            ////row["fechdoc"] = rows["fechdoc"].ToString();
                            ////row["tipodoc"] = rows["tipodoc"].ToString();
                            ////row["serdoc"] = rows["serdoc"].ToString();
                            ////row["numdoc"] = rows["numdoc"].ToString();
                            ////row["cantidad"] = rows["cantidad"].ToString();
                            ////row["motivo"] = rows["motivo"].ToString();
                            ////row["perdni"] = rows["perdni"].ToString();
                            ////row["nombrelargo"] = rows["nombrelargo"].ToString();
                            ////TablaReporte.Rows.Add(row);
                        }
                    }
                }

                if (TablaReporte.Rows.Count > 0)
                {
                    //REPORTES.Frm_reportes miForma = new REPORTES.Frm_reportes();
                    //miForma.Table = TablaReporte;
                    //miForma.Text = "Stock x Estaciones";
                    //miForma.formulario = "Frm_reporte_StockEstacion";
                    //miForma.ShowDialog();
                }
            }
        }
        private void ImpresionKardexArticulo()
        {
            var TablaProductokardex_tela = new DataTable();
            var BL = new tb_60movimientosdetBL();
            var BE = new tb_60movimientosdet();

            if (cbo_moduloides.SelectedIndex != -1)
            {
                BE.moduloid = cbo_moduloides.SelectedValue.ToString();
            }
            else
            {
                MessageBox.Show("!!!... Seleccione Modulo ...!!!", "Información");
                return;
            }

            if (localdes.SelectedIndex != -1)
            {
                BE.local = localdes.SelectedValue.ToString();
            }
            else
            {
                MessageBox.Show("!!!... Seleccione Local ...!!!", "Información");
                return;
            }

            BE.lineaid = lineaid.Text.Trim();
            BE.grupoid = grupoid.Text.Trim();
            BE.subgrupoid = subgrupoid.Text.Trim();
            BE.productid = productid.Text.Trim();
            BE.colorid = colorid.Text.Trim();
            BE.mottrasladointid = mottrasladointid.Text.Trim();
            BE.Ubicacion = produbic.Text.Trim();
            BE.ctacte = ctacte.Text.Trim();
            BE.direcnume = direcnume.ToString();
            BE.fechdocini = Convert.ToDateTime(fechdocini.Text.Substring(0, 10));
            BE.fechdocfin = Convert.ToDateTime(fechdocfin.Text.Substring(0, 10));

            BE.serref = serref.Text.Trim();
            BE.numref = numdococ1.Text.Trim() + numdococ.Text.Trim();

            if (almacaccionid.SelectedValue.ToString() != string.Empty)
            {
                BE.almacaccionid = almacaccionid.SelectedValue.ToString();
            }
            TablaProductokardex_tela = BL.GetAll_productokardex_tela(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            if (TablaProductokardex_tela.Rows.Count == 0)
            {
                MessageBox.Show("No existe Información Procesada", "Mensaje del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var miForma = new Frm_Reportes();
                var reporteRollokardex = new REPORTES.CR_productokardex();
                miForma.Text = "Reporte de Kardex x Articulo";

                reporteRollokardex.DataDefinition.FormulaFields["fechdoc"].Text = "'DE: " + fechdocini.Text.Substring(0, 10) + "  AL:" + fechdocfin.Text.Substring(0, 10) + "'";
                reporteRollokardex.DataDefinition.FormulaFields["almacen"].Text = "'" + cbo_moduloides.Text+ "'";
                if (modulo.Trim() == "0810")
                {
                    reporteRollokardex.DataDefinition.FormulaFields["name"].Text = "'TIENDA : " + localdes.SelectedValue.ToString() + "  - " + localdes.Text +"'";
                }
                else
                {
                    reporteRollokardex.DataDefinition.FormulaFields["name"].Text = "'LOCAL : " + localdes.SelectedValue.ToString() + "  - " + localdes.Text + "'";
                }

                if (modulo  == "0320")
                {
                    reporteRollokardex.DataDefinition.FormulaFields["varitems"].Text = "'ROLLO'";
                }
                else
                {
                    reporteRollokardex.DataDefinition.FormulaFields["varitems"].Text = "''";
                }
                miForma.Table = TablaProductokardex_tela;
                miForma.Reporte = reporteRollokardex;
                miForma.Show();
            }
        }
        private DataTable Movimiento_rollokardex()
        {
            try
            {
                DtReporte = new DataTable("Rollokardex");

                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();

                BE.moduloid = moduloid;
                BE.local = local;
                BE.lineaid = lineaid;
                BE.grupoid = grupoid;
                BE.subgrupoid = subgrupoid;
                BE.productid = productid;
                BE.colorid = colorid;
                BE.rollo = rollo;

                BE.fechdocini = Convert.ToDateTime(fechdocini.Trim().Substring(0, 10));
                BE.fechdocfin = Convert.ToDateTime(fechdocfin.Trim().Substring(0, 10));

                if (almacaccionid.Trim().Length > 0)
                {
                    BE.almacaccionid = almacaccionid;
                }
                DtReporte = BL.GetAll_rollokardex(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                if (DtReporte != null)
                {
                    return DtReporte;
                }
                else
                {
                    return DtReporte;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        private DataTable Movimiento_mov_ordprod()
        {
            DtReporte = new DataTable("Productostock");
            try
            {
                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();

                BE.moduloid = moduloid.Trim();
                BE.local = local.Trim();

                BE.fechdocini = Convert.ToDateTime(fechdocini.Trim().Substring(0, 10));
                BE.fechdocfin = Convert.ToDateTime(fechdocfin.Trim().Substring(0, 10));
                if (serop_ini.Trim().Length > 0)
                {
                    BE.ser_opi = serop_ini.Trim().PadLeft(4, '0');
                }
                if (numop_ini.Trim().Length > 0)
                {
                    BE.num_opi = numop_ini.Trim().PadLeft(10, '0');
                }
                if (serop_fin.Trim().Length > 0)
                {
                    BE.ser_opf = serop_fin.Trim().PadLeft(4, '0');
                }
                if (numop_fin.Trim().Length > 0)
                {
                    BE.num_opf = numop_fin.Trim().PadLeft(10, '0');
                }
                if (almacaccionid.Trim().Length > 0)
                {
                    BE.almacaccionid = almacaccionid;
                }

                DtReporte = BL.GetAll_ConsumoxOP(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                if (DtReporte != null)
                {
                    return DtReporte;
                }
                else
                {
                    return DtReporte;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        private void DetalleMovimiento(String xtipodocalt, String xnumdocalt)
        {
            try
            {
                Decimal xxprecventa = 0, xxcostoultimo = 0, xxstock = 0, xxcostopromed = 0;
                griddetallemov.AutoGenerateColumns = false;

                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();
                var dt = new DataTable();

                BE.moduloid = modulo;

                if (modulo == "0500")
                {
                    griddetallemov.Columns[4].Visible = true;
                    griddetallemov.Columns[6].Visible = false;
                    griddetallemov.Width = 1085;
                }
                else
                {
                    if (modulo == "0330")
                    {
                        griddetallemov.Columns[4].Visible = false;
                        griddetallemov.Columns[6].Visible = true;
                    }
                    else
                    {
                        griddetallemov.Columns[4].Visible = false;
                        griddetallemov.Columns[6].Visible = false;
                    }
                }
                BE.local = local;
                BE.tipodoc = xtipodocalt.ToString();
                BE.serdoc = serdoc.Text.Trim().PadLeft(4, '0');
                BE.numdoc = xnumdocalt.ToString();

                dt = 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_60local_stockBL();
                    var BE2 = new tb_60local_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 = 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"]);
                    }

                    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["nserie"] = fila["nserie"].ToString().Trim();
                    Tabladetallemov.Rows.Add(row);
                }
                griddetallemov.DataSource = Tabladetallemov;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public bool _ValidaDocuOP()
        {
            var xsigo = true;

            try
            {
                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();
                var ds = new DataSet();

                BE.moduloid = modulo;
                BE.local = local;
                BE.ser_op = ser_op.Text.Trim();
                BE.num_op = num_op.Text.Trim();
                BE.tipodoc = tipodoc.SelectedValue.ToString();
                BE.serdoc = serdoc.Text.Trim();
                BE.numdoc = numdoc.Text.Trim();
                BE.almacaccionid = almacaccionid;

                ds = BL.Get_DocOP(EmpresaID, BE);

                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        var msg = "Error Ord.Prod Habilitado en:\n" +
                                     "----------------------------\n";
                        var msg2 = string.Empty;
                        foreach (DataRow fila in ds.Tables[0].Rows)
                        {
                            msg2 = msg2 +
                                "Fecha :" + fila["fechdoc"].ToString() +
                                "\nDocumento :" + fila["numdoc"].ToString() +
                                "\nDestino :" + fila["ctactename"].ToString() + "\n\n";
                        }
                        xsigo = (MessageBox.Show(msg + msg2, "Desea Proseguir !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return xsigo;
        }
        private DataTable Movimiento_mov_balancestock()
        {
            DtReporte = new DataTable("mov_balancestock");
            try
            {
                var BL = new tb_60movimientosdetBL();
                var BE = new tb_60movimientosdet();

                BE.moduloid = moduloid.ToString();
                BE.local = local.ToString();

                BE.perianio = Peranio.ToString();
                BE.perimesini = Mesdoini.ToString();
                BE.perimesfin = Mesdofin.ToString();
                BE.lineaid = lineaid.Trim();
                BE.grupoid = grupoid.Trim();
                BE.subgrupoid = subgrupoid.Trim();
                BE.productidini = productidini.Trim();

                if (accion)
                {
                    BE.accion = "0";
                }
                else
                {
                    BE.accion = "1";
                }

                DtReporte = BL.GetAll_Balance(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];

                if (DtReporte != null)
                {
                    return DtReporte;
                }
                else
                {
                    return DtReporte;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }