Example #1
0
 private void btnXoaTaiKhoan_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn muốn xóa tài khoản này!", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
     {
         Data_SQL.update_Data("DELETE FROM dbo.TAIKHOAN WHERE MaNhanVien = '" + txbMaNhanVien.Text + "'");
         if (MessageBox.Show("Xóa thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
         {
             dtgvDanhSachCapQuyen.DataSource = Data_SQL.GetData_for_DataTable("SELECT MaNhanVien, MatKhau FROM dbo.TAIKHOAN").Tables[0];
         }
     }
 }
Example #2
0
        private void dtgvDanhSachCapQuyen_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            txbChucVu.ReadOnly      = true;
            txbMaNhanVien.ReadOnly  = true;
            txbMatKhau.ReadOnly     = true;
            txbTenNhanVien.ReadOnly = true;
            btnChinhSua.Enabled     = true;
            btnCapMatKhau.Enabled   = false;
            string NameHeader = dtgvDanhSachCapQuyen.Columns[e.ColumnIndex].HeaderText.ToString(); //Lấy tên header của ô được trỏ tới
            string dataCell   = dtgvDanhSachCapQuyen.CurrentCell.Value.ToString();                 //Lấy dữ liệu tại ô được click
            string query      = "select * from dbo.TAIKHOAN where " + NameHeader + " = N'" + dataCell + "'";

            dtgvTempData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            dtgvTempData.DataSource          = Data_SQL.GetData_for_DataTable(query).Tables[0];

            txbMaNhanVien.Text  = dtgvTempData.CurrentRow.Cells[0].Value.ToString();
            txbTenNhanVien.Text = dtgvTempData.CurrentRow.Cells[1].Value.ToString();
            txbMatKhau.Text     = dtgvTempData.CurrentRow.Cells[2].Value.ToString();
            txbChucVu.Text      = dtgvTempData.CurrentRow.Cells[3].Value.ToString();
        }
