private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); try { if (textBox1.Text == "") { return; } string temp_text = textBox1.Text.Replace("\n", ""); StudentProfile studentProfile = General.GetProfileFromBarcode(temp_text, databasePath); label8.Text = "ID: " + studentProfile.ID.ToString(); label9.Text = "Name: " + studentProfile.name.ToString(); button4.Focus(); if (General.FindAttendanceRecord(Convert.ToInt32(label8.Text.Replace("ID:", "")), databasePath) == null) { groupBox4.Enabled = true; } else { groupBox4.Enabled = false; } } catch { MessageBox.Show("Profile not found, add user first", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Text = ""; } }
public static void AddProfileToDatabase(StudentProfile profile, string data_path) { SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + data_path); conn.Open(); SQLiteCommand cmd = new SQLiteCommand(conn); cmd.CommandText = "INSERT INTO Students VALUES (" + profile.ID + ",'" + profile.barcode + "' ,'" + profile.name + "')"; cmd.ExecuteNonQuery(); conn.Close(); }
private void button1_Click(object sender, EventArgs e) { int ID; if (!int.TryParse(addIDTextbox.Text, out ID)) { MessageBox.Show("ID must contain numbers only", "ID not a number", MessageBoxButtons.OK, MessageBoxIcon.Error); } StudentProfile studentProfile = new StudentProfile(ID, addBarcodeTextbox.Text, addNameTextbox.Text); General.AddProfileToDatabase(studentProfile, databasePath); addIDTextbox.Text = ""; addBarcodeTextbox.Text = ""; addNameTextbox.Text = ""; }
public static void AddProfileToDatabase(StudentProfile profile, string data_path) { SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + data_path); conn.Open(); SQLiteCommand cmd = new SQLiteCommand(conn); cmd.CommandText = "INSERT INTO Students VALUES (" + profile.ID + ",'" + profile.barcode + "' ,'" + profile.name + "')"; cmd.ExecuteNonQuery(); conn.Close(); }
private void button1_Click(object sender, EventArgs e) { int ID; if (!int.TryParse(addIDTextbox.Text, out ID)) MessageBox.Show("ID must contain numbers only", "ID not a number", MessageBoxButtons.OK, MessageBoxIcon.Error); StudentProfile studentProfile = new StudentProfile(ID, addBarcodeTextbox.Text, addNameTextbox.Text); General.AddProfileToDatabase(studentProfile, databasePath); addIDTextbox.Text = ""; addBarcodeTextbox.Text = ""; addNameTextbox.Text = ""; }