public DataSet GetAll(string empresaid, tb_pais BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPais_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@paisid", SqlDbType.Char, 4).Value = BE.paisid;
                 cmd.Parameters.Add("@paisname", SqlDbType.VarChar, 40).Value = BE.paisname;
             }
             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_pais BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPais_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@paisid", SqlDbType.Char, 4).Value = BE.paisid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public void U_CargaDatos()
        {
            string xpalabra1 = "";
            string xpalabra2 = "";
            string xpalabra3 = "";
            if (txtFilter.Enabled)
            {
                xpalabra1 = VariablesPublicas.Palabras(txtFilter.Text.Trim(), 1);
                xpalabra2 = VariablesPublicas.Palabras(txtFilter.Text.Trim(), 2);
                xpalabra3 = VariablesPublicas.Palabras(txtFilter.Text.Trim(), 3);
            }
            //tabla = ocapa.UBIGEO_CONSULTA("", "", "", xpalabra1, xpalabra2, xpalabra3);
            try
            {
                paisBL BL = new paisBL();
                tb_pais BE = new tb_pais();

                switch (cboFiltro.SelectedItem.ToString())
                {
                    case "Pais":
                        BE.paisname = txtFilter.Text.Trim().ToUpper();
                        break;
                    case "Código":
                        BE.paisid = txtFilter.Text.Trim().ToUpper();
                        break;
                    default:
                        BE.paisid = txtFilter.Text.Trim().ToUpper();
                        break;
                }
                tabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            btnBuscar.Enabled = true;
            SortOrder sorted = default(SortOrder);
            string xnomcolumna = "";
            if ((gridExaminar.SortedColumn != null))
            {
                xnomcolumna = gridExaminar.Columns[gridExaminar.SortedColumn.Index].Name;
                sorted = gridExaminar.SortOrder;
            }
            gridExaminar.AutoGenerateColumns = false;
            gridExaminar.DataSource = tabla;
            gridExaminar.AllowUserToResizeRows = false;
            if (xnomcolumna.Trim().Length > 0)
            {
                if (sorted == SortOrder.Ascending)
                {
                    gridExaminar.Sort(gridExaminar.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Ascending);
                }
                else
                {
                    gridExaminar.Sort(gridExaminar.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Descending);
                }
            }
            else
            {
                gridExaminar.Sort(gridExaminar.Columns["paisid"], System.ComponentModel.ListSortDirection.Ascending);
            }
            if (gridExaminar.Rows.Count > 0)
            {
                gridExaminar.CurrentCell = gridExaminar.Rows[0].Cells["paisname"];
                gridExaminar.Focus();
                gridExaminar.BeginEdit(true);
            }
        }
        private void ValidaPais()
        {
            if (txtpaisid.Text.Trim().Length > 0)
            {
                var BL = new paisBL();
                var BE = new tb_pais();

                BE.paisid = txtpaisid.Text;
                var tmptablaPais = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];

                if (tmptablaPais.Rows.Count == 0)
                {
                    txtpaisid.Text = j_String;
                }
                else
                {
                    txtpaisid.Text = tmptablaPais.Rows[0]["paisid"].ToString();
                    txtpaisname.Text = tmptablaPais.Rows[0]["paisname"].ToString();
                }
            }
            else
            {
                txtpaisid.Text = j_String;
            }
        }
 public bool Update(string empresaid, tb_pais BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_pais BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public DataSet GetAll(string empresaid, tb_pais BE)
 {
     return tablaDA.GetAll(empresaid, BE);
 }
 public bool Delete(string empresaid, tb_pais BE)
 {
     return tablaDA.Delete(empresaid, BE);
 }