Example #3
0
 private void btnTaoHoSo_Click(object sender, EventArgs e)
 {
     if (txbMaHoSo.Text.Length == 0 || txbNgayTiepNhan.Text.Length == 0 || txbTenDaiLy.Text.Length == 0 || cbbLoaiHoSo.Text.Length == 0 || cbbQuan.Text.Length == 0 || txbTenDaiLy.Text.Length == 0 || txbSoDienThoai.Text.Length == 0 || txbMaNhanVien.Text.Length == 0)
     {
         MessageBox.Show("Tạo hồ sơ thất bại!\n\n Bạn đã bỏ trống trường có dấu (*)", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         //Lấy mã loại đại lý từ tên loại đại lý
         string MaLoaiDaiLy = Data_SQL.get_Data_of_SomeThing("SELECT MaLoaiDaiLy " +
                                                             "FROM dbo.LOAIDAILY WHERE  TenLoaiDaiLy = N'" + cbbLoaiHoSo.Text + "'").ToString();
         //Lấy mã quận từ tên quận
         string MaQuan = Data_SQL.get_Data_of_SomeThing("SELECT MaQuan " +
                                                        "FROM dbo.QUAN WHERE  TenQuan = N'" + cbbQuan.Text + "'").ToString();
         string query = "INSERT INTO dbo.DAILY( MaDaiLy , TenDaiLy , MaLoaiDaiLy , DienThoai , Email , DiaChi , MaQuan , NgayTiepNhan , SoNo , GhiChu , MaNhanVien )" +
                        " VALUES('" + txbMaHoSo.Text + "', "
                        + "N'" + txbTenDaiLy.Text + "', "
                        + "'" + MaLoaiDaiLy + "', "
                        + "'" + txbSoDienThoai.Text + "', "
                        + "'" + txbEmail.Text + "', "
                        + "N'" + txbDiaChi.Text + "', "
                        + "'" + MaQuan + "', "
                        + "'" + txbNgayTiepNhan.Text + "', "
                        + "'0', "
                        + "N'" + txbGhiChu.Text + "', "
                        + "'" + txbMaNhanVien.Text + "')";
         Data_SQL.update_Data(query);
         if (MessageBox.Show("Tạo hồ sơ thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
         {
             txbMaHoSo.Text       = null;
             txbTenDaiLy.Text     = null;
             txbDiaChi.Text       = null;
             txbEmail.Text        = null;
             txbGhiChu.Text       = null;
             txbNgayTiepNhan.Text = null;
             txbSoDienThoai.Text  = null;
             cbbLoaiHoSo.Text     = null;
             cbbQuan.Text         = null;
         }
     }
 }
Example #4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string query = "UPDATE dbo.TAIKHOAN SET " +
                           "TenNhanVien = N'" + txbTenNhanVien.Text + "', " +
                           "MatKhau = '" + txbMatKhau.Text + " ', " +
                           "LoaiTaiKhoan = N'" + txbChucVu.Text + "'" +
                           "WHERE MaNhanVien = '" + txbMaNhanVien.Text + "'";

            Data_SQL.update_Data(query);
            if (MessageBox.Show("chỉnh sửa thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
            {
                txbChucVu.Text          = "";
                txbMaNhanVien.Text      = "";
                txbMatKhau.Text         = "";
                txbTenNhanVien.Text     = "";
                txbChucVu.ReadOnly      = true;
                txbMaNhanVien.ReadOnly  = true;
                txbMatKhau.ReadOnly     = true;
                txbTenNhanVien.ReadOnly = true;
                btnChinhSua.Enabled     = true;
            }
        }
Example #5
0
 private void btnTaoTaiKhoan_Click(object sender, EventArgs e)
 {
     if (txbChucVu.Text.Length == 0 || txbMaNhanVien.Text.Length == 0 || txbMatKhau.Text.Length == 0 || txbTenNhanVien.Text.Length == 0)
     {
         if (MessageBox.Show("Tạo tài khoản thất bại \n\n Bạn phải nhập đầy đủ thông tin", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
         {
             txbChucVu.Text          = "";
             txbMaNhanVien.Text      = "";
             txbMatKhau.Text         = "";
             txbTenNhanVien.Text     = "";
             txbChucVu.ReadOnly      = false;
             txbMaNhanVien.ReadOnly  = false;
             txbMatKhau.ReadOnly     = false;
             txbTenNhanVien.ReadOnly = false;
         }
     }
     else if (txbChucVu.ReadOnly == true)
     {
         MessageBox.Show("Tạo tài khoản thất bại", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information);
         txbChucVu.Text          = "";
         txbMaNhanVien.Text      = "";
         txbMatKhau.Text         = "";
         txbTenNhanVien.Text     = "";
         txbChucVu.ReadOnly      = false;
         txbMaNhanVien.ReadOnly  = false;
         txbMatKhau.ReadOnly     = false;
         txbTenNhanVien.ReadOnly = false;
         btnCapMatKhau.Enabled   = true;
     }
     else
     {
         string query = "INSERT INTO dbo.TAIKHOAN ( MaNhanVien , TenNhanVien , MatKhau , LoaiTaiKhoan ) " +
                        "VALUES ('" + txbMaNhanVien.Text + "', N'" + txbTenNhanVien.Text + "', '" + txbMatKhau.Text + " ', N'" + txbChucVu.Text + "')";
         if (Data_SQL.update_Data(query) == false)
         {
             if (MessageBox.Show("Tạo tài khoản thất bại", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
             {
                 txbChucVu.Text          = "";
                 txbMaNhanVien.Text      = "";
                 txbMatKhau.Text         = "";
                 txbTenNhanVien.Text     = "";
                 txbChucVu.ReadOnly      = false;
                 txbMaNhanVien.ReadOnly  = false;
                 txbMatKhau.ReadOnly     = false;
                 txbTenNhanVien.ReadOnly = false;
             }
         }
         else
         {
             if (MessageBox.Show("Tạo tài khoản thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
             {
                 dtgvDanhSachCapQuyen.DataSource = Data_SQL.GetData_for_DataTable("SELECT MaNhanVien, MatKhau FROM dbo.TAIKHOAN").Tables[0];
                 txbChucVu.Text          = "";
                 txbMaNhanVien.Text      = "";
                 txbMatKhau.Text         = "";
                 txbTenNhanVien.Text     = "";
                 txbChucVu.ReadOnly      = true;
                 txbMaNhanVien.ReadOnly  = true;
                 txbMatKhau.ReadOnly     = true;
                 txbTenNhanVien.ReadOnly = true;
                 btnChinhSua.Enabled     = true;
             }
         }
     }
 }
Example #6
0
 private void ucQuanTriVien_Load(object sender, EventArgs e)
 {
     dtgvDanhSachCapQuyen.DataSource = Data_SQL.GetData_for_DataTable("SELECT MaNhanVien, MatKhau FROM dbo.TAIKHOAN").Tables[0];
     btnLuu.Enabled = false;
 }