コード例 #1
0
        public void loadform()
        {
            buttonManageUser.Visible = false;
            buttonTypeUser.Visible   = false;
            buttonQuyen.Visible      = false;
            buttonPhanQuyen.Visible  = false;
            nguoiDung nguoidung = new nguoiDung();
            DataTable table     = new DataTable();

            table = nguoidung.QuyenLoaiNguoiDung(User);

            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i][3].ToString()) == 1)
                {
                    buttonManageUser.Visible = true;
                    buttonTypeUser.Visible   = true;
                    buttonQuyen.Visible      = true;
                    buttonPhanQuyen.Visible  = true;
                }
            }
            table = nguoidung.QuyenNguoiDung(User);
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i][2].ToString()) == 1)
                {
                    buttonManageUser.Visible = true;
                    buttonTypeUser.Visible   = true;
                    buttonQuyen.Visible      = true;
                    buttonPhanQuyen.Visible  = true;
                }
            }
            dataGridViewQuyenNguoiDung.DataSource     = nguoidung.QuyenNguoiDung(User);
            dataGridViewQuyenLoaiNguoiDung.DataSource = nguoidung.QuyenLoaiNguoiDung(User);
        }
コード例 #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            //try
            //{
            nguoiDung nguoidung = new nguoiDung {
                username = textBoxUserName.Text, password_moi = textBoxPassWord.Text
            };

            if (nguoidung.checkUserAndPass() == true)
            {
                string User = textBoxUserName.Text;

                MainForm main = new MainForm(User);
                main.ShowDialog();
            }
            else
            {
                MessageBox.Show("Invalid username or pass");
            }

            //catch (SqlException ex)
            //{
            //    MessageBox.Show("Lỗi SQL exception !\n" + ex.Message);
            //}
        }
コード例 #3
0
        private void frm_trangchu_Load(object sender, EventArgs e)
        {
            panel_side.Height = btn_thuoc.Height;
            panel_side.Top    = btn_thuoc.Top;
            userControl_thuoc1.BringToFront();
            label2.Text = ff.nd.Ten;

            //userControl_taikhoan1.nd = ff.nd;
            nd = ff.nd;
            userControl_taikhoan1.lb_id.Text           = ff.nd.Tendangnhap;
            userControl_taikhoan1.lb_quyentruycap.Text = ff.nd.Quyen;
            userControl_taikhoan1.txtpassword.Text     = "" + ff.nd.Matkhau;
            userControl_banhang1.txt_mnv.Text          = ff.nd.Manv;
            //  -------------------------------------------

            /*
             * List<khachHang> l = new List<khachHang>();
             * khachHang k = new khachHang();
             * khachHang k2 = new khachHang();
             * k.TenKH = "1";
             * k.MaKH = "mot";
             * l.Add(k);
             * k2.TenKH = "2";
             * k2.MaKH = "hai";
             * l.Add(k2);
             * comboBox1.DataSource = l;
             * comboBox1.DisplayMember = "Makh"; // Tên thuộc tính hiển thị
             * comboBox1.ValueMember = "TenKH"; // Giá trị mà nó nhận ví dụ chọn tên khách hàng trả về mã khách hàng
             * MessageBox.Show(comboBox1.SelectedValue.ToString());  // Lấy giá trị
             * //  -------------------------------------------
             */
        }
コード例 #4
0
 private void buttonUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (Ivaild())
         {
             nguoiDung nguoidung = new nguoiDung {
                 id = Convert.ToInt32(textBoxID.Text), ho_va_ten = textBoxName.Text, username = textBoxUser.Text, password_moi = textBoxPass.Text, loaiNguoiDung_id = Convert.ToInt32(comboBoxLoaiNguoiDung.SelectedValue)
             };
             if (nguoidung.Update())
             {
                 loadNguoiDung();
             }
             else
             {
                 MessageBox.Show("Fail");
             }
         }
         else
         {
             MessageBox.Show("Dien Du Thong Tin");
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show("Lỗi SQL exception !\n" + ex.Message);
     }
 }
コード例 #5
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBoxID.Text != string.Empty)
         {
             nguoiDung nguoidung = new nguoiDung {
                 id = Convert.ToInt32(textBoxID.Text)
             };
             if (nguoidung.delete())
             {
                 loadNguoiDung();
             }
             else
             {
                 MessageBox.Show("Fail");
             }
         }
         else
         {
             MessageBox.Show("Dien Du Thong Tin");
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show("Lỗi SQL exception !\n" + ex.Message);
     }
 }
コード例 #6
0
        public nguoiDung getData(string id)
        {
            openC();
            DataTable  tb  = new DataTable();
            nguoiDung  nd  = new nguoiDung();
            SqlCommand cmd = new SqlCommand("sp_checklogin_nguoidung", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@id", id));
            //SqlDataReader dr = cmd.ExecuteReader();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(tb);

            if (tb.Rows.Count == 0)
            {
                nd.Ten   = "Admin";
                nd.Quyen = "1";
                return(nd);
            }
            //    nd.Manv = tb.Rows[0]["manv"].ToString();

            nd.Ten         = tb.Rows[0]["tennv"].ToString();
            nd.Tendangnhap = tb.Rows[0]["id"].ToString();
            nd.Quyen       = tb.Rows[0]["quyentruycap"].ToString();
            nd.Manv        = tb.Rows[0]["manv"].ToString();
            closeC();
            return(nd);
        }
コード例 #7
0
        public void changePass(string id, string pass)
        {
            openC();
            DataTable  tb  = new DataTable();
            nguoiDung  nd  = new nguoiDung();
            SqlCommand cmd = new SqlCommand("sp_checklogin_changepass", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@user", id));
            cmd.Parameters.Add(new SqlParameter("@pass", pass));
            cmd.ExecuteNonQuery();

            closeC();
        }
コード例 #8
0
 public void loadNguoiDung()
 {
     try
     {
         nguoiDung     nguoidung     = new nguoiDung();
         loaiNguoiDung loainguoidung = new loaiNguoiDung();
         dataGridViewNguoiDung.DataSource    = nguoidung.ShowtableNguoiDung();
         comboBoxLoaiNguoiDung.DataSource    = loainguoidung.ShowtableNguoiDung();
         comboBoxLoaiNguoiDung.ValueMember   = "id";
         comboBoxLoaiNguoiDung.DisplayMember = "tenLoaiNguoiDung";
     }
     catch (SqlException ex)
     {
         MessageBox.Show("Lỗi SQL exception !\n" + ex.Message);
     }
 }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            int kq = nv.dangNhap(txtid.Text, txtpassword.Text);

            if (kq == 0)
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
            }
            else
            {
                // thuoc f = new thuoc();

                //nd.quyen =
                frm_trangchu f = new frm_trangchu(this);
                nd         = data.getData(txtid.Text);
                nd.Matkhau = txtpassword.Text;
                this.Hide();
                f.ShowDialog();
            }
        }
コード例 #10
0
        async private void Btn_Dangnhap_Click(object sender, RoutedEventArgs e)
        {
            username = Txtbox_Username.Text.ToString();
            password = Passwdbox_Password.Password.ToString();
            if (username == "")
            {
                await(new MessageDialog("Vui lòng nhập tên người dùng", "Thông báo").ShowAsync());
                return;
            }
            if (password == "")
            {
                await(new MessageDialog("Vui lòng nhập mật khẩu", "Thông báo").ShowAsync());
                return;
            }
            ws = new kidmathwebserviceSoapClient();
            List <nguoiDung> listnguoidung = new List <nguoiDung>();

            listnguoidung = ws.getDataNguoiDungAsync().Result.Body.getDataNguoiDungResult.ToList <nguoiDung>();
            nguoiDung sessionuser = listnguoidung.Find(user => user.username == username && user.password == password);

            if (sessionuser == null)
            {
                await(new MessageDialog("Tên tài khoản hoặc mật khẩu không chính xác", "Error").ShowAsync());
            }
            else
            {
                UserSession.userlogined = sessionuser;
                if (sessionuser.kieuThanhVien == "B")
                {
                    var msg = new MessageDialog("Tài khoản của bạn đã bị khóa, liên hệ [email protected] để được hỗ trợ", "Error").ShowAsync();
                }
                if (sessionuser.kieuThanhVien == "A")
                {
                    this.Frame.Navigate(typeof(AdminMainPage));
                }
                if (sessionuser.kieuThanhVien == "U")
                {
                    this.Frame.Navigate(typeof(MainPage_AffterLogin));
                }
            }
        }
