private void BunifuFlatButton1_Click(object sender, EventArgs e) { string ext = Path.GetExtension(filepath); if (string.IsNullOrEmpty(bunifuMaterialTextbox1.Text.Trim()) && string.IsNullOrEmpty(bunifuMaterialTextbox2.Text.Trim()) && string.IsNullOrEmpty(bunifuMaterialTextbox3.Text.Trim())) { MessageBox.Show("You must provide all fields", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DBconnect dBconnect = new DBconnect(); void insert() { dBconnect.Insert($"INSERT INTO customers (CustomerName,Mobile,Address,Picture) VALUES('{bunifuMaterialTextbox1.Text}','{bunifuMaterialTextbox2.Text}','{bunifuMaterialTextbox3.Text}','{pictureBox1.Tag}')"); dBconnect.Select("SELECT * FROM customers", dataGridView1); dataGridView1.Update(); } if (pictureBox1.Image == null) { insert(); } else { File.Copy(filepath, imagesPath + bunifuMaterialTextbox2.Text + ext, true); pictureBox1.Tag = bunifuMaterialTextbox2.Text + ext; insert(); } } dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true; dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows.Count - 1; }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { DBconnect dBconnect = new DBconnect(); dBconnect.LoadTextBox("SELECT CustomerName FROM customers", textBox1); DBconnect bconnect = new DBconnect(); bconnect.LoadComboBox("SELECT id FROM customers", comboBox1); DBconnect dBcconnect = new DBconnect(); dBcconnect.Select("SELECT * FROM customers", dataGridView1); dataGridView1.Sort(dataGridView1.Columns["Mobile"], ListSortDirection.Ascending); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { DBconnect dBconnect = new DBconnect(); dBconnect.Select($"Select * FROM customers WHERE id={comboBox1.Text}", dataGridView1); }
private void textBox1_TextChanged_1(object sender, EventArgs e) { DBconnect dBconnect = new DBconnect(); dBconnect.Select($"SELECT * FROM customers WHERE CustomerName LIKE '{textBox1.Text + "%"}'", dataGridView1); }
private void button1_Click(object sender, EventArgs e) { DBconnect db = new DBconnect(); db.Select("SELECT * FROM students", dataGridView1); }