private void BtEliminar_Click(object sender, EventArgs e) { try { DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf"); string[] para = { "@user" }; string[] ele = { TxtUserName.Text }; if (DBControl.Buscar("Select * from [Registro] where [materia]= @user", para, ele)) { MessageBox.Show("Esta materia actualmente figura en una seccion, imposible eliminar"); TxtUserName.Clear(); return; } else { if (DBControl.Eliminar("Delete from [Materias] where [Clave] = @user", para, ele)) { MessageBox.Show("Materia eliminado con exito"); LVUsuarios.Clear(); } else { MessageBox.Show("Error al eliminar Materia"); } } } catch (Exception) { MessageBox.Show("Por favor, verificar los datos"); } }
private void TxtUserName_TextChanged(object sender, EventArgs e) { if (TxtUserName.Text.Length > 0) { DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf"); LVUsuarios.Clear(); string[] _parameters = { "@userN", "@Materia" }; string[] _element = { TxtUserName.Text, TxtMateria.Text }; foreach (string[] item in DBControl.Buscar("Select [Materia] from [Registro] where [Alumno] = @userN ", _parameters, _element, 1)) { foreach (var it in item) { LVUsuarios.Items.Add(new ListViewItem(it)); } } } }
private void TxtUserName_TextChanged(object sender, EventArgs e) { if (TxtUserName.Text.Length > 0) { DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf"); LVUsuarios.Clear(); string[] _parameters = { "@userN" }; string[] _element = { TxtUserName.Text }; string[] _returned = { "UserName" }; foreach (string[] item in DBControl.Buscar("Select [ID] from [Maestros] where [ID] like '%' + @userN + '%'", _parameters, _element, 1)) { foreach (var it in item) { LVUsuarios.Items.Add(new ListViewItem(it)); } } } }
private void BtEliminar_Click(object sender, EventArgs e) { try { DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf"); string[] para = { "@user" }; string[] ele = { TxtUserName.Text }; if (DBControl.Eliminar("Delete from Maestros where [ID] = @user", para, ele)) { MessageBox.Show("Maestro eliminado con exito"); LVUsuarios.Clear(); } else { MessageBox.Show("Error al eliminar maestro"); } } catch (Exception) { MessageBox.Show("Por favor, verificar los datos"); } }
private void BtEliminar_Click(object sender, EventArgs e) { try { DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf"); string[] _parameters = { "@userN", "@Materia" }; string[] _element = { TxtUserName.Text, TxtMateria.Text }; if (DBControl.Eliminar("Delete from [Registro] where [Alumno] = @userN and [Materia] = @Materia ", _parameters, _element)) { MessageBox.Show("Registro eliminado con exito"); LVUsuarios.Clear(); } else { MessageBox.Show("Error al eliminar usuario"); } } catch (Exception) { MessageBox.Show("Por favor, verificar los datos"); } }