コード例 #1
0
        private void Btn_dpt_remove_Click(object sender, RoutedEventArgs e)
        {
            string query;

            if (dpt_field_name.Text.Equals(""))
            {
                MessageBox.Show("Please specfiy the department by name to remove.");
            }
            else
            {
                string get_dep_id = Get_Department(dpt_field_name.Text);
                if (get_dep_id.Equals("-1"))
                {
                    MessageBox.Show("Department with name: " + dpt_field_name.Text);
                }
                else
                {
                    query = "select * from employee where department_id=@Dept;";
                    if (Database.Query(query, ("@Dept", get_dep_id)).Rows.Count > 0)
                    {
                        MessageBox.Show("Cannot delete department: " + dpt_field_name.Text + ", because " + Database.Query(query).Rows.Count + " user(s) are still in that department.");
                    }