Exemplo n.º 1
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            DataTable dt = new TaiKhoanBLL().TimKiem(txtTaiKhoan.Text.Trim(), txtMatKhau.Text.Trim());

            try
            {
                if (txtTaiKhoan.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Bạn chưa nhập tài khoản", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (txtMatKhau.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Bạn chưa nhập mật khẩu", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Đăng nhập thành công");
                    string taikhoan = dt.Rows[0][0].ToString();
                    new frmMenu(taikhoan).Show();
                    Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < txtSDT.Text.Length; i++)
                {
                    if (((int)txtSDT.Text[i] < 48 && (int)txtSDT.Text[i] != 32) || (int)txtSDT.Text[i] > 57)
                    {
                        MessageBox.Show("Vui lòng kiểm tra lại số điện thoại", "Thông báo", MessageBoxButtons.OK);
                        return;
                    }
                }

                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.DiaChi      = txtDiaChi.Text;
                taiKhoan.Email       = txtEmail.Text;
                taiKhoan.HoTen       = txtHoTen.Text;
                taiKhoan.SDT         = txtSDT.Text;
                taiKhoan.TenDangNhap = tenDangNhap;

                TaiKhoanBLL.CapNhatTaiKhoanNhanVien(taiKhoan);
                MessageBox.Show("Thay đổi thông tin tài khoản nhân viên thành công!", "Thông báo");
                LoadDataGridView();
            }
            catch {; }
        }
Exemplo n.º 3
0
    //private void showProvince()
    //{
    //    ddlProvince.Items.Clear();
    //    ddlProvince.Items.Add(new ListItem(".:Chọn Tỉnh/Thành Phố:.", "0"));
    //    SqlDataAdapter ad = new SqlDataAdapter("Select * from Province", conn);
    //    DataTable dt = new DataTable();
    //    ad.Fill(dt);
    //    if (dt.Rows.Count > 0)
    //    {
    //        for (int i = 0; i < dt.Rows.Count; i++)
    //        {
    //            ddlProvince.Items.Add(new ListItem(dt.Rows[i]["ProvinceName"].ToString(), dt.Rows[i]["ProvinceID"].ToString()));
    //        }
    //    }
    //}
    //private void showDistrict()
    //{
    //    ddlDistrict.Items.Clear();
    //    ddlDistrict.Items.Add(new ListItem(".:Chọn Quận/Huyện:.", "0"));
    //    SqlDataAdapter ad = new SqlDataAdapter("Select * from District where ProvinceID = " + ddlProvince.SelectedValue, conn);
    //    DataTable dt = new DataTable();
    //    ad.Fill(dt);
    //    if (dt.Rows.Count > 0)
    //    {
    //        for (int i = 0; i < dt.Rows.Count; i++)
    //        {
    //            ddlDistrict.Items.Add(new ListItem(dt.Rows[i]["DistrictName"].ToString(), dt.Rows[i]["DistrictID"].ToString()));
    //        }
    //    }
    //}
    //private void showWard()
    //{
    //    ddlWard.Items.Clear();
    //    ddlWard.Items.Add(new ListItem(".:Chọn Phường/Xã:.", "0"));
    //    SqlDataAdapter ad = new SqlDataAdapter("Select * from Ward where DistrictID = " + ddlDistrict.SelectedValue, conn);
    //    DataTable dt = new DataTable();
    //    ad.Fill(dt);
    //    if (dt.Rows.Count > 0)
    //    {
    //        for (int i = 0; i < dt.Rows.Count; i++)
    //        {
    //            ddlWard.Items.Add(new ListItem(dt.Rows[i]["WardName"].ToString(), dt.Rows[i]["WardID"].ToString()));
    //        }
    //    }
    //}
    protected void btnDoiMK_Click(object sender, EventArgs e)
    {
        //Thay đổi mật khẩu
        TaiKhoanBLL tb = new TaiKhoanBLL();

        if (tb.dangNhap(Session["Username"].ToString(), txtMKCu.Text))
        {
            conn.Open();
            SqlCommand     cmd = new SqlCommand("update TaiKhoan set Pass=@Pass where Username=@Username", conn);//update
            SqlParameter[] par = new SqlParameter[] {
                new SqlParameter("@Username", SqlDbType.NVarChar),
                new SqlParameter("@Pass", SqlDbType.NVarChar)
            };
            par[0].Value = Session["Username"].ToString();
            par[1].Value = txtMKMoi.Text;
            cmd.Parameters.AddRange(par);
            int i = cmd.ExecuteNonQuery();
            if (i > 0)
            {
                lblThongBao.Visible = true;
                lblThongBao.Text    = "Mật khẩu đã được thay đổi thành công.";
            }
            else
            {
                lblThongBao.Visible = true;
                lblThongBao.Text    = "Mật khẩu đã được thay đổi thành công.";
            }
        }
        else
        {
            lblThongBao.Visible = true;
            lblThongBao.Text    = "Mật khẩu cũ chưa đúng.";
        }
    }
Exemplo n.º 4
0
    protected void btnCapNhat_Click(object sender, EventArgs e)
    {
        //cập nhật theo thông tin
        TaiKhoanInfo ti = new TaiKhoanInfo();

        ti.HoTen = txtHoTen.Text;
        //ti.Province = ddlProvince.SelectedValue;
        //ti.District = ddlDistrict.SelectedValue;
        //ti.Ward = ddlWard.SelectedValue;
        ti.DiaChi   = txtDiaChi.Text;
        ti.SDT      = txtSDT.Text;
        ti.Email    = txtEmail.Text;
        ti.Username = Session["Username"].ToString();
        TaiKhoanBLL tb = new TaiKhoanBLL();

        if (tb.updateUser(ti))
        {
            lblThongBao2.Visible = true;
            lblThongBao2.Text    = "Cập nhật thông tin thành công."; // giá trị trả về đúng thì update thành công
            loadInfo();
        }
        else
        {
            lblThongBao2.Visible = true;
            lblThongBao2.Text    = "Lỗi.";//ngược lại thì lỗi
        }
    }
Exemplo n.º 5
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (string.Equals(txtMatKhauHienThoi.Text, TaiKhoanBLL.MatKhauCu(taiKhoan).Trim()))
            {
                if (txtMatKhauMoi.Text.Length >= 4 && txtMatKhauMoi.Text.Length <= 20)
                {
                    if (string.Equals(txtMatKhauMoi.Text, txtNhapLaiMKMoi.Text))
                    {
                        try
                        {
                            TaiKhoanBLL.ThayDoiMatKhau(taiKhoan, txtMatKhauMoi.Text);
                            MessageBox.Show("Thay đổi mật khẩu thành công", "Thông Báo", MessageBoxButtons.OK);
                        }
                        catch {; }
                    }
                    else
                    {
                        MessageBox.Show("Mật khẩu không trùng khớp.\nXin nhập lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtMatKhauMoi.Clear();
                        txtNhapLaiMKMoi.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Mật khẩu phải từ 4-20 kí tự", "Lỗi", MessageBoxButtons.OK);
                    txtMatKhauMoi.Clear();
                    txtNhapLaiMKMoi.Clear();
                }
            }

            else
            {
                MessageBox.Show("Mật khẩu hiện thời không đúng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public Form_QL_QuanLyNhanVien()
 {
     InitializeComponent();
     db    = new QLCFDataContext();
     nvbll = new NhanVienBLL();
     tkbll = new TaiKhoanBLL();
 }
Exemplo n.º 7
0
 private void Init()
 {
     txtMaPhieu.Text       = PhieuTiepNhanBLL.GenMaPhieu().ToString();
     txtMaHocSinh.Text     = TreBLL.GenMaTre().ToString();
     txtNgayTiepNhan.Text  = DateTime.Now.ToShortDateString();
     txtNguoiTiepNhan.Text = TaiKhoanBLL.GetTenNguoiDung(username);
 }
Exemplo n.º 8
0
 public FormDoiMatKhau()
 {
     tkBLL = new TaiKhoanBLL();
     dsTK  = new List <eTaiKhoan>();
     dsTK  = tkBLL.LayThongTinTaiKhoan();
     InitializeComponent();
 }
    void load()
    {
        TaiKhoanBLL tb  = new TaiKhoanBLL();
        ArrayList   lst = new ArrayList();

        lst = (ArrayList)tb.showUserinfo();
        GridView1.DataSource = lst;
        GridView1.DataBind();
    }
Exemplo n.º 10
0
 private void frmThuHocPhi_Load(object sender, EventArgs e)
 {
     InitDataGridView();
     LoadListNamHoc();
     LoadListLoaiLop();
     LoadDataGirdView();
     lbNgayThu.Text       = DateTime.Now.ToString("dd/MM/yyyy");
     txtNguoiThuTien.Text = TaiKhoanBLL.GetTenNguoiDung(username);
 }
Exemplo n.º 11
0
 private void btnXoaTaiKhoan_Click(object sender, EventArgs e)
 {
     try
     {
         TaiKhoanBLL.XoaTaiKhoan(tenDangNhap);
         MessageBox.Show("Xóa tài khoản thành công!", "Thông báo", MessageBoxButtons.OK);
         LoadDataGridView();
     }
     catch {; }
 }
Exemplo n.º 12
0
        void LoadDataGridView()
        {
            dgvDanhSachTaiKhoan.DataSource = TaiKhoanBLL.GetTaiKhoan();
            string[] columns = { "TENDANGNHAP", "HOTEN", "SDT" };
            Utility.ControlFormat.DataGridViewFormat(dgvDanhSachTaiKhoan, columns);

            dgvDanhSachTaiKhoan.Columns[0].HeaderText = "Tài khoản";
            dgvDanhSachTaiKhoan.Columns[1].HeaderText = "Họ tên";
            dgvDanhSachTaiKhoan.Columns[2].HeaderText = "SĐT";
        }
Exemplo n.º 13
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        // xóa tài khoản
        int         MaUser = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
        TaiKhoanBLL tb     = new TaiKhoanBLL();

        tb.xoaUser(MaUser);
        load();
        string scr = "<script>alert('Xóa thành công.')</script>";

        Page.ClientScript.RegisterStartupScript(Page.GetType(), "Thông báo", scr);
    }
Exemplo n.º 14
0
        public void Reset()
        {
            txtMaDDH.ResetText();

            txtNCC.Properties.DataSource    = nccBLL.LayDanhSach();
            txtNCC.Properties.DisplayMember = "Ten";
            txtNCC.Properties.ValueMember   = "MaNCC";

            txtNhanVien.Text = TaiKhoanBLL.TaiKhoanDaDangNhap().NhanVien.Ten;
            dtpNgayThem.ResetText();

            gridControl2.DataSource = null;
        }
Exemplo n.º 15
0
 public Form_TPB_QuanLyNhanVien()
 {
     InitializeComponent();
     pbbll = new PhongBanBLL();
     nvbll = new NhanVienBLL();
     tkbll = new TaiKhoanBLL();
     pcbll = new PhanCongBLL();
     db    = new QLLD_DBDataContext();
     ckn   = new ChuoiKetNoi();
     dataGridView1.Columns[2].DefaultCellStyle.Format = "dd/MM/yyyy";
     cbbTK_NV.Text     = "Theo Tên NV";
     _trangThaiTimKiem = "L";
 }
Exemplo n.º 16
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            var TenDangNhap = txtTenDangNhap.Text;
            var MatKhau     = txtMatKhau.Text;

            if (!TaiKhoanBLL.DangNhap(TenDangNhap, MatKhau))
            {
                MessageBox.Show("Tên tài khoản hoặc mật khẩu không đúng.\nVui lòng thử lại.", "Lỗi");
                return;
            }

            this.Close();
            var t = new Thread(() => new frmMain().ShowDialog());

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }
Exemplo n.º 17
0
 public FormDangNhap()
 {
     InitializeComponent();
     myList = new List <int>();
     dsQL   = new List <eQuanLy>();
     qlBLL  = new QuanLyBLL();
     dsTK   = new List <eTaiKhoan>();
     tkBLL  = new TaiKhoanBLL();
     dsBS   = new List <eBacSi>();
     bsBLL  = new BacSiBLL();
     nvBLL  = new NhanVienBLL();
     dsNV   = new List <eNhanVien>();
     //dsQL = qlBLL.layThongTinQuanLy();
     //dsNV = nvBLL.LayThongTinNhanVien();
     //dsTK = tkBLL.layThongTinTaiKhoan();
     //dsBS = bsBLL.LayThongTinBacSi();
     txtMatKhau.PasswordChar = '*';
 }
Exemplo n.º 18
0
        private void btnDangnhap_Click(object sender, EventArgs e)
        {
            TaiKhoanBLL tkbll   = new TaiKhoanBLL();
            string      tentk   = txbTendangnhap.Text;
            string      matkhau = txbMatkhau.Text;

            if (tkbll.TaiKhoan(tentk, matkhau))
            {
                TaiKhoan Dangnhaptaikhoan = tkbll.LaytaikhautheoTendn(tentk);
                fMain    fchinh           = new fMain(Dangnhaptaikhoan);
                this.Hide();
                fchinh.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("Đăng nhập không thành công!");
            }
        }
Exemplo n.º 19
0
        private void btnXong_Click(object sender, EventArgs e)
        {
            try
            {
                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.DiaChi      = txtDiaChi.Text;
                taiKhoan.Email       = txtEmail.Text;
                taiKhoan.HoTen       = txtHoTen.Text;
                taiKhoan.SDT         = txtSDT.Text;
                taiKhoan.TenDangNhap = tenDangNhap;
                taiKhoan.Quyen       = quyen;
                taiKhoan.MatKhau     = matKhau;

                TaiKhoanBLL.ThayDoiThongTinTaiKhoan(taiKhoan);
                MessageBox.Show("Thay đổi thông tin tài khoản thành công!", "Thông báo");
                this.Close();
            }
            catch {; }
        }
Exemplo n.º 20
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            // Kiem tra dang nhap
            if (!TaiKhoanBLL.DaDangNhap())
            {
                this.Close();
                new Thread(() => new frmLogin().ShowDialog()).Start();
                return;
            }

            _tk = TaiKhoanBLL.TaiKhoanDaDangNhap();
            _nv = _tk.NhanVien;
            _dn = DateTime.Now;

            txtTenNhanVien.Caption = "Nhân viên: " + _nv.Ten;
            txtQuyen.Caption       = "Vai trò: " + _tk.PhanQuyen.Ten;

            // Mo san form
            btnDanhSachDDH.PerformClick();
        }
Exemplo n.º 21
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            TaiKhoanBLL taikhoanbll = new TaiKhoanBLL();
            int         kq          = taikhoanbll.KiemTraDangNhap(txtid.Text, txtpass.Text);

            if (kq == 0)
            {
                MessageBox.Show("Sai ID hoặc Password !", "Thông báo");
            }
            else
            {
                Visible       = false;
                ShowInTaskbar = false;
                // show form Main
                FormMain frmnew = new FormMain();
                frmnew._message = txtid.Text;

                frmnew.ShowDialog();
            }
        }
