private void btnNew_Click(object sender, EventArgs e) { ServerConnection server = new ServerConnection(); if (btnNew.Text == "New") { btnNew.Text = "Add"; btnUpdate.Enabled = false; txtID.Text = ""; txtUser.Text = ""; txtFullname.Text = ""; txtAccount.Text = ""; txtPassword.Text = ""; txtAnswer.Text = ""; txtID.Enabled = true; } else { if (txtID.Text == "" || txtUser.Text == "" || txtFullname.Text == "") { return; } DialogResult Add = MessageBox.Show("Add this User Data ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Add == DialogResult.No) { return; } try { string sqlAdd = "insert into acnt_usr(usr_id,usr_name,usr_password,usr_rspnsblty,usr_fullname)values" + "('" + txtID.Text + "','" + txtUser.Text + "','" + txtPassword.Text + "','" + txtAccount.Text + "','" + txtFullname.Text + "')"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); server.CloseConnection(); string sqlAdd1 = "insert into usr_scrty_qustn(user_id, usr_question, usr_answer)values" + "('" + txtID.Text + "','" + txtQuestion.Text + "','" + txtAnswer.Text + "')"; server.Connection(); MySqlCommand cmd1 = new MySqlCommand(sqlAdd1, server.con); MySqlDataReader read1; server.OpenConnection(); read1 = cmd1.ExecuteReader(); server.CloseConnection(); MessageBox.Show("New User Added", "", MessageBoxButtons.OK, MessageBoxIcon.Information); ReFresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } } }
private void button3_Click(object sender, EventArgs e) { DialogResult Delete = MessageBox.Show("Do you want to REMOVE this Account Level ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Delete == DialogResult.No) { return; } ServerConnection server = new ServerConnection(); int ctrUsed = 0; try { string sqlAdd = "select * from acnt_usr where usr_rspnsblty = '" + txtAccountCode.Text + "'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); if (read.Read()) { ctrUsed++; } server.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); return; } if (ctrUsed > 0) { MessageBox.Show("There is someone using this Account Level.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { string sqlAdd = "delete from acnt_rspnsblty where acnt_desc = '" + txtAccountDesc.Text + "' or acnt_code = '" + txtAccountCode.Text + "'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); server.CloseConnection(); MessageBox.Show("Deleting Account Level Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information); ReFresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { int ctr = 0; try { string sqlAdd = "select * from usr_scrty_qustn where user_id = '" + textBox1.Text + "'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); while (read.Read()) { label3.Text = read["usr_question"].ToString(); UserAnswer = read["usr_answer"].ToString(); Password = read["usr_password"].ToString(); ctr++; } server.CloseConnection(); if (ctr <= 0) { MessageBox.Show("Account number is invalid or not existing", "Contact Administrator or POS Provider", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } }
private void button5_Click(object sender, EventArgs e) { ServerConnection server = new ServerConnection(); if (txtAccountCode.Text != "" && txtAccountDesc.Text != "") { DialogResult Add = MessageBox.Show("Add this Account Level ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Add == DialogResult.No) { return; } try { string sqlAdd = "update acnt_rspnsblty set acnt_desc = '" + txtAccountDesc.Text + "', acnt_code = '" + txtAccountCode.Text + "'" + "where acnt_desc = '" + txtAccountDesc.Text + "' or acnt_code = '" + txtAccountCode.Text + "'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); server.CloseConnection(); MessageBox.Show("Updating Account Level Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information); ReFresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } } }
private void btnUpdate_Click(object sender, EventArgs e) { DialogResult Update = MessageBox.Show("Do you want to Update this User ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Update == DialogResult.No) { return; } ServerConnection server = new ServerConnection(); try { string sqlAdd = "update acnt_usr set usr_name = '" + txtUser.Text + "', usr_password = '******', " + "usr_rspnsblty = '" + txtAccount.Text + "', usr_fullname = '" + txtFullname.Text + "' where usr_id = '" + txtID.Text + "'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); server.CloseConnection(); string sqlAdd1 = "update usr_scrty_qustn set usr_question = '" + txtQuestion.Text + "', usr_answer = '" + txtAnswer.Text + "' where usr_id = '" + txtID.Text + "'"; server.Connection(); MySqlCommand cmd1 = new MySqlCommand(sqlAdd1, server.con); MySqlDataReader read1; server.OpenConnection(); read1 = cmd1.ExecuteReader(); server.CloseConnection(); MessageBox.Show("Updating Data Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information); ReFresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } }
private void btnRemove_Click(object sender, EventArgs e) { txtID.Enabled = false; DialogResult Delete = MessageBox.Show("Do you want to REMOVE this person ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Delete == DialogResult.No) { return; } ServerConnection server = new ServerConnection(); try { string sqlAdd = "delete from acnt_usr where usr_id = '" + txtID.Text + "'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); server.CloseConnection(); string sqlAdd1 = "delete from usr_scrty_qustn where usr_id = '" + txtID.Text + "'"; server.Connection(); MySqlCommand cmd1 = new MySqlCommand(sqlAdd1, server.con); MySqlDataReader read1; server.OpenConnection(); read1 = cmd1.ExecuteReader(); server.CloseConnection(); MessageBox.Show("Deleting Data Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information); ReFresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } }
private void button6_Click(object sender, EventArgs e) { ServerConnection server = new ServerConnection(); if (button6.Text == "New") { button6.Text = "Add"; txtAccountCode.Text = ""; txtAccountDesc.Text = ""; button5.Enabled = false; } else { if (txtAccountCode.Text != "" && txtAccountDesc.Text != "") { DialogResult Add = MessageBox.Show("Add this Account Level ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Add == DialogResult.No) { return; } try { string sqlAdd = "insert into acnt_rspnsblty(acnt_code,acnt_desc)values" + "('" + txtAccountCode.Text + "','" + txtAccountDesc.Text + "')"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); server.CloseConnection(); MessageBox.Show("New Account Level Added", "", MessageBoxButtons.OK, MessageBoxIcon.Information); ReFresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); server.CloseConnection(); } } } }
private void button1_Click(object sender, EventArgs e) { ServerConnection server = new ServerConnection(); if (checkBox1.Checked) { if (txtUsername.Text == DefaultUser && txtPassword.Text == DefaultPassword) { DefaultUserAccess = true; Responsibility = "Admin"; FullName = "Dashboard - Default User Account"; this.Hide(); Form1 Dashboard = new Form1(); DialogResult LoginSuccess = Dashboard.ShowDialog(); if (LoginSuccess == DialogResult.OK) { this.Show(); txtUsername.Text = ""; txtPassword.Text = ""; checkBox1.Checked = false; } return; } else { MessageBox.Show("Invalid Default User", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { DefaultUserAccess = false; try { string sqlAdd = "SELECT * FROM acnt_usr where usr_name = '" + txtUsername.Text + "' and usr_password = '******'"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); if (read.Read()) { Responsibility = read["usr_rspnsblty"].ToString(); FullName = "Dashboard - " + read["usr_fullname"].ToString(); this.Hide(); Form1 Dashboard = new Form1(); DialogResult LoginSuccess = Dashboard.ShowDialog(); if (LoginSuccess == DialogResult.OK) { this.Show(); txtPassword.Text = ""; } } else { MessageBox.Show("Invalid Username or Password", "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void ReFresh() { txtID.Text = ""; txtUser.Text = ""; txtFullname.Text = ""; txtAccount.Text = ""; txtPassword.Text = ""; btnUpdate.Enabled = true; txtID.Enabled = true; button6.Text = "New"; txtAccountCode.Text = ""; txtAccountDesc.Text = ""; button5.Enabled = true; ServerConnection server = new ServerConnection(); listView1.Items.Clear(); listView2.Items.Clear(); txtAccount.Items.Clear(); #region Get the Acnt User try { string sqlAdd = "select * from acnt_usr a join usr_scrty_qustn b on a.usr_id = b.user_id order by a.usr_id;"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); while (read.Read()) { ListViewItem item = new ListViewItem(read["usr_id"].ToString()); item.SubItems.Add(read["usr_name"].ToString()); item.SubItems.Add(read["usr_fullname"].ToString()); item.SubItems.Add(read["usr_rspnsblty"].ToString()); item.SubItems.Add(read["usr_password"].ToString()); item.SubItems.Add(read["usr_question"].ToString()); item.SubItems.Add(read["usr_answer"].ToString()); listView1.Items.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion #region Get The Acnt Responsibility try { string sqlAdd = "SELECT * FROM acnt_rspnsblty"; server.Connection(); MySqlCommand cmd = new MySqlCommand(sqlAdd, server.con); MySqlDataReader read; server.OpenConnection(); read = cmd.ExecuteReader(); while (read.Read()) { txtAccount.Items.Add(read["acnt_code"].ToString()); ListViewItem item = new ListViewItem(read["acnt_code"].ToString()); item.SubItems.Add(read["acnt_desc"].ToString()); listView2.Items.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion }