Esempio n. 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            List <PW_User> lst = new List <PW_User>();

            try
            {
                lst = dGVPeopleInfo.DataSource as List <PW_User>;
            }
            catch (Exception ex)
            {
                return;
            }
            int index = -1;

            try
            {
                index = dGVPeopleInfo.SelectedRows[0].Index;
            }
            catch
            {
                index = -1;
            }
            if (index > -1)
            {
                PW_User one = lst[index];
                if (one.USERNAME == "001")
                {
                    MessageBox.Show("不允许删除001管理员账号!");
                    return;
                }
                using (ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient())
                {
                    if (!srv.PW_User_DeleteUser(one.ID))
                    {
                        MessageBox.Show("删除失败!");
                        return;
                    }
                }
                lst.RemoveAt(index);
                dGVPeopleInfo.DataSource = null;
                dGVPeopleInfo.DataSource = lst;
                if (index > 0)
                {
                    index -= 1;
                    dGVPeopleInfo.Rows[index].Selected = true;
                }
            }
        }