public DataSet BuscaOrden(string empresaid, tb_cm_ordendecompra BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCmOrdendecompradet_SELECT", 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("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                 cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                 cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                 cmd.Parameters.Add("@items", SqlDbType.Char, 5).Value = BE.filtro;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public bool Delete(string empresaid, tb_cm_ordendecompra BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                SqlTransaction tr = default(SqlTransaction);
                Boolean TransaExito = false;

                using (SqlCommand cmd1 = new SqlCommand("gspTbCmOrdencompra_DELETE", cnx))
                {
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd1.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd1.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                    cmd1.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd1.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    cmd1.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;

                    try
                    {
                        cnx.Open();
                        tr = cnx.BeginTransaction(IsolationLevel.Serializable);
                        cmd1.Transaction = tr;

                        if (cmd1.ExecuteNonQuery() > 0)
                        {
                            TransaExito = true;
                        }

                        if (TransaExito == true)
                        {
                            tr.Commit();
                            return true;
                        }
                        else
                        {
                            tr.Rollback();
                            return false;
                        }

                    }
                    catch (Exception ex)
                    {
                        tr.Rollback();
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public bool GenerarOrdenDetallado(string empresaid, tb_cm_ordendecompra BE)
 {
     return tablaDA.GenerarOrdenDetallado(empresaid, BE);
 }
 public bool Delete(string empresaid, tb_cm_ordendecompra BE1)
 {
     return tablaDA.Delete(empresaid, BE1);
 }
 public DataSet BuscarOrden(string empresaid, tb_cm_ordendecompra BE)
 {
     return tablaDA.BuscaOrden(empresaid, BE);
 }
        private void unmed_SelectedIndexChanged(object sender, EventArgs e)
        {
            var BL = new tb_co_tabla06_unidadmedidaBL();
            var BE = new tb_co_tabla06_unidadmedida();
            var dt = new DataTable();
            var xcodigoid1 = string.Empty;
            var xcodigoid2 = string.Empty;
            Decimal equiv = 0;

            BE.sigla = unmed.SelectedValue.ToString();
            dt = BL.GetAll(EmpresaID, BE).Tables[0];

            if (dt.Rows.Count > 0)
            {
                xcodigoid1 = dt.Rows[0]["codigoid"].ToString();

                var BL2 = new tb_co_tabla06_unidadmedidaBL();
                var BE2 = new tb_co_tabla06_unidadmedida();
                var dt2 = new DataTable();

                if (unmedenvase.Text != string.Empty)
                {
                    BE2.sigla = unmedenvase.SelectedValue.ToString();
                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];

                    if (dt2.Rows.Count > 0)
                    {
                        xcodigoid2 = dt2.Rows[0]["codigoid"].ToString();

                        var BE3 = new tb_cm_ordendecompra();
                        var BL3 = new tb_cm_ordendecompraBL();
                        var dt3 = new DataTable();

                        BE3.Unmed1 = xcodigoid1;
                        BE3.Unmed2 = xcodigoid2;
                        dt3 = BL3.GetAll(EmpresaID, BE3).Tables[0];

                        if (dt3.Rows.Count > 0)
                        {
                            equiv = Convert.ToDecimal(dt3.Rows[0]["equivalencia"].ToString());
                            unidenvase.Text = Convert.ToString(equiv);
                        }
                        else
                        {
                            unidenvase.Text = string.Empty;
                        }
                    }
                }
            }
        }
 public DataSet GetAll(string empresaid, tb_cm_ordendecompra BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCm_equivalencia_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@unmed1", SqlDbType.Char, 3).Value = BE.Unmed1;
                 cmd.Parameters.Add("@unmed2", SqlDbType.Char, 15).Value = BE.Unmed2;
                 cmd.Parameters.Add("@equiv", SqlDbType.Char, 15).Value = BE.Equivalencia;
             }
             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_cm_ordendecompra BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert_det(string empresaid, tb_cm_ordendecompra BE)
 {
     return tablaDA.Insert_det(empresaid, BE);
 }
        public bool Update(string empresaid, tb_cm_ordendecompra BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                SqlTransaction tr = default(SqlTransaction);
                Boolean TransaExito = false;

                using (SqlCommand cmd = new SqlCommand("gspTbCmOrdencompra_UPDATE", cnx))
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                    cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    cmd.Parameters.Add("@moduloiddes", SqlDbType.Char, 4).Value = BE.moduloiddes;
                    cmd.Parameters.Add("@localdes", SqlDbType.Char, 3).Value = BE.localdes;
                    cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                    cmd.Parameters.Add("@fechdoc", SqlDbType.DateTime).Value = fecha(BE.fechdoc);
                    cmd.Parameters.Add("@almacaccionid", SqlDbType.Char, 2).Value = BE.almacaccionid;
                    cmd.Parameters.Add("@ctacteaccionid", SqlDbType.Char, 2).Value = BE.ctacteaccionid;
                    cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                    cmd.Parameters.Add("@ctactename", SqlDbType.VarChar, 70).Value = BE.ctactename;
                    cmd.Parameters.Add("@direc", SqlDbType.VarChar, 70).Value = BE.direc;
                    cmd.Parameters.Add("@tipdid", SqlDbType.Char, 1).Value = BE.tipdid;
                    cmd.Parameters.Add("@nmruc", SqlDbType.Char, 11).Value = BE.nmruc;
                    cmd.Parameters.Add("@tipref", SqlDbType.Char, 2).Value = BE.tipref;
                    cmd.Parameters.Add("@serref", SqlDbType.Char, 4).Value = BE.serref;
                    cmd.Parameters.Add("@numref", SqlDbType.Char, 10).Value = BE.numref;
                    cmd.Parameters.Add("@fechref", SqlDbType.DateTime).Value = fecha(BE.fechref);
                    cmd.Parameters.Add("@tipped", SqlDbType.Char, 2).Value = BE.tipped;
                    cmd.Parameters.Add("@serped", SqlDbType.Char, 4).Value = BE.serped;
                    cmd.Parameters.Add("@numped", SqlDbType.Char, 10).Value = BE.numped;
                    cmd.Parameters.Add("@compradorid", SqlDbType.Char, 4).Value = BE.compradorid;
                    cmd.Parameters.Add("@condpagoid", SqlDbType.Char, 3).Value = BE.condpagoid;
                    cmd.Parameters.Add("@ubige", SqlDbType.Char, 6).Value = BE.ubige;
                    cmd.Parameters.Add("@bruto", SqlDbType.Decimal).Value = BE.bruto;
                    cmd.Parameters.Add("@pdscto", SqlDbType.Decimal).Value = BE.pdscto;
                    cmd.Parameters.Add("@idscto", SqlDbType.Decimal).Value = BE.idscto;
                    cmd.Parameters.Add("@afectoigv", SqlDbType.Bit).Value = BE.afectoigv;
                    cmd.Parameters.Add("@pigv", SqlDbType.Decimal).Value = BE.pigv;
                    cmd.Parameters.Add("@incprec", SqlDbType.Char, 1).Value = BE.incprec;
                    cmd.Parameters.Add("@moneda", SqlDbType.Char).Value = BE.moneda;
                    cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb;
                    cmd.Parameters.Add("@valventa", SqlDbType.Decimal).Value = BE.valventa;
                    cmd.Parameters.Add("@totimpto", SqlDbType.Decimal).Value = BE.totimpto;
                    cmd.Parameters.Add("@totimporte", SqlDbType.Decimal).Value = BE.totimporte;
                    cmd.Parameters.Add("@valor_ocompra", SqlDbType.Decimal).Value = BE.valor_ocompra;
                    cmd.Parameters.Add("@valor_guiado", SqlDbType.Decimal).Value = BE.valor_guiado;
                    cmd.Parameters.Add("@valor_facturado", SqlDbType.Decimal).Value = BE.valor_facturado;
                    cmd.Parameters.Add("@glosa", SqlDbType.VarChar, 1000).Value = BE.glosa;
                    cmd.Parameters.Add("@totpzas", SqlDbType.Decimal).Value = BE.totpzas;
                    cmd.Parameters.Add("@fechentrega", SqlDbType.DateTime).Value = fecha(BE.fechentrega);
                    cmd.Parameters.Add("@fechpago", SqlDbType.DateTime).Value = fecha(BE.fechpago);
                    cmd.Parameters.Add("@fechcancel", SqlDbType.DateTime).Value = fecha(BE.fechcancel);
                    cmd.Parameters.Add("@items", SqlDbType.Decimal).Value = BE.items;
                    cmd.Parameters.Add("@afecdetraccion", SqlDbType.Bit).Value = BE.afecdetraccion;
                    cmd.Parameters.Add("@detraccionid", SqlDbType.Char, 5).Value = BE.detraccionid;
                    cmd.Parameters.Add("@pdetraccion", SqlDbType.Decimal).Value = BE.pdetraccion;
                    cmd.Parameters.Add("@atencion", SqlDbType.VarChar, 100).Value = BE.atencion;
                    cmd.Parameters.Add("@puntollegada", SqlDbType.VarChar, 100).Value = BE.puntollegada;
                    cmd.Parameters.Add("@visado", SqlDbType.Bit).Value = BE.visado;
                    cmd.Parameters.Add("@usuarvisado", SqlDbType.Char, 15).Value = BE.usuarvisado;
                    cmd.Parameters.Add("@observacionvisado", SqlDbType.VarChar, 50).Value = BE.observacionvisado;
                    cmd.Parameters.Add("@fechvisado", SqlDbType.DateTime).Value = fecha(BE.fechvisado);
                    cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                    cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                    cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;

                    //opt
                    cmd.Parameters.Add("@XMLnew", SqlDbType.Xml).Value = BE.GetItemXML();
                    cmd.Parameters.Add("@XMLold", SqlDbType.Xml).Value = BE.GetItemXML();

                    try
                    {
                        cnx.Open();
                        tr = cnx.BeginTransaction(IsolationLevel.Serializable);
                        cmd.Transaction = tr;

                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            TransaExito = true;
                        }

                        if (TransaExito == true)
                        {
                            tr.Commit();
                            return true;
                        }
                        else
                        {
                            tr.Rollback();
                            return false;
                        }

                    }
                    catch (Exception ex)
                    {
                        tr.Rollback();
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public DataSet Report_OrdEmitidasGen(string empresaid, tb_cm_ordendecompra BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCmOrdencompra_REPORT_EmitidasGen", 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("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                    cmd.Parameters.Add("@fechaini", SqlDbType.DateTime).Value = BE.fechaini;
                    cmd.Parameters.Add("@fechafin", SqlDbType.DateTime).Value = BE.fechafin;

                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);
                        }
                        return ds;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public bool Insert_det(string empresaid, tb_cm_ordendecompra BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                SqlTransaction tr = default(SqlTransaction);
                Boolean TransaExito = false;

                using (SqlCommand cmd = new SqlCommand("gspTbCmOrdendecompradet_INSERT_xml2", cnx))
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType = CommandType.StoredProcedure;
                    //opt

                    //cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                    cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    //cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;
                    cmd.Parameters.Add("@XML", SqlDbType.Xml).Value = BE.GetItemXML();

                    try
                    {
                        cnx.Open();
                        tr = cnx.BeginTransaction(IsolationLevel.Serializable);
                        cmd.Transaction = tr;

                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            TransaExito = true;
                        }

                        if (TransaExito == true)
                        {
                            tr.Commit();
                            return true;
                        }
                        else
                        {
                            tr.Rollback();
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        tr.Rollback();
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public DataSet Get_ctactename(string empresaid, tb_cm_ordendecompra.Item BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCm_Ctactename_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloiddes", SqlDbType.Char, 4).Value = BE.moduloiddes;
                 cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public DataSet GetKardex(string empresaid, tb_cm_ordendecompra BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCm_OrdenCompra_Kardex", cnx))
                {
                    DataSet ds = new DataSet();

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@numdoc_desde", SqlDbType.Char, 10).Value = BE.num_desde;
                    cmd.Parameters.Add("@numdoc_hasta", SqlDbType.Char, 10).Value = BE.num_hasta;
                    cmd.Parameters.Add("@grupoid", SqlDbType.Char, 7).Value = BE.grupoid;
                    cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;

                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);
                        }
                        return ds;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public DataSet GetReport2(string empresaid, tb_cm_ordendecompra BE)
 {
     return tablaDA.GetReport2(empresaid, BE);
 }
        private DataTable Ordencompra()
        {
            try
            {
                var TablaOrdencompra = new DataTable("Movimientos");

                var BL = new tb_cm_ordendecompraBL();
                var BE = new tb_cm_ordendecompra();

                BE.moduloid = moduloid.Trim();
                BE.local = local.Trim();
                BE.tipodoc = tipdoc.Trim();
                BE.serdoc = serdoc.Trim();
                BE.numdoc = numdoc.Trim();
                BE.localdes = localdes.ToString();

                if (formulario == "Frm_ordencompra2")
                {
                    TablaOrdencompra = BL.GetReport2(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                }
                else
                {
                    TablaOrdencompra = BL.GetReport(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                }

                if (TablaOrdencompra.Rows.Count > 0)
                {
                    return TablaOrdencompra;
                }
                else
                {
                    return TablaOrdencompra;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 // Consultar
 public DataSet Get_ctactename(string empresaid, tb_cm_ordendecompra.Item BE)
 {
     return tablaDA.Get_ctactename(empresaid, BE);
 }
        private DataTable Reporte_Kardex()
        {
            try
            {
                var TablaOrdencompra = new DataTable("Kardex O/C");

                var BL = new tb_cm_ordendecompraBL();
                var BE = new tb_cm_ordendecompra();

                BE.moduloid = moduloid.Trim();
                BE.num_desde = num_desde.Trim();
                BE.num_hasta = num_hasta.Trim();
                BE.grupoid = grupoid.Trim();
                BE.productid = productid.Trim();

                TablaOrdencompra = BL.GetKardex(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];

                if (TablaOrdencompra.Rows.Count > 0)
                {
                    return TablaOrdencompra;
                }
                else
                {
                    return TablaOrdencompra;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public DataSet Report_OrdEmitidasGen(string empresaid, tb_cm_ordendecompra BE)
 {
     return tablaDA.Report_OrdEmitidasGen(empresaid, BE);
 }
        private DataTable Reporte_OrdEmitidas()
        {
            try
            {
                var TablaOrdencompra = new DataTable();

                var BL = new tb_cm_ordendecompraBL();
                var BE = new tb_cm_ordendecompra();

                BE.moduloid = moduloid.Trim();
                BE.local = local;
                BE.ctacte = grupoid.Trim();
                BE.fechaini = fechaini;
                BE.fechafin = fechafin;

                TablaOrdencompra = BL.Report_OrdEmitidas(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];

                if (TablaOrdencompra.Rows.Count > 0)
                {
                    return TablaOrdencompra;
                }
                else
                {
                    return TablaOrdencompra;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void unmed_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Verificamos el codigoid Primer Combo
            tb_co_tabla06_unidadmedidaBL BL = new tb_co_tabla06_unidadmedidaBL();
            tb_co_tabla06_unidadmedida BE = new tb_co_tabla06_unidadmedida();
            DataTable dt = new DataTable();
            String xcodigoid1 = "", xcodigoid2 = "";
            Decimal equiv = 0;

            BE.sigla = unmed.SelectedValue.ToString();
            dt = BL.GetAll(EmpresaID, BE).Tables[0];

            if (dt.Rows.Count > 0)
            {
                xcodigoid1 = dt.Rows[0]["codigoid"].ToString();

                // Verificamos el Segundo Combo
                tb_co_tabla06_unidadmedidaBL BL2 = new tb_co_tabla06_unidadmedidaBL();
                tb_co_tabla06_unidadmedida BE2 = new tb_co_tabla06_unidadmedida();

                DataTable dt2 = new DataTable();

                if (unmedenvase.Text != "")
                {
                    BE2.sigla = unmedenvase.SelectedValue.ToString();
                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];

                    if (dt2.Rows.Count > 0)
                    {
                        xcodigoid2 = dt2.Rows[0]["codigoid"].ToString();

                        // En Esta Parte Recien Verificamos La Igualdad de Codigos :D
                        tb_cm_ordendecompra BE3 = new tb_cm_ordendecompra();
                        tb_cm_ordendecompraBL BL3 = new tb_cm_ordendecompraBL();
                        DataTable dt3 = new DataTable();

                        BE3.Unmed1 = xcodigoid1;
                        BE3.Unmed2 = xcodigoid2;
                        dt3 = BL3.GetAll(EmpresaID, BE3).Tables[0];

                        if (dt3.Rows.Count > 0)
                        {
                            equiv = Convert.ToDecimal(dt3.Rows[0]["equivalencia"].ToString());
                            unidenvase.Text = Convert.ToString(equiv);
                        }
                        else
                        {
                            unidenvase.Text = "";
                        }
                    }
                }
            }
        }
        public bool GenerarOrdenDetallado(string empresaid, tb_cm_ordendecompra BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCmOrdendecompraDetallado", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@productid", SqlDbType.Char, 13).Value = BE.productid;
                    cmd.Parameters.Add("@numdoc", SqlDbType.Char, 13).Value = BE.numdoc;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd.Parameters.Add("@filtro", SqlDbType.Char, 1).Value = BE.filtro;

                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }