Beispiel #1
0
        private void buttonViewEmp_Click(object sender, EventArgs e)
        {
            this.Visible  = false;
            ShowInTaskbar = false;


            FormViewEmp viewEmp = new FormViewEmp();

            viewEmp.Show();
        }
Beispiel #2
0
        private void buttonEmpDel_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=EMMANUELSAL\EMAN_SQL;Initial Catalog=POS1;Integrated Security=True");


            if (comboBoxLast.Text == "")
            {
                MessageBox.Show("Nothing Found!");
                return;
            }



            else
            {
                if (MessageBox.Show("Are you sure to delete " + comboBoxLast.Text + " record?",
                                    "",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Information) == DialogResult.Yes)

                {
                    con.Open();
                    SqlCommand cmd = con.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "Delete from addEmp2 where EmployeeId = '" + comboBoxLast.Text + "'";


                    cmd.ExecuteNonQuery();
                    con.Close();

                    MessageBox.Show("Deleted!");
                    comboBoxLast.Text = string.Empty;
                    DisplayData();
                    FormViewEmp view = new FormViewEmp();
                    this.Visible  = false;
                    ShowInTaskbar = false;
                    view.Show();
                }
                else
                {
                    return;
                }
            }
        }