예제 #1
0
        private void updateNhanVien()
        {
            string   ten, sdt, quequan, username;
            int      id, active, quyen;
            bool     gioitinh;
            DateTime ngaysinh;

            id       = int.Parse(txtMa.Text);
            ten      = txtTen.Text;
            sdt      = txtSdt.Text;
            quequan  = txtQueQuan.Text;
            username = txtUsername.Text;
            quyen    = Ham.GetIdFromCombobox(cbQuyen.SelectedItem.ToString());
            gioitinh = Ham.NamNuToTrueFalse(cbGioiTinh.SelectedItem.ToString());
            active   = checkActive.Checked ? 1 : 0;
            ngaysinh = dateTimePicker1.Value;
            string sql = "update HTUser set ten = N'" + ten + "',ngaysinh = '" + ngaysinh + "',sdt = '" + sdt + "',gioitinh = '" + gioitinh + "'" +
                         ",diachi = N'" + quequan + "',taikhoan = '" + username + "',active = " + active + ",roleId =" + quyen + " where id = " + id;

            try
            {
                cn.ExecuteNonQuery(sql);
                getDataNhanVien();
            }
            catch (Exception)
            {
                MessageBox.Show("Kiểm tra lại thông tin", "Thông báo!");
            }
        }