Exemplo n.º 22
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        TaiKhoanBLL tk = new TaiKhoanBLL();

        if (tk.dangNhap(txtUsername.Text, txtPass.Text))
        {
            Session["Username"] = txtUsername.Text;
            Session["Quyen"]    = tk.layQuyen(txtUsername.Text);
            if (Request.QueryString["id"] != null)
            {
                Response.Redirect(Request.Url.AbsolutePath.ToString() + "?id=" + Request.QueryString["id"].ToString());
            }
            else
            {
                Response.Redirect(Request.Url.AbsolutePath.ToString() + "?mess=log-done");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "Thông báo", "<script>alert('Tài khoản hoặc mật khẩu chưa đúng!')</script>");
        }
    }
Exemplo n.º 23
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     // cấp quyền người dùng và admin
     if (e.CommandName == "CapQuyen")
     {
         foreach (GridViewRow r in GridView1.Rows)
         {
             if (GridView1.DataKeys[r.DataItemIndex].Value.ToString() == e.CommandArgument.ToString())
             {
                 DropDownList ddl     = (DropDownList)r.Cells[6].FindControl("ddlQuyen");
                 int          MaQuyen = int.Parse(ddl.SelectedValue.ToString());
                 TaiKhoanBLL  tb      = new TaiKhoanBLL();
                 int          MaUser  = int.Parse(e.CommandArgument.ToString());
                 tb.capQuyen(MaUser, MaQuyen);                                   //quyền theo mã
                 load();
                 Session["Quyen"] = tb.layQuyen(Session["Username"].ToString()); //cấp theo admin và user
                 string scr = "<script>alert('Cấp quyền thành công.')</script>"; //Thông báo windowload thành công
                 Page.ClientScript.RegisterStartupScript(Page.GetType(), "Thông báo", scr);
             }
         }
     }
 }