コード例 #11
0
        public void loadcombox()
        {
            loaiNguoiDung loainguoidung = new loaiNguoiDung();
            nguoiDung     nguoidung     = new nguoiDung();
            quyen         q             = new quyen();
            quyen         Quyen         = new quyen();

            comboBoxLoaiNguoiDung.DataSource    = loainguoidung.ShowtableNguoiDung();
            comboBoxLoaiNguoiDung.DisplayMember = "tenLoaiNguoiDung";
            comboBoxLoaiNguoiDung.ValueMember   = "id";

            comboBoxNhomQuyen.DataSource    = q.ShowtableQuyen();
            comboBoxNhomQuyen.DisplayMember = "tenQuyen";
            comboBoxNhomQuyen.ValueMember   = "id";

            comboBoxUser.DataSource    = nguoidung.ShowtableNguoiDung();
            comboBoxUser.DisplayMember = "username";
            comboBoxUser.ValueMember   = "id";

            comboBoxQuyen.DataSource    = Quyen.ShowtableQuyen();
            comboBoxQuyen.DisplayMember = "tenQuyen";
            comboBoxQuyen.ValueMember   = "id";
        }
コード例 #12
0
        private async void khoanguoidung_mokhoaclick(object sender, RoutedEventArgs e)
        {
            Button    userstatus = sender as Button;
            nguoiDung tempuser   = userstatus.DataContext as nguoiDung;

            if (tempuser.kieuThanhVien == "Bình thường")
            {
                userstatus.Content = "Bình thường";
                var msg = new MessageDialog("Bạn muốn khóa tài khoản này ?");
                msg.Commands.Add(new UICommand()
                {
                    Id = 0, Label = "Xác nhận khóa"
                });
                msg.Commands.Add(new UICommand()
                {
                    Id = 1, Label = "Hủy"
                });
                var rs = await msg.ShowAsync();

                if ((int)rs.Id == 0)
                {
                    ws = new kidmathwebserviceSoapClient();
                    string sql_khoatk = "UPDATE nguoiDung SET nguoiDung.kieuThanhVien ='B' WHERE nguoiDung.username ='******';";
                    if (ws.ThucHienLenhAsync(sql_khoatk).Result.Body.ThucHienLenhResult != 0)
                    {
                        userstatus.Content = "Bị khóa";
                        var msg_ = new MessageDialog("Đã khóa tài khoản").ShowAsync();
                    }
                    else
                    {
                        var msg_2 = new MessageDialog("Xảy ra lỗi").ShowAsync();
                    }
                }
            }
            else if (tempuser.kieuThanhVien == "Bị khóa")
            {
                userstatus.Content = "Bị khóa";
                var msg = new MessageDialog("Bạn muốn mở khóa tài khoản này ?");
                msg.Commands.Add(new UICommand()
                {
                    Id = 0, Label = "Xác nhận mở khóa"
                });
                msg.Commands.Add(new UICommand()
                {
                    Id = 1, Label = "Hủy"
                });
                var rs = await msg.ShowAsync();

                if ((int)rs.Id == 0)
                {
                    ws = new kidmathwebserviceSoapClient();
                    string sql_khoatk = "UPDATE nguoiDung SET nguoiDung.kieuThanhVien ='U' WHERE nguoiDung.username ='******';";
                    if (ws.ThucHienLenhAsync(sql_khoatk).Result.Body.ThucHienLenhResult != 0)
                    {
                        userstatus.Content = "Bình thường";
                        var msg_ = new MessageDialog("Đã mở khóa tài khoản").ShowAsync();
                    }
                    else
                    {
                        var msg_2 = new MessageDialog("Xảy ra lỗi").ShowAsync();
                    }
                }
            }
        }