Пример #1
0
        private void Btnluu_Click(object sender, EventArgs e)
        {
            Nhansu nhansu = laynhansu();
            var    row    = nhansuBUS.themsuanhansu(Id, nhansu);

            if (row > 0)
            {
                if (Role == 2 || Role == 3)
                {
                    khicapnhat();
                }


                if (Id != 0)
                {
                    MessageBox.Show("Cập nhật thành công!");
                }
                else
                {
                    MessageBox.Show("Thêm thành viên thành công!");
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("Cập nhật thất bại!");
            }
        }
Пример #2
0
        private void Btnsua_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Object id          = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
            Object tenDangNhap = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TenDangNhap");
            Object matKhau     = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MatKhau");
            Object ten         = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Ten");
            Object tmail       = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Email");
            Object ngayThamgia = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NgayThamgia");
            Object diachi      = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Diachi");
            Object idQuyen     = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "IdQuyen");
            Object gioitinh    = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Gioitinh");
            Object nganhang    = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Nganhang");
            Object sotk        = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Sotk");
            Object sodienthoai = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Sodienthoai");

            Nhansu nhansu = new Nhansu()
            {
                Id          = (int)id,
                TenDangNhap = tenDangNhap.ToString(),
                MatKhau     = nhansuDao.Laypasswork((int)id),
                Ten         = ten.ToString(),
                Email       = tmail.ToString(),
                NgayThamgia = ngayThamgia.ToString(),
                Diachi      = diachi.ToString(),
                IdQuyen     = (int)idQuyen,
                Gioitinh    = gioitinh.ToString(),
                Nganhang    = nganhang.ToString(),
                Sotk        = (long)sotk,
                Sodienthoai = (int)sodienthoai
            };
            Themsuanguoidung themsuanhansu = new Themsuanguoidung(nhansu, Idmh);

            themsuanhansu.Show();
            themsuanhansu.khicapnhat += Themsuanhansu_khicapnhat;
        }
Пример #3
0
        public Nhansu Laynhansu(string sql)
        {
            int    id       = 0;
            Nhansu roleform = new Nhansu();

            SqlConnection con        = new SqlConnection(path);
            SqlCommand    sqlCommand = new SqlCommand(sql, con);

            con.Open();
            SqlDataReader row = sqlCommand.ExecuteReader();

            if (row.HasRows)
            {
                row.Read();
                roleform.Id          = int.Parse(row[0].ToString());
                roleform.TenDangNhap = (row[1].ToString());
                roleform.MatKhau     = (row[2].ToString());
                roleform.Ten         = (row[3].ToString());
                roleform.Email       = (row[4].ToString());
                roleform.NgayThamgia = (row[5].ToString());
                roleform.Diachi      = (row[6].ToString());
                roleform.Gioitinh    = row[7].ToString();
                roleform.Nganhang    = (row[8].ToString());
                roleform.Sotk        = long.Parse(row[9].ToString());
                roleform.Sodienthoai = int.Parse(row[10].ToString());
                roleform.IdQuyen     = int.Parse(row[11].ToString());
            }


            con.Close();
            return(roleform);
        }
Пример #4
0
        public Themsuanguoidung(Nhansu nhansu, string matkhau)
        {
            InitializeComponent();
            this.Text      = "Cập nhật thông tin";
            btnluu.Text    = "Cập nhật";
            Id             = nhansu.Id;
            btnluu.Enabled = false;

            txttentk.Text           = nhansu.TenDangNhap;
            txttentk.Enabled        = false;
            txtmatkhau.Text         = matkhau;
            txtmatkhau.Enabled      = false;
            txtxnmatkhau.Text       = matkhau;
            txtxnmatkhau.Enabled    = false;
            txtdiachi.Text          = nhansu.Diachi;
            txtdiachi.Enabled       = false;
            txttennguoidung.Text    = nhansu.Ten;
            txttennguoidung.Enabled = false;
            txtemail.Text           = nhansu.Email;
            txtemail.Enabled        = false;
            txtngaythamhia.Text     = nhansu.NgayThamgia;
            txtngaythamhia.Enabled  = false;
            txtnganhang.Text        = nhansu.Nganhang;
            txtnganhang.Enabled     = false;
            txttaikhoan.Text        = nhansu.Sotk.ToString();
            txttaikhoan.Enabled     = false;
            txtsodeinthoai.Text     = nhansu.Sodienthoai.ToString();
            txtsodeinthoai.Enabled  = false;

            if (nhansu.Gioitinh == "Nam")
            {
                rdonam.Checked = true;
            }
            if (nhansu.Gioitinh == "Nữ")
            {
                rdonu.Checked = true;
            }
            if (nhansu.IdQuyen == 1)
            {
                cbbquyenhan.Text = "Người dùng";
            }
            if (nhansu.IdQuyen == 2)
            {
                cbbquyenhan.Text = "Nhân viên";
            }
            if (nhansu.IdQuyen == 3)
            {
                cbbquyenhan.Text = "Admin";
            }
            rdonam.Enabled      = false;
            rdonu.Enabled       = false;
            cbbquyenhan.Enabled = false;
            label1.Enabled      = false;
        }
Пример #5
0
        private void Btnthongtintk_ItemClick(object sender, ItemClickEventArgs e)
        {
            NhansuBUS nhansuBUS = new NhansuBUS();
            Nhansu    nhansu    = nhansuBUS.Laynhansu(Id);


            Themsuanguoidung themsuanguoidung = new Themsuanguoidung(nhansu, passwork);

            themsuanguoidung.MdiParent = this;
            themsuanguoidung.Show();
        }
Пример #6
0
        public Nhansu laynhansu()
        {
            Nhansu nhansu = new Nhansu();

            nhansu.Id = this.Id;
            int quyen = 0;

            if (cbbquyenhan.Text == "Người dùng")
            {
                quyen = 1;
            }
            if (cbbquyenhan.Text == "Nhân viên")
            {
                quyen = 2;
            }
            if (cbbquyenhan.Text == "Admin")
            {
                quyen = 3;
            }

            nhansu.IdQuyen     = quyen;
            nhansu.MatKhau     = txtmatkhau.Text;
            nhansu.Nganhang    = txtnganhang.Text;
            nhansu.NgayThamgia = txtngaythamhia.Text;
            nhansu.Sodienthoai = int.Parse(txtsodeinthoai.Text);
            nhansu.Sotk        = long.Parse(txttaikhoan.Text);
            nhansu.Ten         = txttennguoidung.Text;
            nhansu.TenDangNhap = txttentk.Text;
            nhansu.Diachi      = txtdiachi.Text;
            nhansu.Email       = txtemail.Text;
            if (rdonam.Checked == true)
            {
                nhansu.Gioitinh = "Nam";
            }
            if (rdonu.Checked == true)
            {
                nhansu.Gioitinh = "Nữ";
            }


            return(nhansu);
        }
Пример #7
0
        public int themsuanhansu(int Id, Nhansu nhansu)
        {
            string sql = "";

            if (nhansu.MatKhau != "aaaaaaaa" && Id != 0)
            {
                sql = string.Format("Update Nhansu Set TenDangNhap=N'{0}',MatKhau= N'{1}',Ten=N'{2}',Email='{3}',NgayThamgia='{4}',Diachi=N'{5}',IdQuyen='{6}',Gioitinh=N'{7}',Nganhang=N'{8}',Sotk='{9}',Sodienthoai=N'{10}' Where Id='{11}'", nhansu.TenDangNhap, nhansu.MatKhau, nhansu.Ten, nhansu.Email, nhansu.NgayThamgia, nhansu.Diachi, nhansu.IdQuyen, nhansu.Gioitinh, nhansu.Nganhang, nhansu.Sotk, nhansu.Sodienthoai, Id);
            }
            else
            if (Id != 0)
            {
                sql = string.Format("Update Nhansu Set TenDangNhap=N'{0}',Ten= N'{1}',Email='{2}',NgayThamgia='{3}',Diachi=N'{4}',IdQuyen='{5}',Gioitinh=N'{6}',Nganhang=N'{7}',Sotk='{8}',Sodienthoai='{9}' Where Id='{10}'", nhansu.TenDangNhap, nhansu.Ten, nhansu.Email, nhansu.NgayThamgia, nhansu.Diachi, nhansu.IdQuyen, nhansu.Gioitinh, nhansu.Nganhang, nhansu.Sotk, nhansu.Sodienthoai, Id);
            }
            else
            {
                sql = string.Format("Insert into Nhansu(TenDangNhap,MatKhau,Ten,Email,NgayThamgia,Diachi,IdQuyen,Gioitinh,Nganhang,Sotk,Sodienthoai) Values(N'{0}',N'{1}',N'{2}','{3}','{4}',N'{5}','{6}',N'{7}',N'{8}','{9}',N'{10}')", nhansu.TenDangNhap, nhansu.MatKhau, nhansu.Ten, nhansu.Email, nhansu.NgayThamgia, nhansu.Diachi, nhansu.IdQuyen, nhansu.Gioitinh, nhansu.Nganhang, nhansu.Sotk, nhansu.Sodienthoai);
            }
            var rs = db.thesuadulieu(sql);

            return(rs);
        }
Пример #8
0
 public Themsuanguoidung(Nhansu nhansu, int Idmh)
 {
     InitializeComponent();
     this.Text   = "Cập nhật thông tin";
     Role        = 3;
     this.IDmh   = Idmh;
     btnluu.Text = "Cập nhật";
     layoutControlItem16.ContentVisible = false;
     Id                   = nhansu.Id;
     txttentk.Text        = nhansu.TenDangNhap;
     txtmatkhau.Text      = "aaaaaaaa";
     txtxnmatkhau.Text    = "aaaaaaaa";
     txtdiachi.Text       = nhansu.Diachi;
     txttennguoidung.Text = nhansu.Ten;
     txtemail.Text        = nhansu.Email;
     txtngaythamhia.Text  = nhansu.NgayThamgia;
     txtnganhang.Text     = nhansu.Nganhang;
     txttaikhoan.Text     = nhansu.Sotk.ToString();
     txtsodeinthoai.Text  = nhansu.Sodienthoai.ToString();
     if (nhansu.IdQuyen == 1)
     {
         cbbquyenhan.Text = "Người dùng";
     }
     if (nhansu.IdQuyen == 2)
     {
         cbbquyenhan.Text = "Nhân viên";
     }
     if (nhansu.IdQuyen == 3)
     {
         cbbquyenhan.Text = "Admin";
     }
     if (nhansu.Gioitinh == "Nam")
     {
         rdonam.Checked = true;
     }
     if (nhansu.Gioitinh == "Nữ")
     {
         rdonu.Checked = true;
     }
 }
Пример #9
0
 public int themsuanhansu(int Id, Nhansu nhansu)
 {
     return(nhansuDAO.themsuanhansu(Id, nhansu));
 }