public bool Insert(staff nv) { try { db.staffs.InsertOnSubmit(nv); var permissions = from p in db.permissions select p; foreach (permission p in permissions) { staff_permission sp = new staff_permission(); sp.permission = p; sp.staff = nv; sp.created = DateTime.Now; sp.allow = false; db.staff_permissions.InsertOnSubmit(sp); } db.SubmitChanges(); return true; } catch(Exception ex) { throw ex; } }
public List<staff_permission> GetPermissions(staff nv) { var p = from d in nv.staff_permissions select d; return p.ToList(); }
public BindingList<CourseList>ListAssignedCoursesByUser(int staff_id) { List<staff_assigned_course> list = new List<staff_assigned_course>(); BindingList<CourseList> blist = new BindingList<CourseList>(); list = ListOfAssignedCoursesByUser(staff_id); int i = 1; Dictionary<int, CourseList> map = new Dictionary<int, CourseList>(); foreach (staff_assigned_course sac in list) { CourseList cl = new CourseList(); int _trainer_id = 0; staff s = new staff(); _trainer_id = int.Parse(sac.assigned_course.course.trainer_id.ToString()); s = GetStaffById(_trainer_id); cl.TrainingModule = sac.assigned_course.course.name; cl.InternalTrainerName = string.Concat(s.first_name.ToString(), " ", s.last_name.ToString()); cl.CourseType = sac.assigned_course.course.course_type.name; cl.CompletionStatus = sac.completion_status.name; cl.CompletionDate = DateTime.Parse(sac.assigned_course.end_date.ToString()); map.Add(i, cl); i += 1; } foreach (KeyValuePair<int, CourseList> m in map) { blist.Add(m.Value); } return blist; }
public object GetAllPermission(staff nv) { try { var st = from p in db.staff_permissions where p.staff_id.Equals(nv.id) select p; return st; } catch(Exception ex) { throw ex; } }
public bool Delete(staff nv) { try { staff_permission p = db.staff_permissions.Where(t => t.staff_id.Equals(nv.id)).FirstOrDefault(); if (p != null) return false; return true; } catch(Exception ex) { throw ex; } }
public ApiMessage <staff> LoginOn(staff user) { var strSql = PetaPoco.Sql.Builder; strSql.Append("select f.* from staff f left join station s on s.ID=f.StationID "); strSql.Where("f.UserCode=@0 and f.IsActive=1", user.UserCode); strSql.Where("f.PassWord=@0 and s.IsActive=1", user.PassWord); var loginUser = _db.Fetch <staff>(strSql).FirstOrDefault(); if (string.IsNullOrEmpty(loginUser?.ID)) { return(new ApiMessage <staff> { MsgCode = "400", Msg = "用户不存在或密码有误", Success = false }); } return(new ApiMessage <staff> { Data = loginUser }); }
public ApiMessage <string> Add(staff user) { user.Insert(); return(new ApiMessage <string>()); }
void FrmMain_Load(object sender, EventArgs e) { ImgSlide.Images.Add(GUI.Properties.Resources.slide2); //ImgSlide.Images.Add(GUI.Properties.Resources.slide3); //ImgSlide.Images.Add(GUI.Properties.Resources.slide4); //ImgSlide.Images.Add(GUI.Properties.Resources.slide5); //ImgSlide.Images.Add(GUI.Properties.Resources.slide6); //ImgSlide.Images.Add(GUI.Properties.Resources.slide7); //ImgSlide.Images.Add(GUI.Properties.Resources.slide8); //ImgSlide.Images.Add(GUI.Properties.Resources.slide9); //ImgSlide.Images.Add(GUI.Properties.Resources.slide10); NhanVien = phanquyen.GetUsername(this.Tag.ToString()); if (NhanVien == null) return; barTxtNhanVien.Caption = NhanVien.name; barTxtDangNhap.Caption = "Đăng xuất"; List<staff_permission> permissions = phanquyen.GetPermissions(NhanVien); Dictionary<string, bool> quyen = new Dictionary<string, bool>(); foreach (staff_permission sp in permissions) { quyen.Add(sp.permission.id, sp.allow); } // dat quyen tuong ung voi rib ribHoaDon.Enabled = quyen["QLHD"]; ribCauHinh.Enabled = quyen["QLHT"]; ribHangHoa.Enabled = quyen["QLHH"]; ribKhachHang.Enabled = quyen["QLKH"]; ribNhaCungCap.Enabled = quyen["QLNCC"]; ribNhanVien.Enabled = quyen["QLNV"]; ribNhapHang.Enabled = quyen["QLNH"]; ribPhanQuyen.Enabled = quyen["QLPQ"]; }
private void detach_staffs(staff entity) { this.SendPropertyChanging(); entity.role = null; }
partial void Deletestaff(staff instance);
private void attach_staffs(staff entity) { this.SendPropertyChanging(); entity.role = this; }
partial void Updatestaff(staff instance);
partial void Insertstaff(staff instance);
private void attach_staffs(staff entity) { this.SendPropertyChanging(); entity.department = this; }
private void btnLuu_Click(object sender, EventArgs e) { if (lbTenNV.Text == string.Empty) { CheckLoi(txtTenNV.Text); txtTenNV.Focus(); } if (lbDiaChi.Text == string.Empty) { CheckLoi(txtDiaChi.Text); txtDiaChi.Focus(); } if (dpNgaySinh.EditValue == null) { CheckLoi(lbNgaySinh.Text); dpNgaySinh.Focus(); } if (chkNam.Checked == false && chkNu.Checked == false) { CheckLoi(lbGioiTinh.Text); } if(txtUser.Text == string.Empty) { CheckLoi(lbUserName.Text); txtUser.Focus(); } if (txtPass.Text == string.Empty) { CheckLoi(lbPassword.Text); txtPass.Focus(); } staff nv = new staff(); nv.id = txtMaNV.Text; nv.name = txtTenNV.Text; nv.birthday = (DateTime)dpNgaySinh.EditValue; nv.address = txtDiaChi.Text; nv.email = txtEmail.Text; nv.username = txtUser.Text; nv.password = txtPass.Text; nv.created = DateTime.Now; if (chkNam.Checked) nv.gender = true; else nv.gender = false; if(s == "Them") { if (busNhanVien.Insert(nv)) { XtraMessageBox.Show("Thêm nhân viên thành công!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); btnDanhMucLamMoi.PerformClick(); } else { XtraMessageBox.Show("Thêm nhân viên bị lỗi!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { staff n = (staff)gvNhanVien.GetFocusedRow(); n.name = txtTenNV.Text; nv.birthday = (DateTime)dpNgaySinh.EditValue; nv.address = txtDiaChi.Text; nv.email = txtEmail.Text; nv.username = txtUser.Text; nv.password = txtPass.Text; if (chkNam.Checked) nv.gender = true; else nv.gender = false; if (busNhanVien.Update(nv)) { XtraMessageBox.Show("Cập nhật thành công!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); btnDanhMucLamMoi.PerformClick(); } else { XtraMessageBox.Show("Cập nhật thất bại!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } }
public bool Update(staff nv) { try { nv.modified = DateTime.Now; db.SubmitChanges(); return true; } catch(Exception ex) { throw ex; } }