protected void btnGrabar_Click(object sender, EventArgs e)
        {
            Bobina            b         = new Bobina();
            Bobina_Controller controlbo = new Bobina_Controller();

            b.NumeroOp = Request.QueryString["o"].ToString();
            b.Codigo   = txtCodigoB.Text;
            b.pliego   = Request.QueryString["c"].ToString();

            for (int i = 0; i < RadGrid1.Items.Count; i++)
            {
                GridDataItem item = (GridDataItem)RadGrid1.Items[i];
                b.Proveedor = item["Proveedor"].Text;
                b.Marca     = item["Marca"].Text;
                b.Tipo      = item["Tipo"].Text;
                string PBruto = item["Peso_Original"].Text;
                if (PBruto.Length >= 4)
                {
                    b.Peso_Original = Convert.ToInt32(PBruto.ToString().Replace(",", string.Empty));
                }
                else
                {
                    b.Peso_Original = Convert.ToInt32(PBruto);
                }
                string PGr = item["Gramage"].Text;
                if (PGr.Length >= 4)
                {
                    b.Gramage = Convert.ToInt32(PGr.Replace(",", string.Empty));
                }
                else
                {
                    b.Gramage = Convert.ToInt32(PGr);
                }
                string PAncho = item["Ancho"].Text;
                if (PAncho.Length >= 4)
                {
                    b.Ancho = Convert.ToInt32(PAncho.Replace(",", string.Empty));
                }
                else
                {
                    b.Ancho = Convert.ToInt32(PAncho);
                }
            }
            if (Convert.ToInt32(ddlEstado.SelectedValue) == 1)
            {
                b.Responsable   = 1;
                b.Estado_Bobina = 100;
            }
            else
            {
                b.Responsable   = Convert.ToInt32(ddlResponsable.SelectedValue);
                b.Estado_Bobina = Convert.ToInt32(ddlCausa.SelectedValue);
            }
            b.Peso_Tapa       = Convert.ToDouble(txtTapa.Text);
            b.Peso_emboltorio = Convert.ToDouble(txtEmboltorio.Text);
            b.PesoEscarpe     = Convert.ToDouble(txtEscarpe.Text);
            string Fecha = "";

            if (b.Codigo != "")
            {
                if (b.PesoEscarpe <= (30) || txtobs.Visible == true)
                {
                    string Maquina = controlbo.BuscarMaquinaUser(GetDireccionIp(Request));
                    b.Ubicacion = Maquina;
                    if (Maquina != "")
                    {
                        if (controlbo.AgregarBobinaDimen(b, lblUsuario.Text, Maquina, lblSKU.Text, lblFolio.Text))
                        {
                            if ((b.Peso_Tapa < 15) && (b.Peso_emboltorio < 15))
                            {
                                if (b.PesoEscarpe >= (20))
                                {
                                    EnvioCorreo(b, lblUsuario.Text, txtobs.Text.ToString());
                                }

                                string popupScript4 = "<script language='JavaScript'>window.opener.location='Consumo_Dimensionadora.aspx?id=3&Cat=10&o=" + b.NumeroOp + "&c=" + b.pliego + "&f=" + lblFolio.Text + "&t=" + lblCantidad.Text + "&n=" + lblNombreOt.Text + "';window.close();</script>";
                                Page.RegisterStartupScript("PopupScript", popupScript4);
                            }
                            else
                            {
                                Validacion.Visible      = true;
                                Image.ImageUrl          = "../../Images/cross.png";
                                lblvalidacion.Text      = "Peso de Tapa y de Envoltura no debe ser mayor a 15KG.";
                                lblvalidacion.ForeColor = Color.White;
                                Validacion.Attributes.Add("style", "background-color:red");
                            }
                        }
                        else
                        {
                            Validacion.Visible      = true;
                            Image.ImageUrl          = "../../Images/cross.png";
                            lblvalidacion.Text      = "Error al Ingresar Registro a Base de Datos.";
                            lblvalidacion.ForeColor = Color.White;
                            Validacion.Attributes.Add("style", "background-color:red");
                        }
                    }
                }
                else
                {
                    Validacion.Visible      = true;
                    Image.Visible           = false;
                    lblvalidacion.Text      = "Obs.";
                    lblvalidacion.ForeColor = Color.White;
                    Validacion.Attributes.Add("style", "background-color:red");
                    txtobs.Visible = true;
                }
            }
            else
            {
                Validacion.Visible      = true;
                Image.ImageUrl          = "../../Images/cross.png";
                lblvalidacion.Text      = "Codigo de Bobina es un campo obligatorio.";
                lblvalidacion.ForeColor = Color.White;
                Validacion.Attributes.Add("style", "background-color:red");
            }
        }