Example #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            dbClass   db     = new dbClass();
            DataTable jb     = db.dbSelect("SELECT id from tb_job WHERE description='" + cmbJob.Text + "'");
            DataTable dp     = db.dbSelect("SELECT id from tb_department WHERE code='" + cmbDept.Text + "'");
            DataTable parent = db.dbSelect("SELECT id from tb_department WHERE code='" + cmbParent.Text + "'");

            if (this.activeForm == "Information")
            {
                db.dbUpdate("UPDATE tb_info SET lastname='" + txtLN.Text + "', firstname='" + txtFN.Text + "', middlename='" + txtMN.Text + "', address='" + txtAdd.Text + "', birthdate='" + pickBday.Text + "', birthplace='" + txtBPlace.Text + "', contact='" + txtContact.Text + "', department=" + dp.Rows[0][0].ToString() + ", job=" + jb.Rows[0][0].ToString() + " WHERE id=" + this.activeID);
            }
            if (this.activeForm == "Department")
            {
                db.dbUpdate("UPDATE tb_department SET code='" + txtCode.Text + "', description='" + txtDesc.Text + "' WHERE id=" + this.activeID);
            }
            if (this.activeForm == "Job")
            {
                db.dbUpdate("UPDATE tb_job SET description='" + txtJob.Text + "', parent=" + parent.Rows[0][0] + ", salary=" + txtSalary.Text + " WHERE id=" + this.activeID);
            }
            Main main = new Main();

            this.Hide();
            main.Show();
            MessageBox.Show("Updated!");
        }