private void frmCab_Load(object sender, EventArgs e) { string clave = cmbClave.SelectedIndex.ToString(); string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True"; //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True"; SqlConnection conn = UsoDB.ConectaBD(strCon); if (conn == null) { MessageBox.Show("Imposible Conectar"); } string strcomand = "select rfcId from rfc where estatus = 'recibido'"; SqlDataReader Lector = UsoDB.Consulta(strcomand, conn); if (Lector == null) { MessageBox.Show("Error en la Consulta"); conn.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { cmbClave.Items.Add(Lector.GetValue(0).ToString()); } } conn.Close(); }
public void CargaUsuario() { string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True"; //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True"; SqlConnection conn = UsoDB.ConectaBD(strCon); if (conn == null) { MessageBox.Show("Imposible Conectar"); return; } string strComando = "select usuarioID from usuarios where Tipo='T'"; SqlDataReader lector = UsoDB.Consulta(strComando, conn); if (lector == null) { MessageBox.Show("Error En La Consulta"); conn.Close(); return; } if (lector.HasRows) { while (lector.Read()) { cmbClaveUsuario.Items.Add(lector.GetValue(0).ToString()); } } conn.Close(); }
public String obtenerTipoUsuario() { String tipo = ""; string usuario = txtUsuario.Text; string contrasena = txtContrasena.Text; //string clave = cmbClave.SelectedItem.ToString(); string strCon = "Data Source=DESKTOP-5J98UPE\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True"; //string strCon = "Data Source=DESKTOP-9D96CMH\\SQLEXPRESS;Initial Catalog=Interceramic;Integrated Security=True"; SqlConnection conn = UsoDB.ConectaBD(strCon); if (conn == null) { MessageBox.Show("Imposible Conectar"); return(null); } string strcomand = "select tipo from usuarios where usuario = '" + usuario + "' and contrasena = '" + contrasena + "'"; SqlDataReader Lector = UsoDB.Consulta(strcomand, conn); if (Lector == null) { MessageBox.Show("Error en la Consulta"); conn.Close(); return(null); } if (Lector.HasRows) { while (Lector.Read()) { //cmbDepartamento.Items.Add(Lector.GetValue(0).ToString()); tipo = Lector.GetValue(0).ToString(); return(tipo); } } else { return(null); } conn.Close(); return(tipo); }