private void BtnAgregar_Click(object sender, EventArgs e)
        {
            var BL = new tb_ta_prodrolloBL();
            var BE = new tb_ta_prodrollo();
            try
            {
                if (rollodesde.Text.Trim().Length > 0)
                {
                    BE.rollodesde = rollodesde.Text.Trim().PadLeft(10, '0');
                }

                if (rollohasta.Text.Trim().Length > 0)
                {
                    BE.rollohasta = rollohasta.Text.Trim().PadLeft(10, '0');
                }

                if (chkActivar.Checked)
                {
                    if (precio.Text == string.Empty)
                    {
                        MessageBox.Show("Ingrese Precio !!!");
                        return;
                    }
                }

                Data = BL.GetAll_prod(EmpresaID, BE).Tables[0];

                if (Data.Rows.Count > 0)
                {
                    for (var i = 0; i < Data.Rows.Count; i++)
                    {
                        row = Tabladet.NewRow();
                        row["productid"] = Data.Rows[i]["productid"].ToString();
                        row["productname"] = Data.Rows[i]["productname"].ToString();
                        row["rollo"] = Data.Rows[i]["rollo"].ToString();
                        if (chkActivar.Checked)
                        {
                            row["precio"] = Convert.ToDecimal(precio.Text);
                        }
                        row["check"] = Convert.ToBoolean(chkActivar.Checked);

                        Tabladet.Rows.Add(row);
                    }

                    PasaRollos(Tabladet);
                }
            }
            catch (Exception)
            {
            }

            Close();
        }
        private void btn_busqueda_Click(object sender, EventArgs e)
        {
            try
            {
                if (Tablaproductorollo.Rows.Count > 0)
                {
                    Tablaproductorollo.Rows.Clear();
                }
                var BL = new tb_ta_prodrolloBL();
                var BE = new tb_ta_prodrollo();

                switch (cbo_buscar.SelectedIndex)
                {
                    case 0:
                        if (txt_criterio.Text.Trim().Length > 0)
                        {
                            BE.rollo = txt_criterio.Text.Trim().ToUpper().PadLeft(10, '0');
                        }
                        break;
                    case 1:
                        BE.productid = txt_criterio.Text.Trim().ToUpper();
                        break;
                    case 2:
                        BE.productname = txt_criterio.Text.Trim().ToUpper();
                        break;
                    default:
                        break;
                }

                if (rollodesde.Text.Trim().Length > 0)
                {
                    BE.rollodesde = rollodesde.Text.Trim().PadLeft(10, '0');
                }

                if (rollohasta.Text.Trim().Length > 0)
                {
                    BE.rollohasta = rollohasta.Text.Trim().PadLeft(10, '0');
                }

                Tablaproductorollo = BL.GetAll_prod(EmpresaID, BE).Tables[0];

                if (Tablaproductorollo.Rows.Count > 0)
                {
                    gridproductorollo.DataSource = Tablaproductorollo;
                    gridproductorollo.Rows[0].Selected = false;
                    gridproductorollo.Focus();
                }

                double sumatoria = 0, sumatoria2 = 0;
                foreach (DataGridViewRow row in gridproductorollo.Rows)
                {
                    sumatoria += Convert.ToDouble(row.Cells["grollostock"].Value);
                    sumatoria2 += Convert.ToDouble(row.Cells["grollomedcompra"].Value);
                }

                txt_metraje.Text = Convert.ToString(sumatoria.ToString("##,###,##0.00"));
                txt_metraje2.Text = Convert.ToString(sumatoria2.ToString("##,###,##0.00"));
                txtnum_rollos.Text = Convert.ToString(gridproductorollo.Rows.Count.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_Tablaproductorollomov()
        {
            try
            {
                var BL = new tb_ta_prodrolloBL();
                var BE = new tb_ta_prodrollo();

                var dt = new DataTable();

                switch (cbo_buscar.SelectedValue.ToString())
                {
                    case "01":
                        BE.productid = txt_criterio.Text.Trim().ToUpper();
                        break;
                    case "02":
                        BE.productname = txt_criterio.Text.Trim().ToUpper();
                        break;
                    case "03":
                        if (txt_criterio.Text.Trim().Length > 0)
                        {
                            BE.rollo = txt_criterio.Text.Trim().ToUpper().PadLeft(10, '0');
                        }
                        break;
                    default:
                        break;
                }

                if (rollodesde.Text.Trim().Length > 0)
                {
                    BE.rollodesde = rollodesde.Text.Trim().PadLeft(10, '0');
                }

                if (rollohasta.Text.Trim().Length > 0)
                {
                    BE.rollohasta = rollohasta.Text.Trim().PadLeft(10, '0');
                }

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

                if (dt.Rows.Count > 0)
                {
                    Tablaproductorollo = dt;
                    gridproductorollo.DataSource = Tablaproductorollo;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_Tablaproductorollomov()
        {
            try
            {
                var BL = new tb_ta_prodrolloBL();
                var BE = new tb_ta_prodrollo();

                var dt = new DataTable();
                BE.productid = productid.Text.Trim().ToUpper();
                if (rollodesde.Text.Trim().Length > 0)
                {
                    BE.rollodesde = rollodesde.Text.Trim().PadLeft(10, '0');
                }

                if (rollohasta.Text.Trim().Length > 0)
                {
                    BE.rollohasta = rollohasta.Text.Trim().PadLeft(10, '0');
                }

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

                if (dt.Rows.Count > 0)
                {
                    Tablaproductorollo = dt;
                    gridproductorollo.DataSource = Tablaproductorollo;
                    gridproductorollo.Rows[0].Selected = false;
                    gridproductorollo.Focus();
                    btn_impcodbar.Enabled = true;
                    btn_nuevo.Enabled = true;
                }
                else
                {
                    Tablaproductorollo = dt;
                    gridproductorollo.DataSource = Tablaproductorollo;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }