Esempio n. 1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            btnThem.Enabled = true;
            btnSua.Enabled  = true;
            btnXoa.Enabled  = false;
            btnLuu.Enabled  = false;

            if (flag == 1)
            {
                NGUOIQUANLY ngql = db.NGUOIQUANLies.Where(p => p.IDNGUOIQUANLY == txtIDNQL.Text).FirstOrDefault();
                try
                {
                    if (ngql != null)
                    {
                        ngql.HOTEN    = txtHoTen.Text;
                        ngql.IDKHUTRO = cbbTenKhuTro.SelectedValue.ToString();
                        ngql.SDT      = txtSDT.Text;
                        ngql.CMND     = txtCMND.Text;
                        ngql.NGAYSINH = dtpNgaySinh.Value;
                        ngql.DIACHI   = txtDiaChi.Text;
                        db.SubmitChanges();
                        MessageBox.Show("Sửa đổi hoàn tất !!!");
                        LoadData();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Lỗi Rồi!!!", "[Thông Báo]");
                }
            }

            flag             = -1;
            txtIDNQL.Enabled = false;
        }
Esempio n. 2
0
        private void LoadDataToControl(int iRow)
        {
            string maNQL = dtgvDSNQL.Rows[iRow].Cells[0].Value.ToString();
            MD5    mh    = MD5.Create();

            NGUOIQUANLY nql = db.NGUOIQUANLies.OrderBy(p => p.IDNGUOIQUANLY).Where(p => p.IDNGUOIQUANLY == maNQL).FirstOrDefault();

            try
            {
                byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(nql.PASSNGQL);
                //mã hóa chuỗi đã chuyển
                byte[] hash = mh.ComputeHash(inputBytes);
                //tạo đối tượng StringBuilder (làm việc với kiểu dữ liệu lớn)
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }

                txtHoTen.Text     = nql.HOTEN;
                txtDiaChi.Text    = nql.DIACHI;
                txtCMND.Text      = nql.CMND;
                txtSDT.Text       = nql.SDT;
                txtIDNQL.Text     = nql.IDNGUOIQUANLY;
                txtPass.Text      = sb.ToString();
                dtpNgaySinh.Value = nql.NGAYSINH;
                cbbTenKhuTro.Text = nql.KHUTRO.TENKHUTRO;
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi !!!", "[Thông Báo]");
            }
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtMKM2.Text != txtMM1.Text)
            {
                MessageBox.Show("Mật Khẩu Mới Không Khớp!!!");
            }
            else
            {
                if (txtMKC.Text != matkhau)
                {
                    MessageBox.Show("Mật khẩu cũ không đúng !!!");
                }
                else
                {
                    if (flag == true)
                    {
                        CHUQUANLY chumk = db.CHUQUANLies.Where(p => p.IDCHUQUANLY == taikhoan).FirstOrDefault();

                        if (chumk != null)
                        {
                            //MD5 mh = MD5.Create();
                            ////Chuyển kiểu chuổi thành kiểu byte
                            //byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(txtMKM2.Text);
                            ////mã hóa chuỗi đã chuyển
                            //byte[] hash = mh.ComputeHash(inputBytes);
                            ////tạo đối tượng StringBuilder (làm việc với kiểu dữ liệu lớn)
                            //StringBuilder sb = new StringBuilder();
                            //for (int i = 0; i < hash.Length; i++)
                            //{
                            //    sb.Append(hash[i].ToString("X2"));
                            //}

                            chumk.PASSBOSS = txtMKM2.Text;
                        }
                        db.SubmitChanges();
                        MessageBox.Show("Update!!!");
                        this.Close();
                    }
                    else
                    {
                        //for (int i = 0; i < db.NGUOIQUANLies.ToList().Count; i++)
                        //{
                        //    string tknql = db.NGUOIQUANLies.Select(p => p.IDNGUOIQUANLY).ToList()[i].ToString().Trim();
                        //    string mknql = db.NGUOIQUANLies.Select(p => p.PASSNGQL).ToList()[i].ToString().Trim();
                        NGUOIQUANLY nql = db.NGUOIQUANLies.Where(p => p.IDNGUOIQUANLY == taikhoan).FirstOrDefault();
                        if (nql != null)
                        {
                            nql.PASSNGQL = txtMKM2.Text;
                        }
                        db.SubmitChanges();
                        MessageBox.Show("Update!!!");
                        //}
                        this.Close();
                    }
                }
            }
        }
Esempio n. 4
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            NGUOIQUANLY tt = db.NGUOIQUANLies.SingleOrDefault(p => p.IDNGUOIQUANLY == txtIDNQL.Text);

            if (tt != null)
            {
                if (MessageBox.Show("Bạn Có Chắc Chắn Xóa", "[Thông Báo]", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    db.NGUOIQUANLies.DeleteOnSubmit(tt);
                    db.SubmitChanges();
                    LoadData();
                    MessageBox.Show("Xóa Thành Công", "[Thông Báo]");
                    btnXoa.Enabled = false;
                }
            }
        }
Esempio n. 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            Random     random = new Random();
            string     s      = "";
            List <int> list   = new List <int>();

            for (int i = 0; i <= 9; i++)
            {
                list.Add(i);
            }
            //random
            for (int i = 0; i <= 4; i++)
            {
                int tmp = random.Next(list.Count);
                s += list[tmp];
            }


            if (flag == true)
            {
                CHUQUANLY chumk = db.CHUQUANLies.Where(p => p.IDCHUQUANLY == taikhoan).FirstOrDefault();

                if (chumk != null)
                {
                    chumk.PASSBOSS = s;
                }
                db.SubmitChanges();
                MessageBox.Show("Mật khẩu mới của bạn là : " + s);
            }
            else
            {
                NGUOIQUANLY nql = db.NGUOIQUANLies.Where(p => p.IDNGUOIQUANLY == taikhoan).FirstOrDefault();
                if (nql != null)
                {
                    nql.PASSNGQL = s;
                }
                db.SubmitChanges();
                MessageBox.Show("Mật khẩu mới của bạn là : " + s);
            }
        }
Esempio n. 6
0
 private void btnDangKy_Click(object sender, EventArgs e)
 {
     if (flagDangKy == false)//&&check==false)
     {
         //try
         {
             NGUOIQUANLY nql = new NGUOIQUANLY
             {
                 HOTEN         = txtHoTen.Text,
                 DIACHI        = txtDiaChi.Text,
                 IDNGUOIQUANLY = txtID.Text,
                 SDT           = txtSDT.Text,
                 PASSNGQL      = txtPass.Text,
                 CMND          = txtCMND.Text,
                 NGAYSINH      = dtNgaySinh.Value,
                 IDKHUTRO      = cbbKhuTro.SelectedValue.ToString()
             };
             if (txtID.Text == "" || txtHoTen.Text == "" || txtDiaChi.Text == "" || txtPass.Text == "" || txtCMND.Text == "" || txtSDT.Text == "")
             {
                 MessageBox.Show("Thiếu dữ liệu");
             }
             else
             {
                 db.NGUOIQUANLies.InsertOnSubmit(nql);
                 db.SubmitChanges();
                 MessageBox.Show("Thêm Thành công!!!");
                 flagtk = true;
             }
         }
         //catch (Exception)
         //{
         //    MessageBox.Show("Lỗi!!! Thêm không Thành Công");
         //}
     }
     //else if (flagDangKy == true && check == true)
     //{
     //    //try
     //    {
     //        CHUQUANLY cql = new CHUQUANLY
     //        {
     //            HOTEN = txtHoTen.Text,
     //            IDCHUQUANLY = txtID.Text,
     //            DIACHI = txtDiaChi.Text,
     //            PASSBOSS = txtPass.Text,
     //            NGAYSINH = dtNgaySinh.Value,
     //            CMND = txtCMND.Text,
     //            SDT = txtSDT.Text
     //        };
     //        if(txtID.Text == "" || txtHoTen.Text == "" || txtDiaChi.Text == "" || txtPass.Text == "" || txtCMND.Text == "" || txtSDT.Text == "")
     //        {
     //            MessageBox.Show("Thiếu Thông Tin Đăng Nhập!!!");
     //        }
     //        else
     //        {
     //            db.CHUQUANLies.InsertOnSubmit(cql);
     //            db.SubmitChanges();
     //            MessageBox.Show("Thêm Thành Công!!!");
     //        }
     //    }
     //    //catch(Exception)
     //    //{
     //    //    MessageBox.Show("Lỗi!!!");
     //    //}
     //}
 }
Esempio n. 7
0
 private void detach_NGUOIQUANLies(NGUOIQUANLY entity)
 {
     this.SendPropertyChanging();
     entity.KHUTRO = null;
 }
Esempio n. 8
0
 partial void DeleteNGUOIQUANLY(NGUOIQUANLY instance);
Esempio n. 9
0
 partial void UpdateNGUOIQUANLY(NGUOIQUANLY instance);
Esempio n. 10
0
 partial void InsertNGUOIQUANLY(NGUOIQUANLY instance);