private void buttonLogin_Click(object sender, EventArgs e) { if (textBoxId.Text != "") { mysql query = new mysql("password", "funcionarios", "id_func = " + textBoxId.Text); if (query.read()) { if (query.read("password") == textBoxPassword.Text) { Variables.funcId = Convert.ToInt16(textBoxId.Text); query.close(); MessageBox.Show("Bem-vindo!"); livros obj = new livros(); this.Hide(); obj.ShowDialog(); this.Close(); } else { query.close(); MessageBox.Show("Dados inseridos não estão corretos."); } } else { query.close(); MessageBox.Show("Dados inseridos não estão corretos."); } } else { MessageBox.Show("Dados inseridos não estão corretos."); } }
private void viewMode() { mysql query = new mysql("*", "autores", "id_auto = " + id); query.read(); searchId.CBValue = query.read("id_auto").ToString(); searchNome.CBValue = query.read("nome").ToString(); searchNacionalidade.CBValue = query.read("nacionalidade").ToString(); searchDataNascimento.CBValue = query.read("data_nasc").ToString(); if (query.read("data_fale").ToString() == "") { searchDataFalecimento.Visible = false; } else { searchDataFalecimento.Visible = true; searchDataFalecimento.CBValue = query.read("data_fale").ToString(); } query.close(); edit = false; searchNome.CBReadOnly = true; searchNacionalidade.CBReadOnly = true; searchDataNascimento.CBReadOnly = true; searchDataFalecimento.CBReadOnly = true; buttonCancel.Visible = false; buttonSave.Visible = false; buttonEdit.Visible = true; checkBox.Visible = false; buttonEliminar.Visible = false; }
private void viewMode() { mysql query = new mysql("*", "livros", "id_livr = " + id); query.read(); searchId.CBValue = query.read("id_livr").ToString(); searchTitulo.CBValue = query.read("titulo").ToString(); searchPaginas.CBValue = query.read("n_pagi").ToString(); searchCategoria.CBValue = query.read("id_cate").ToString(); searchAutor.CBValue = query.read("id_auto").ToString(); searchEditora.CBValue = query.read("id_edit").ToString(); searchEditora.CBValue = query.read("id_edit").ToString(); searchData.CBValue = query.read("data_lanc").ToString(); query.close(); edit = false; searchTitulo.CBReadOnly = true; searchPaginas.CBReadOnly = true; searchCategoria.CBReadOnly = true; searchAutor.CBReadOnly = true; searchEditora.CBReadOnly = true; searchData.CBReadOnly = true; buttonCancel.Visible = false; buttonSave.Visible = false; buttonEdit.Visible = true; buttonEliminar.Visible = false; }
private void viewMode() { mysql query = new mysql("*", "leitores", "id_leit = " + id); query.read(); searchId.CBValue = query.read("id_leit").ToString(); searchNome.CBValue = query.read("nome").ToString(); searchEmail.CBValue = query.read("email").ToString(); searchMorada.CBValue = query.read("morada").ToString(); searchTelemovel.CBValue = query.read("telemovel").ToString(); query.close(); edit = false; searchNome.CBReadOnly = true; searchEmail.CBReadOnly = true; searchMorada.CBReadOnly = true; searchTelemovel.CBReadOnly = true; buttonCancel.Visible = false; buttonSave.Visible = false; buttonEdit.Visible = true; buttonImagem.Visible = false; buttonEliminar.Visible = false; if (File.Exists(Application.StartupPath + @"\leitores\" + id)) { pictureBox1.ImageLocation = Application.StartupPath + @"\leitores\" + id; } }
private void textBoxColumn_Leave(object sender, EventArgs e) { if (!CBReadOnly) { if (textBoxColumn.Text == "") { textBoxColumn.Text = CBColumnName; textBoxColumn.ForeColor = System.Drawing.Color.Gray; textBoxId.Clear(); if (this.ConditionChanged != null) { this.ConditionChanged(this, e); } CBValue = "ID"; textBoxId.ForeColor = System.Drawing.Color.Gray; } else { mysql query = new mysql("COUNT(" + CBIdColumn + ") as a", CBTableName, CBColumnName + " LIKE '%" + textBoxColumn.Text + "%'"); query.read(); if (query.read("a") == "1") { query.close(); query = new mysql(CBIdColumn + ", " + CBColumnName, CBTableName, CBColumnName + " LIKE '%" + textBoxColumn.Text + "%'"); query.read(); CBValue = query.read(CBIdColumn); textBoxColumn.Text = query.read(CBColumnName); query.close(); textBoxId.ForeColor = System.Drawing.Color.Black; if (this.ConditionChanged != null) { this.ConditionChanged(this, e); } } else { if (Convert.ToInt16(query.read("a")) > 1) { MessageBox.Show("Pouco específico"); } else { MessageBox.Show("Sem resultados"); } query.close(); textBoxColumn.Select(); textBoxColumn.Clear(); textBoxId.Clear(); textBoxId.ForeColor = System.Drawing.Color.Gray; CBValue = "ID"; } } } }
private void addMode() { edit = false; mysql query = new mysql("`AUTO_INCREMENT` as a", "INFORMATION_SCHEMA.TABLES", "TABLE_SCHEMA = 'biblioteca' AND TABLE_NAME = 'categorias'"); query.read(); searchId.CBValue = query.read("a").ToString(); id = Convert.ToInt16(searchId.CBValue); buttonEliminar.Visible = false; query.close(); }
private bool updateColumn() { mysql query = new mysql(CBColumnName, CBTableName, CBIdColumn + " = " + CBValue); if (query.read()) { textBoxColumn.Text = query.read(CBColumnName); query.close(); textBoxColumn.ForeColor = System.Drawing.Color.Black; return(true); } else { query.close(); MessageBox.Show("Sem resultados"); textBoxId.Select(); textBoxId.Clear(); textBoxColumn.Text = CBColumnName; textBoxColumn.ForeColor = System.Drawing.Color.Gray; return(false); } }
private void viewMode() { mysql query = new mysql("*", "categorias", "id_cate = " + id); query.read(); searchId.CBValue = query.read("id_cate").ToString(); searchCategoria.CBValue = query.read("categoria").ToString(); query.close(); edit = false; searchCategoria.CBReadOnly = true; buttonCancel.Visible = false; buttonSave.Visible = false; buttonEdit.Visible = true; buttonEliminar.Visible = false; }