示例#1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NHAN_VIEN nv = LayTTNV();

            if (dieukien)
            {
                if (dao_nv.InsertNhanVien(nv))
                {
                    MessageBox.Show("Thêm thành công");
                    loadNhanVien();
                    xuLyControl(false);
                    //txtMa.Enabled = true;
                    frm.Visible = false;
                    resetText();
                }
            }
            else
            {
                if (dao_nv.UpdateNhanVien(nv))
                {
                    MessageBox.Show("Sửa thành công");
                    loadNhanVien();
                    xuLyControl(false);
                    //txtMa.Enabled = true;
                    frm.Visible = false;
                    resetText();
                    sua(true);
                }
            }
        }
示例#2
0
        public NHAN_VIEN GetDVByUsername(string username)
        {
            NHAN_VIEN result = new NHAN_VIEN();

            result = context.NHAN_VIEN.FirstOrDefault(m => m.USERNAME == username);
            return(result);
        }
 private void RaiseSendDataEventHander(NHAN_VIEN nhanVien)
 {
     if (SendData != null)
     {
         SendData(this, nhanVien);
     }
 }
示例#4
0
        public DataTable KiemTraTrungSDT(NHAN_VIEN nv)
        {
            string    query = "select * from NHAN_VIEN where NV_SDT = '" + nv.Nv_sdt + "'";
            DataTable dt    = connecDB.ExecuteQuery(query);

            return(dt);
        }
        public static bool Login(string tenDangNhap, string matKhau)
        {
            int       user = 0;
            NHAN_VIEN tmp;

            try
            {
                user = Convert.ToInt32(tenDangNhap);
            }
            catch (Exception)
            {
                user = 0;
            }
            try
            {
                tmp = NHAN_VIEN.select(" where MSNV = " + user + " and TRANG_THAI > 0 ")[0];
            }
            catch (Exception)
            {
                tmp = null;
            }
            if (tmp != null && tmp.MAT_KHAU == matKhau)
            {
                Init.nhanVien = tmp;
                return(true);
            }
            return(false);
        }
示例#6
0
        private void icoBtnXoa_Click(object sender, EventArgs e)
        {
            if (maNvGlobal == "")
            {
                MessageBox.Show("Vui lòng chọn nhân viên cần xóa!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                NHAN_VIEN nv = context.NHAN_VIEN.FirstOrDefault(p => p.MaNhanVien.Equals(maNvGlobal));

                if (nv != null)
                {
                    if (MessageBox.Show("Xác nhận xóa!", "Cảnh báo!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        context.NHAN_VIEN.Remove(nv);
                        context.SaveChanges();
                        MessageBox.Show(" Xóa thành công!", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        loadData();
                    }
                }
                else
                {
                    MessageBox.Show(" Vui lòng chọn nhân viên cần xóa", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
示例#7
0
 public bool InsertNhanVien(NHAN_VIEN nv)
 {
     if (KiemTraNhapLieu(nv))
     {
         try
         {
             string query = string.Format("Insert NHAN_VIEN (CD_ID, CV_ID, NV_HOTEN, NV_GIOITINH, NV_NGAYSINH, NV_CMT, NV_SDT, NV_DIACHI, NV_TAIKHOAN, NV_MATKHAU, NV_TINHTRANG) values ('{0}', '{1}', N'{2}', '{3}', CONVERT(DATE, '{4}', 103) , '{5}',  '{6}', N'{7}', '{8}', '{9}', '{10}')",
                                          nv.Id_cd, nv.Id_cv, nv.Nv_hoten, nv.Nv_gioitinh, nv.Nv_ngaysinh, nv.Nv_cmt, nv.Nv_sdt, nv.Nv_diachi, nv.Nv_tk, nv.Nv_mk, nv.Nv_trangthai);
             int result = connecDB.ExecuteNonQuery(query);
             return(result > 0);
         }
         catch
         {
             /*if (KiemTraTrungCMT(nv).Rows.Count == 0)
              * {
              *  MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
              * }
              * else
              * {
              *  MessageBox.Show("Thêm không thành công do CMT của giáo viên đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
              * }
              *
              * if(KiemTraTrungSDT(nv).Rows.Count == 0)
              * {
              *  MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
              * }
              * else
              * {
              *  MessageBox.Show("Thêm không thành công do Số điện thoại của giáo viên đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
              * }*/
         }
     }
     return(false);
 }
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            int       Ma_NV      = Convert.ToInt32(Session["MA_NV"]);
            NHAN_VIEN nv         = nhanVienService.GetDVByMa(Ma_NV);
            string    passoldstr = txt_old_pass.Text;

            byte[] passold = Encoding.ASCII.GetBytes(passoldstr);
            if (nhanVienService.Login(nv.USERNAME, passold))
            {
                string passstr = txt_new_password.Text;
                byte[] pass    = Encoding.ASCII.GetBytes(passstr);
                if (nhanVienService.ChangePassWord(pass, Ma_NV) == 1)
                {
                    lb_messenger.Visible = true;
                    lb_messenger.Text    = "Thay đổi thành công";
                }
                else
                {
                    lb_messenger.Visible = true;
                    lb_messenger.Text    = "Thay đổi không thành công";
                }
            }
            else
            {
                lb_messenger.Visible = true;
                lb_messenger.Text    = "Mật khẩu cũ không đúng";
            }
        }
示例#9
0
        public NHAN_VIEN GetDVByMa(int pMa)
        {
            NHAN_VIEN result = new NHAN_VIEN();

            result = context.NHAN_VIEN.FirstOrDefault(m => m.MA_NV == pMa);
            return(result);
        }
        public ActionResult XemThongTin(NHAN_VIEN model)
        {
            if (ModelState.IsValid)
            {
                if (Session["Ten_NV"] != null)
                {
                    ViewBag.Ten_NV = Session["Ten_NV"].ToString();
                }
                if (Session["CHUCVU_NV"] != null)
                {
                    ViewBag.CHUCVU_NV = Session["CHUCVU_NV"].ToString();
                }
                if (Session["Email_NV"] != null)
                {
                    ViewBag.Email_NV = Session["Email_NV"].ToString();
                }

                var dao = new NHAN_VIEN_DAO();
                model.MATKHAU      = Encryptor.MD5Hash(model.MATKHAU);
                model.CONFIRM_PASS = Encryptor.MD5Hash(model.CONFIRM_PASS);
                bool kq = dao.UpdateNhanVien(model);
                if (kq)
                {
                    ModelState.AddModelError("", "Cập nhật thành công thông tin cá nhân");
                    //return RedirectToAction("Index", "ADTuyenDuong");
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật thất bại thông tin cá nhân");
                }
            }
            return(View(model));
        }
        public PanelCaLamViec(NHAN_VIEN nv, int tongCa, List <PHAN_CA> pc, DateTime thoiGian)
        {
            InitializeComponent();
            this.tongCa  = tongCa;
            lbHoTen.Text = nv.MSNV + "-" + nv.HO_TEN.Substring(Math.Max(nv.HO_TEN.IndexOf(' '), 0));
            int j = 0;

            for (int i = 1; i <= tongCa; i++)
            {
                CheckBox tmp = new CheckBox();
                tmp.AutoSize                = true;
                tmp.Font                    = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(163)));
                tmp.Location                = new System.Drawing.Point(3, 3);
                tmp.Name                    = i.ToString();
                tmp.RightToLeft             = System.Windows.Forms.RightToLeft.Yes;
                tmp.Size                    = new System.Drawing.Size(113, 25);
                tmp.TabIndex                = 5;
                tmp.Text                    = i.ToString();
                tmp.UseVisualStyleBackColor = true;
                if (j < pc.Count && i == pc[j].CA)
                {
                    tmp.Checked = true;
                    if (pc[j].CHAM_CONG == 1)
                    {
                        tmp.Enabled = false;
                    }
                    j++;
                }
                cbb.Add(tmp);
                flowPanel.Controls.Add(cbb[i - 1]);
            }
            nhanVien      = nv;
            this.thoiGian = thoiGian;
        }
示例#12
0
        public ActionResult DeleteConfirmed(string id)
        {
            NHAN_VIEN nHAN_VIEN = db.NHAN_VIEN.Find(id);

            db.NHAN_VIEN.Remove(nHAN_VIEN);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#13
0
        public int Add(NHAN_VIEN p)
        {
            int result = 0;

            context.NHAN_VIEN.Add(p);
            result = context.SaveChanges();
            return(result);
        }
示例#14
0
        public int Delete(int pMa)
        {
            int       result = 0;
            NHAN_VIEN k      = context.NHAN_VIEN.FirstOrDefault(m => m.MA_NV == pMa);

            context.NHAN_VIEN.Remove(k);
            result = context.SaveChanges();
            return(result);
        }
示例#15
0
        //	Employee leave
        public static bool SaThaiNhanVien(int msnv, string ghiChu)
        {
            LichSuNhanVien.SaThaiNhanVien(msnv, ghiChu);
            NHAN_VIEN nv = NHAN_VIEN.select(" where MSNV = " + msnv)[0];

            nv.TRANG_THAI = 0;
            NHAN_VIEN.update(nv);
            return(true);
        }
示例#16
0
 public ActionResult Edit([Bind(Include = "MA_NV,MAT_KHAU,TEN_NV,CHUC_VU,LIEN_HE,Email")] NHAN_VIEN nHAN_VIEN)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nHAN_VIEN).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nHAN_VIEN));
 }
示例#17
0
 //	Change Infomation of Employee
 public static bool ThayDoiThongTin(NHAN_VIEN nvCu, NHAN_VIEN nvMoi)
 {
     if (nvMoi.MSNV != nvCu.MSNV)
     {
         return(false);
     }
     LichSuNhanVien.ThayDoiThongTin(nvCu, nvMoi);
     NHAN_VIEN.update(nvMoi);
     return(true);
 }
示例#18
0
        public ActionResult Create([Bind(Include = "MA_NV,MAT_KHAU,TEN_NV,CHUC_VU,LIEN_HE,Email")] NHAN_VIEN nHAN_VIEN)
        {
            if (ModelState.IsValid)
            {
                db.NHAN_VIEN.Add(nHAN_VIEN);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nHAN_VIEN));
        }
示例#19
0
 public static string LayHoTen(int MSNV)
 {
     try
     {
         return(NHAN_VIEN.select(" where MSNV = " + MSNV + " ")[0].HO_TEN);
     }
     catch (Exception)
     {
         return("");
     }
 }
示例#20
0
        private void icoBtnThem_Click(object sender, EventArgs e)
        {
            if (txtHoten.Text == "" || txtDiachi.Text == "" || txtSDT.Text == "")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (txtSDT.Text.Substring(0, 1) != "0")
                {
                    MessageBox.Show("Số điện thoại không đúng định dạng! (0xxx)");
                }
                else
                {
                    if (check18(DateTime.Parse(dateTimePicker1.Text.ToString())))
                    {
                        // Lay nhan vien cuoi
                        NHAN_VIEN nv = getLastStaff();

                        if (nv == null)
                        {
                            NHAN_VIEN newNV = new NHAN_VIEN()
                            {
                                MaNhanVien = "NV001", HoTen = txtHoten.Text, ChucVu = cboChucvu.Text, GioiTinh = cboGioitinh.Text, DiaChi = txtDiachi.Text, NgaySinh = DateTime.Parse(dateTimePicker1.Text), SoDienThoai = txtSDT.Text, MaChucVu = cboChucvu.SelectedValue.ToString()
                            };

                            context.NHAN_VIEN.Add(newNV);
                            context.SaveChanges();
                            MessageBox.Show(" Thêm thành công!", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            loadData();
                        }
                        else
                        {
                            string sttCuoi = nv.MaNhanVien.Replace("NV", "").ToString();
                            string maMoi   = convertNumbtoID(sttCuoi);

                            NHAN_VIEN newNV = new NHAN_VIEN()
                            {
                                MaNhanVien = maMoi, HoTen = txtHoten.Text, ChucVu = cboChucvu.Text, GioiTinh = cboGioitinh.Text, DiaChi = txtDiachi.Text, NgaySinh = DateTime.Parse(dateTimePicker1.Text), SoDienThoai = txtSDT.Text, MaChucVu = cboChucvu.SelectedValue.ToString()
                            };

                            context.NHAN_VIEN.Add(newNV);
                            context.SaveChanges();
                            MessageBox.Show(" Thêm thành công!", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            loadData();
                        }
                    }
                    else
                    {
                        MessageBox.Show(" Nhân viên quá nhỏ tuổi!", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
示例#21
0
 public bool SuaTTNhanVien(NHAN_VIEN p)
 {
     try
     {
         NHAN_VIEN k = qlkho.NHAN_VIENs.Where(t => t.MANV == p.MANV).FirstOrDefault();
         k = p;
         qlkho.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }
示例#22
0
 public bool XoaNhanVien(string ma)
 {
     try
     {
         NHAN_VIEN p = qlkho.NHAN_VIENs.Where(t => t.MANV == ma).FirstOrDefault();
         qlkho.NHAN_VIENs.DeleteOnSubmit(p);
         qlkho.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }
示例#23
0
        //Lay nhan vien cuoi
        public NHAN_VIEN getLastStaff()
        {
            NHAN_VIEN        nv   = null;
            List <NHAN_VIEN> list = context.NHAN_VIEN.ToList();

            foreach (var temp in list)
            {
                nv = temp;
            }
            return(nv);
        }
示例#24
0
 public static NHAN_VIEN LayNhanVien(int msnv)
 {
     try
     {
         return(NHAN_VIEN.select(" where MSNV = " + msnv + " and TRANG_THAI = 1 ")[0]);
     }
     catch (Exception)
     {
         return(null);
     }
 }
示例#25
0
 //	Get Position of Employee
 public static int getChucVu(int user)
 {
     try
     {
         return(NHAN_VIEN.select(" where MSNV = " + user + " ")[0].MSNV);
     }
     catch (Exception)
     {
         return(0);
     }
 }
示例#26
0
 public bool UpdateNhanVien(NHAN_VIEN nv)
 {
     if (KiemTraNhapLieu(nv))
     {
         string query = string.Format("Update NHAN_VIEN set CD_ID = '{0}', CV_ID = '{1}', NV_HOTEN = N'{2}', NV_GIOITINH = N'{3}', NV_NGAYSINH = CONVERT(DATE, '{4}', 103), NV_CMT = '{5}',  NV_SDT = '{6}', NV_DIACHI = N'{7}'  where NV_ID = '{8}'",
                                      nv.Id_cd, nv.Id_cv, nv.Nv_hoten, nv.Nv_gioitinh, nv.Nv_ngaysinh, nv.Nv_cmt, nv.Nv_sdt, nv.Nv_diachi, nv.Id_nv);
         int result = connecDB.ExecuteNonQuery(query);
         return(result > 0);
     }
     return(true);
 }
示例#27
0
 //	Create New Employee
 public static int ThemNhanVien(NHAN_VIEN nv, string ghiChu)
 {
     try
     {
         int msnv = NHAN_VIEN.insert(nv);
         LichSuNhanVien.ThemNhanVien(msnv, ghiChu);
         return(msnv);
     }
     catch (Exception)
     {
         return(0);
     }
 }
示例#28
0
 public bool ThemNhanVien(NHAN_VIEN nv)
 {
     try
     {
         qlkho.NHAN_VIENs.InsertOnSubmit(nv);
         qlkho.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#29
0
        // GET: Admin/Employee/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NHAN_VIEN nHAN_VIEN = db.NHAN_VIEN.Find(id);

            if (nHAN_VIEN == null)
            {
                return(HttpNotFound());
            }
            return(View(nHAN_VIEN));
        }
示例#30
0
        public bool KiemTraNhapLieu(NHAN_VIEN nv)
        {
            if (nv.Nv_hoten.Equals(""))
            {
                MessageBox.Show("Tên giáo viên không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            else if (nv.Nv_ngaysinh.Equals(""))
            {
                MessageBox.Show("Ngày sinh không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }