public DataSet GetAll2(string empresaid, tb_t1_tarjgrupo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbT1Tarjeta_SEARCH2", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 //cmd.Parameters.Add("@tarjetaid", SqlDbType.Int).Value = BE.tarjetaid;
                 //cmd.Parameters.Add("@tarjetaname", SqlDbType.VarChar, 50).Value = BE.tarjetaname;
                 //cmd.Parameters.Add("@filtro", SqlDbType.Char, 1).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_t1_tarjgrupo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbTarjgrupo_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tarjgrupoid", SqlDbType.Int).Value = BE.tarjgrupoid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private void Update()
        {
            try
            {
                if (tarjgrupoid.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Falta Codigo Tarjeta !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (tarjgruponame.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese Nombre de línea", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new tb_t1_tarjgrupoBL();
                        var BE = new tb_t1_tarjgrupo();

                        BE.tarjgrupoid = Convert.ToInt32(tarjgrupoid.Text.Trim());
                        BE.tarjgruponame = tarjgruponame.Text.ToUpper();

                        if (BL.Update(EmpresaID, BE))
                        {
                            SEGURIDAD_LOG("M");
                            MessageBox.Show("Datos Modificado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            procesado = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Insert()
        {
            try
            {
                if (tarjgruponame.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese nombre de Tarjeta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_t1_tarjgrupoBL();
                    var BE = new tb_t1_tarjgrupo();

                    BE.tarjgruponame = tarjgruponame.Text.ToUpper();

                    if (BL.Insert(EmpresaID, BE))
                    {
                        MessageBox.Show("Datos Grabados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        procesado = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Delete()
        {
            try
            {
                if (tarjgrupoid.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Falta Codigo Tarjeta !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_t1_tarjgrupoBL();
                    var BE = new tb_t1_tarjgrupo();

                    BE.tarjgrupoid = Convert.ToInt32(tarjgrupoid.Text.Trim());

                    if (BL.Delete(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("E");
                        MessageBox.Show("Datos Eliminados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        form_bloqueado(false);
                        data_TablaTarjeta();
                        btn_nuevo.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_TablaTarjeta()
        {
            try
            {
                if (TablaTarjeta.Rows.Count > 0)
                {
                    TablaTarjeta.Rows.Clear();
                }
                var BL = new tb_t1_tarjgrupoBL();
                var BE = new tb_t1_tarjgrupo();

                BE.tarjgruponame = txt_criterio.Text.Trim().ToUpper();

                TablaTarjeta = BL.GetAll(EmpresaID, BE).Tables[0];
                if (TablaTarjeta.Rows.Count > 0)
                {
                    btn_imprimir.Enabled = true;
                    gridTarjeta.DataSource = TablaTarjeta;
                    gridTarjeta.Rows[0].Selected = false;
                    gridTarjeta.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public bool Update(string empresaid, tb_t1_tarjgrupo BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_t1_tarjgrupo BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public String GetNextCod(string empresaid, tb_t1_tarjgrupo BE)
 {
     return tablaDA.GetNextCod(empresaid, BE);
 }
 public DataSet GetAll_direc(string empresaid, tb_t1_tarjgrupo BE)
 {
     return tablaDA.GetAll_direc(empresaid, BE);
 }
        private void _CargarGrupoTarjetas()
        {
            var BL = new tb_t1_tarjgrupoBL();
            var BE = new tb_t1_tarjgrupo();
            var dt = new DataTable();

            dt = BL.GetAll(EmpresaID, BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                cmb_tarjgrupoid.DataSource = dt;
                cmb_tarjgrupoid.ValueMember = "tarjgrupoid";
                cmb_tarjgrupoid.DisplayMember = "tarjgruponame";
            }
        }
        public String GetNextCod(string empresaid, tb_t1_tarjgrupo BE)
        {
            String newcod = "";

            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCliente_SEARCH_nextcod", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    try
                    {
                        cnx.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.Read())
                        {
                            newcod = Convert.ToString(reader["nextcod"]);
                        }
                        return newcod;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public DataSet GetAll_direc(string empresaid, tb_t1_tarjgrupo BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCliente_SEARCH_direc", cnx))
                {
                    DataSet ds = new DataSet();
                    {
                        //cmd.CommandType = CommandType.StoredProcedure;
                        //cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                        //cmd.Parameters.Add("@ctactename", SqlDbType.VarChar, 70).Value = BE.ctactename;
                        //cmd.Parameters.Add("@docuidentid", SqlDbType.Char, 1).Value = BE.docuidentid;
                        //cmd.Parameters.Add("@nmruc", SqlDbType.Char, 11).Value = BE.nmruc;
                        //cmd.Parameters.Add("@tpperson", SqlDbType.Char, 2).Value = BE.tpperson;
                        //cmd.Parameters.Add("@agerent", SqlDbType.Bit).Value = BE.agerent;
                        //cmd.Parameters.Add("@appat", SqlDbType.VarChar, 20).Value = BE.appat;

                    }
                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);
                        }
                        return ds;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }