Esempio n. 1
0
 public DataSet GetAll(string empresaid, tb_ubigeo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbUbigeo_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@ubige", SqlDbType.Char, 6).Value = BE.ubige;
                 cmd.Parameters.Add("@depar", SqlDbType.VarChar, 30).Value = BE.depar;
                 cmd.Parameters.Add("@provi", SqlDbType.VarChar, 30).Value = BE.provi;
                 cmd.Parameters.Add("@distr", SqlDbType.VarChar, 30).Value = BE.distr;
                 cmd.Parameters.Add("@nombrelike1", SqlDbType.VarChar, 30).Value = BE.nombrelike1;
                 cmd.Parameters.Add("@nombrelike2", SqlDbType.VarChar, 30).Value = BE.nombrelike2;
                 cmd.Parameters.Add("@nombrelike3", SqlDbType.VarChar, 30).Value = BE.nombrelike3;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Esempio n. 2
0
 public DataSet GetAll_depar(string empresaid, tb_ubigeo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbUbigeo_SEARCH_depar", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Esempio n. 3
0
 public bool Delete(string empresaid, tb_ubigeo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbUbigeo_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@ubige", SqlDbType.Char, 6).Value = BE.ubige;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        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 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);
     }
 }
 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);
     }
 }
Esempio n. 8
0
        public bool Insert(string empresaid, tb_ubigeo BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbUbigeo_INSERT", cnx))
                {

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@ubige", SqlDbType.Char, 6).Value = BE.ubige;
                    cmd.Parameters.Add("@depar", SqlDbType.VarChar, 30).Value = BE.depar;
                    cmd.Parameters.Add("@provi", SqlDbType.VarChar, 30).Value = BE.provi;
                    cmd.Parameters.Add("@distr", SqlDbType.VarChar, 30).Value = BE.distr;

                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Esempio n. 9
0
 public bool Update(string empresaid, tb_ubigeo BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
Esempio n. 10
0
 public bool Insert(string empresaid, tb_ubigeo BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
Esempio n. 11
0
 public DataSet GetAll_provi(string empresaid, tb_ubigeo BE)
 {
     return tablaDA.GetAll_provi(empresaid, BE);
 }
Esempio n. 12
0
 public bool Delete(string empresaid, tb_ubigeo BE)
 {
     return tablaDA.Delete(empresaid, BE);
 }
        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();
        }