public void fillSistema() { cbp_browseSistema = new List <CheckBoxPairsSistemas>(); string qry_getEventos = "SELECT ID, nombre FROM sistema WHERE isActive = 1"; db.openConn(); using (db.setComm(qry_getEventos)) { db.setReader(); while (db.getReader().Read()) { cbp_browseSistema.Add(new CheckBoxPairsSistemas( Convert.ToString(db.getReader()["ID"]), Convert.ToString(db.getReader()["nombre"]) )); } } db.closeConn(); buscarSistema.DisplayMemberPath = "nombre"; buscarSistema.SelectedValuePath = "ID"; buscarSistema.ItemsSource = cbp_browseSistema; // clear childs of stackpanel with systems stackAutos.Children.Clear(); }
public void fillSystems() { db.openConn(); using (db.setComm(qry_getNoSistemas)) { db.setReader(); while (db.getReader().Read()) { affectedRows = Convert.ToInt32(db.getReader()["numSistemas"]); } } if (affectedRows == 0) { db.sendMBandCloseConn("No hay Sistemas registrados. Por el momento"); noSystems.Visibility = Visibility.Visible; } // llenar el stack con los sistemas encontrados else { string qry_getSistemas = "SELECT ID, nombre FROM sistema WHERE isActive = 1"; using (db.setComm(qry_getSistemas)) { db.setReader(); while (db.getReader().Read()) { cbp.Add(new CheckBoxPairsSistemas( Convert.ToString(db.getReader()["ID"]), Convert.ToString(db.getReader()["nombre"]) )); } } fillStackWithAllSystems(); db.closeConn(); } }
private void Sample1_DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventArgs) { string qry_updateRuta = "UPDATE rutas SET ruta = '" + NuevaRuta.Text + "' WHERE ID = " + ID;; db.openConn(); using (db.setComm(qry_updateRuta)) { db.getComm().ExecuteNonQuery(); } db.closeConn(); RouteChanged.IsOpen = true; }
public void fillUsers() { cbp = new List <ComboBoxPairs>(); string qry_getUsers = "SELECT ID, user FROM usuarios;"; db.openConn(); using (db.setComm(qry_getUsers)) { db.setReader(); while (db.getReader().Read()) { cbp.Add(new ComboBoxPairs( Convert.ToString(db.getReader()["user"]), Convert.ToString(db.getReader()["ID"]) )); } } comboUsuarios.DisplayMemberPath = "user"; comboUsuarios.SelectedValuePath = "ID"; comboUsuarios.ItemsSource = cbp; db.closeConn(); }
public void fillEventos() { cbp = new List <ComboBoxPairsEvento>(); string qry_getEventos = "SELECT ID, nombre FROM evento WHERE is_current = 2"; db.openConn(); using (db.setComm(qry_getEventos)) { db.setReader(); while (db.getReader().Read()) { cbp.Add(new ComboBoxPairsEvento( Convert.ToString(db.getReader()["nombre"]), Convert.ToString(db.getReader()["ID"]) )); } } db.closeConn(); comboEventos.DisplayMemberPath = "nombre"; comboEventos.SelectedValuePath = "ID"; comboEventos.ItemsSource = cbp; }
public void fillEventos() { cbp = new List <ComboBoxPairsEvento>(); string qry_getEventos = "SELECT ID, nombre FROM evento"; db.openConn(); using (db.setComm(qry_getEventos)) { db.setReader(); while (db.getReader().Read()) { cbp.Add(new ComboBoxPairsEvento( Convert.ToString(db.getReader()["nombre"]), Convert.ToString(db.getReader()["ID"]) )); } } db.closeConn(); }
public void fillSistema() { cbp_browseSistema = new List <CheckBoxPairsSistemas>(); string qry_getEventos = "SELECT ID, nombre FROM sistema WHERE isActive = 1"; db.openConn(); using (db.setComm(qry_getEventos)) { db.setReader(); while (db.getReader().Read()) { cbp_browseSistema.Add(new CheckBoxPairsSistemas( Convert.ToString(db.getReader()["ID"]), Convert.ToString(db.getReader()["nombre"]) )); } } db.closeConn(); chooseSystem.DisplayMemberPath = "nombre"; chooseSystem.SelectedValuePath = "ID"; chooseSystem.ItemsSource = cbp_browseSistema; }
public admin() { InitializeComponent(); UserControl usc = null; GridMain.Children.Clear(); usc = new Instruccions(); GridMain.Children.Add(usc); NavigationCommands.BrowseBack.InputGestures.Clear(); NavigationCommands.BrowseForward.InputGestures.Clear(); db = new DB(); string qry_getEvento = "SELECT COUNT(nombre) AS numEventos FROM evento WHERE is_current = 1"; string qry_getEventoNom = "SELECT nombre, ID FROM evento WHERE is_current = 1"; string nom_evento_actual = ""; int ID_evento_actual = 0; db.openConn(); using (db.setComm(qry_getEvento)) { db.setReader(); while (db.getReader().Read()) { affectedRows = Convert.ToInt32(db.getReader()["numEventos"]); } } if (affectedRows == 0) { nombreEvento.Text = SesionUsuario.getUserTipoString(); } else { using (db.setComm(qry_getEventoNom)) { db.setReader(); while (db.getReader().Read()) { nom_evento_actual = Convert.ToString(db.getReader()["nombre"]); ID_evento_actual = Convert.ToInt32(db.getReader()["ID"]); } SesionUsuario.setEvento(nom_evento_actual); SesionUsuario.setIDEvento(ID_evento_actual); } changeEventTitle(); } db.closeConn(); fillEventos(); // Remove elements if not administrator if (SesionUsuario.getUserTipo() == 2) { // AgregarEvento.Visibility = Visibility.Collapsed; AgregarAuto.Visibility = Visibility.Collapsed; AgregarSistema.Visibility = Visibility.Collapsed; AgregarFuncion.Visibility = Visibility.Collapsed; NuevoUsuario.Visibility = Visibility.Collapsed; EliminarUsuario.Visibility = Visibility.Collapsed; ResetPasswords.Visibility = Visibility.Collapsed; Administracion.Visibility = Visibility.Collapsed; } if (SesionUsuario.getUser() == "cesar") { nombreUsuario.Text = "César"; } else { nombreUsuario.Text = SesionUsuario.getUser(); } }
public void inicioSesion(string user, string pass) { // check if user exists string user_exists = ""; db.openConn(); string qry_know_userExists = "SELECT count(user) AS numero FROM usuarios WHERE user = '******'"; using (db.setComm(qry_know_userExists)) { db.setReader(); while (db.getReader().Read()) { user_exists = Convert.ToString(db.getReader()["numero"]); } } // if not, then will return if (user_exists != "1") { sendMBandCloseConn("Revisa tu usuario, no es correcto el nombre."); return; } // else will check password string qry_get_userID = "SELECT * FROM usuarios WHERE user ='******'"; using (db.setComm(qry_get_userID)) { db.setReader(); while (db.getReader().Read()) { user_ID = Convert.ToString(db.getReader()["ID"]); user_name = Convert.ToString(db.getReader()["user"]); user_password = Convert.ToString(db.getReader()["password"]); tipo_user = Convert.ToString(db.getReader()["tipo_user"]); activo = Convert.ToString(db.getReader()["activo"]); isFirstLogin = Convert.ToString(db.getReader()["isFirstLogin"]); } if (activo == "2") { sendMBandCloseConn("Lo siento. No tienes permiso para entrar al sistema"); return; } // here we will check the password if (pass != user_password) { sendMBandCloseConn("Revisa tu contraseña, no es correcta."); return; } // We Verify if is firstLogin of user, if it is, // then we should ask the user to change password and return } db.closeConn(); if (isFirstLogin == "1") { dialogi.IsOpen = true; } else // 0 is when is not first login { // else, we will store data session and Update last login SesionUsuario.setID(Convert.ToInt32(user_ID)); SesionUsuario.setUser(user_name); SesionUsuario.setUserTipo(Convert.ToInt32(tipo_user)); MessageBox.Show("Inicio de Sesión correcto. "); // pasar a siguiente página admin Admin = new admin(); NavigationService.Navigate(Admin); } }
public void fillItems2Edit(string getItems, int autoOrSystem) { RestoreStack.Children.Clear(); items.Clear(); restore.Clear(); itemsRestore.Clear(); ItemsCB.ItemsSource = null; nombreItem.Text = ""; string qry_countItems = "SELECT COUNT(ID) AS count "; string qry_RestoreItems = "SELECT "; db.openConn(); if (autoOrSystem == 1) { using (db.setComm(getItems)) { db.setReader(); while (db.getReader().Read()) { items.Add( new Item2Edit { ID = Convert.ToString(db.getReader()["ID"]), nombre = Convert.ToString(db.getReader()["modelo"]) } ); } } // if car was selected, get elements that are notactive qry_RestoreItems += "ID, modelo FROM autos WHERE isActive = 0"; qry_countItems += "FROM autos WHERE isActive = 0"; using (db.setComm(qry_countItems)) { db.setReader(); while (db.getReader().Read()) { numRegisters = Convert.ToInt32(db.getReader()["count"]); } } if (numRegisters <= 0) { noItems.Visibility = Visibility.Visible; } else { noItems.Visibility = Visibility.Collapsed; using (db.setComm(qry_RestoreItems)) { db.setReader(); while (db.getReader().Read()) { restore.Add( new Item2EditAuto { ID = Convert.ToString(db.getReader()["ID"]), modelo = Convert.ToString(db.getReader()["modelo"]) } ); } } // fill stackpanel with elements that can be restored foreach (Item2EditAuto i2ea in restore) { CheckBox cb = new CheckBox(); cb.Name = "_" + i2ea.ID; cb.Content = i2ea.modelo; RestoreStack.Children.Add(cb); } } } else { /* * using (db.setComm(getItems)) * { * db.setReader(); * while (db.getReader().Read()) * { * items.Add( * new Item2Edit * { * ID = Convert.ToString(db.getReader()["ID"]), * nombre = Convert.ToString(db.getReader()["nombre"]) * } * ); * } * } */ // same for funktion and system, get elements and append them to stack if (whichItem == 2) { qry_RestoreItems += "ID, Funktion FROM funktion WHERE isActive = 0"; qry_countItems += "FROM funktion WHERE isActive = 0"; using (db.setComm(getItems)) { db.setReader(); while (db.getReader().Read()) { items.Add( new Item2Edit { ID = Convert.ToString(db.getReader()["ID"]), nombre = Convert.ToString(db.getReader()["Funktion"]) } ); } } } else { qry_RestoreItems += "ID, nombre FROM sistema WHERE isActive = 0"; qry_countItems += "FROM sistema WHERE isActive = 0"; using (db.setComm(getItems)) { db.setReader(); while (db.getReader().Read()) { items.Add( new Item2Edit { ID = Convert.ToString(db.getReader()["ID"]), nombre = Convert.ToString(db.getReader()["nombre"]) } ); } } } using (db.setComm(qry_countItems)) { db.setReader(); while (db.getReader().Read()) { numRegisters = Convert.ToInt32(db.getReader()["count"]); } } if (numRegisters == 0) { noItems.Visibility = Visibility.Visible; } else { noItems.Visibility = Visibility.Collapsed; using (db.setComm(qry_RestoreItems)) { db.setReader(); while (db.getReader().Read()) { if (whichItem == 2) { itemsRestore.Add( new Item2Edit { ID = Convert.ToString(db.getReader()["ID"]), nombre = Convert.ToString(db.getReader()["Funktion"]) } ); } else { itemsRestore.Add( new Item2Edit { ID = Convert.ToString(db.getReader()["ID"]), nombre = Convert.ToString(db.getReader()["nombre"]) } ); } } } // fill stackpanel with elements that can be restored foreach (Item2Edit i2e in itemsRestore) { CheckBox cb = new CheckBox(); cb.Name = "_" + i2e.ID; cb.Content = i2e.nombre; RestoreStack.Children.Add(cb); } } } db.closeConn(); ItemsCB.DisplayMemberPath = "nombre"; ItemsCB.SelectedValuePath = "ID"; ItemsCB.ItemsSource = items; }
private void Button_Click(object sender, RoutedEventArgs e) { registerCounter = 0; nuevoUsuario = usuario_box.Text; db.openConn(); // count if user exist already using (db.setComm(userExist + "'" + nuevoUsuario + "'")) { db.setReader(); while (db.getReader().Read()) { registerCounter = Convert.ToInt32(db.getReader()["userExist"]); } } // there is an user, so we close DB and return if (registerCounter >= 1) { db.sendMBandCloseConn("Este nombre de Usuario: " + nuevoUsuario + ", ya existe. Elige otro por favor."); return; } db.closeConn(); password = password_box.Password.ToString(); confirmPassword = confirmPassword_box.Password.ToString(); if (password != confirmPassword) { MessageBox.Show("Las contraseñas no coinciden, revísalas por favor."); return; } if (esAdmin.IsChecked == true) { tipo_usuario = "1"; } else { tipo_usuario = "2"; } db.openConn(); string qry_new_user = "******"; qry_new_user += "VALUES('" + password + "', '" + nuevoUsuario + "', '" + tipo_usuario + "', 1, 'fecha', " + 1 + ")"; using (db.setComm(qry_new_user)) { affectedRows = db.getComm().ExecuteNonQuery(); } if (affectedRows == 0) { db.sendMBandCloseConn("No se pudo añadir Usuario. Inténtalo de nuevo"); return; } db.sendMBandCloseConn("Usuario añadido exitosamente."); usuario_box.Clear(); password_box.Clear(); confirmPassword_box.Clear(); }