public void U_CargaDatos()
        {
            var xpalabra1 = string.Empty;
            var xpalabra2 = string.Empty;
            var xpalabra3 = string.Empty;
            if (txtNombre.Enabled)
            {
                xpalabra1 = VariablesPublicas.Palabras(txtNombre.Text.Trim(), 1);
                xpalabra2 = VariablesPublicas.Palabras(txtNombre.Text.Trim(), 2);
                xpalabra3 = VariablesPublicas.Palabras(txtNombre.Text.Trim(), 3);
            }
            var BL = new ubigeoBL();
            var BE = new tb_ubigeo();

            BE.nombrelike1 = xpalabra1;
            BE.nombrelike2 = xpalabra2;
            BE.nombrelike3 = xpalabra3;
            tabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];

            btnRefrescar.Enabled = true;
            var sorted = default(SortOrder);
            var xnomcolumna = string.Empty;
            if ((Examinar.SortedColumn != null))
            {
                xnomcolumna = Examinar.Columns[Examinar.SortedColumn.Index].Name;
                sorted = Examinar.SortOrder;
            }
            Examinar.AutoGenerateColumns = false;
            Examinar.DataSource = tabla;
            Examinar.AllowUserToResizeRows = false;
            if (xnomcolumna.Trim().Length > 0)
            {
                if (sorted == SortOrder.Ascending)
                {
                    Examinar.Sort(Examinar.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Ascending);
                }
                else
                {
                    Examinar.Sort(Examinar.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Descending);
                }
            }
            else
            {
                Examinar.Sort(Examinar.Columns["ubige"], System.ComponentModel.ListSortDirection.Ascending);
            }
            if (Examinar.Rows.Count > 0)
            {
                Examinar.CurrentCell = Examinar.Rows[0].Cells["depar"];
                Examinar.Focus();
                Examinar.BeginEdit(true);
            }
        }
 private void FillResultProviN(ComboBox cboPN, ComboBox cboTN, string iddepartN)
 {
     var BL = new ubigeoBL();
     var BE = new tb_ubigeo();
     BE.ubige = iddepartN;
     try
     {
         cboPN.DataSource = BL.GetAll_provi(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
         cboPN.ValueMember = "ubige";
         cboPN.DisplayMember = "provi";
         if (cboPN.Items.Count > 0)
         {
             cboPN.SelectedIndex = 0;
             FillResultDistrN(cboTN, cboPN.SelectedValue.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void FillResultDepar(ComboBox cboD, ComboBox cboP, ComboBox cboT)
 {
     var BL = new ubigeoBL();
     var BE = new tb_ubigeo();
     try
     {
         cboD.DataSource = BL.GetAll_depar(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
         cboD.ValueMember = "ubige";
         cboD.DisplayMember = "depar";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void FillResultDistrN(ComboBox cboTN, string idproviN)
 {
     var BL = new ubigeoBL();
     var BE = new tb_ubigeo();
     BE.ubige = idproviN;
     try
     {
         cboTN.DataSource = BL.GetAll_distr(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
         cboTN.ValueMember = "ubige";
         cboTN.DisplayMember = "Distr";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        internal void ValidaUbigeo()
        {
            Int16 lc_cont;
            var zhallado = false;

            var VMNROITEM = gridAnexos.Rows[gridAnexos.CurrentRow.Index].Cells["direcnume"].Value.ToString();
            var xcodartic = "..";
            if (!(gridAnexos.Rows[gridAnexos.CurrentRow.Index].Cells["ubige"].Value == DBNull.Value))
            {
                xcodartic = gridAnexos.Rows[gridAnexos.CurrentRow.Index].Cells["ubige"].Value.ToString();
            }
            if ( xcodartic.Trim().Length == 0 )
            {
                zhallado = true;
            }
            else
            {
                var BL = new ubigeoBL();
                var BE = new tb_ubigeo();

                BE.ubige = xcodartic;
                tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                for (lc_cont = 0; lc_cont < TablaAnexos.Rows.Count; lc_cont++)
                {
                    if (TablaAnexos.Rows[lc_cont]["direcnume"].ToString() == VMNROITEM )
                    {
                        if ( tmptabla.Rows.Count > 0 )
                        {
                            TablaAnexos.Rows[lc_cont]["ubige"] = tmptabla.Rows[0]["ubige"];
                            txtUbigeoanexos.Text = tmptabla.Rows[0]["depar"] + " - " + tmptabla.Rows[0]["provi"] + " - " + tmptabla.Rows[0]["distr"];
                            zhallado = true;
                            break;
                        }
                    }
                }
            }
            if ( ! zhallado )
            {
                gridAnexos.Rows[gridAnexos.CurrentRow.Index].Cells["ubige"].Value = j_CodUbigeo;
            }
            gridAnexos.Refresh();
        }