Exemplo n.º 24
0
        private void btndoimatkhau_Click(object sender, EventArgs e)
        {
            if (txtmatkhau.Text == txtmatkhaumoi.Text)
            {
                MessageBox.Show("Không được đặt lại mật khẩu hiện tại!");
            }
            else if (txtmatkhaumoi.Text != txtnhaplaimk.Text)
            {
                MessageBox.Show("Mật khẩu không chùng khớp!");
            }
            else
            {
                string mkmoi = txtmatkhaumoi.Text;

                byte[]   bytes       = Encoding.UTF8.GetBytes(mkmoi);
                var      encodedData = Convert.ToBase64String(bytes);
                TaiKhoan tk          = new TaiKhoan(user, encodedData);

                TaiKhoanBLL.SuaMatKhau(tk);
                MessageBox.Show("Đổi mật khẩu thành công!");
            }
        }
 public Form_DangNhap()
 {
     InitializeComponent();
     tkbll = new TaiKhoanBLL();
     nvbll = new NhanVienBLL();
 }
Exemplo n.º 26
0
 private void btnDangXuat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     TaiKhoanBLL.DangXuat();
     this.Close();
     new Thread(() => new frmLogin().ShowDialog()).Start();
 }
Exemplo n.º 27
0
 public Form_DoiMatKhau()
 {
     taiKhoanBLL = new TaiKhoanBLL();
     InitializeComponent();
 }
Exemplo n.º 28
0
 public frmLogin()
 {
     tkBLL = new TaiKhoanBLL();
     InitializeComponent();
 }
Exemplo n.º 29
0
 public Form_DoiMatKhau()
 {
     InitializeComponent();
     tkbll = new TaiKhoanBLL();
 }
Exemplo n.º 30
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (string.Equals(txtMatKhau.Text, txtMatKhauNhapLai.Text) && !string.IsNullOrEmpty(txtTenTaiKhoan.Text) && !string.IsNullOrEmpty(txtMatKhau.Text))
            {
                if (txtMatKhau.Text.Length >= 4 && txtMatKhau.Text.Length <= 20)
                {
                    if (txtTenTaiKhoan.Text.Length == 0 || txtTenTaiKhoan.Text.Length < 20)
                    {
                        try
                        {
                            string quyen = "";
                            if (rdoGiamDoc_them.Checked)
                            {
                                quyen = "GIAMDOC";
                            }
                            else if (rdoNhanVien_Them.Checked)
                            {
                                quyen = "NHANVIEN";
                            }
                            else if (rdoQuanLy_Them.Checked)
                            {
                                quyen = "QUANLI";
                            }
                            TaiKhoan taiKhoan = new TaiKhoan();
                            taiKhoan.DiaChi      = txtDiaChi_them.Text;
                            taiKhoan.Email       = txtEmail_them.Text;
                            taiKhoan.HoTen       = txtHoTen_them.Text;
                            taiKhoan.MatKhau     = txtMatKhau.Text;
                            taiKhoan.Quyen       = quyen;
                            taiKhoan.SDT         = txtSDT_them.Text;
                            taiKhoan.TenDangNhap = txtTenTaiKhoan.Text;

                            TaiKhoanBLL.ThemTaiKhoan(taiKhoan);
                            MessageBox.Show("Thêm tài khoản thành công");
                            txtDiaChi_them.Clear();
                            txtEmail_them.Clear();
                            txtHoTen_them.Clear();
                            txtMatKhau.Clear();
                            txtMatKhauNhapLai.Clear();
                            txtSDT_them.Clear();
                            txtTenTaiKhoan.Clear();
                            LoadDataGridView();
                        }
                        catch
                        {
                            MessageBox.Show("Vui lòng điền đầy đủ tên đăng nhập và mật khẩu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tên tài khoản phải nhỏ hơn 20 kí tự", "Thông báo", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Mật khẩu phải từ 4-20 kí tự", "Thông báo", MessageBoxButtons.OK);
                };
            }
            else
            {
                if (string.IsNullOrEmpty(txtTenTaiKhoan.Text) || string.IsNullOrEmpty(txtMatKhau.Text))
                {
                    MessageBox.Show("Vui lòng điền đầy đủ tên đăng nhập và mật khẩu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else //if (string.Equals(txtMatKhau.Text, txtMatKhauNhapLai.Text))
                {
                    MessageBox.Show("Mật khẩu không trùng khớp. Vui lòng nhập lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                txtMatKhau.Clear();
                txtMatKhauNhapLai.Clear();
            }
        }