Exemple #1
0
        private void btnViewList_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmViewEmp frm2 = new frmViewEmp();

            frm2.Show();
            frm2.cmbdept.Text = "";
        }
        private void btnEnter2_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmViewEmp frm2 = new frmViewEmp();

            frm2.Show();
            // set combobox data empty
            frm2.cmbdept.Text = "";
        }
Exemple #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int x = Convert.ToInt32(txtEmpId.Text);

            if (x > 0)
            {
                var result = MessageBox.Show("Are you sure to delete?", "DELETE EMPLOYEE INFORMATION",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                switch (result)
                {
                case DialogResult.Yes:
                    SqlConnection con = new SqlConnection(conString);
                    con.Open();
                    //Query for Delete data
                    string     q   = "EXECUTE usp_DeleteEmpInfo @EmpId ='" + txtEmpId.Text.ToString() + "'";
                    SqlCommand cmd = new SqlCommand(q, con);
                    // execute command
                    cmd.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Employee ID: " + txtEmpId.Text.ToString() + "has been removed from database.",
                                    "DELETE EMPLOYEE INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Hide();
                    frmViewEmp frm2 = new frmViewEmp();
                    frm2.Show();
                    frm2.cmbdept.Text = "";
                    break;

                case DialogResult.No:
                    this.Activate();
                    break;
                }
            }
            else
            {
                MessageBox.Show("The transaction is invalid.", "VALIDATION ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }