//auto check delegate status when page load public void updateDelegateStatus(List <Models.Delegate> delegateList, DateTime operationDate) { foreach (Models.Delegate item in delegateList) { if (item.endDate < operationDate && item.status != "cancelled" && item.status != "terminated" && item.status != "expired")//expired { item.status = "expired"; string currentHeadID = item.DeptStaff.Department.headStaffID; DeptStaff currendHead = context.DeptStaffs.Where(x => x.staffID == currentHeadID).First(); currendHead.role = "head"; DeptStaff employee = context.DeptStaffs.Where(x => x.staffID == item.staffID).ToList().First(); employee.role = "emp"; } else { if (item.startDate <= operationDate && item.endDate >= operationDate && item.status != "cancelled" && item.status != "terminated" && item.status != "expired")//between delegate days { item.status = "On delegation"; string currentHeadID = item.DeptStaff.Department.headStaffID; DeptStaff currendHead = context.DeptStaffs.Where(x => x.staffID == currentHeadID).First(); currendHead.role = "outOfOfficeHead"; DeptStaff employee = context.DeptStaffs.Where(x => x.staffID == item.staffID).ToList().First(); employee.role = "delegateHead"; } } } context.SaveChanges(); }
public WCFDeptStaff GetDeptStaffById(string id) { DeptStaffDAO dDAO = new DeptStaffDAO(); DeptStaff d = dDAO.findStaffByID(id); return(new WCFDeptStaff(d.staffID, d.staffName, d.role, d.deptID, d.password, d.email, d.address)); }
//find a staff by ID public DeptStaff findStaffByID(string staffId) { List <DeptStaff> staffList = context.DeptStaffs.Where(x => x.staffID == staffId).ToList(); DeptStaff staff = new DeptStaff(); if (staffList.Count() > 0) { staff = staffList.First(); } return(staff); }
//find the current rep of certain department public DeptStaff findDeptRep(string deptId) { DeptStaff staff = new DeptStaff(); var s = context.DeptStaffs.Where(x => x.deptID == deptId && x.role == "rep").ToList(); if (s.Count > 0) { staff = s.First(); } return(staff); }
public string getStaffNameByID(string ID) { List <DeptStaff> list = new List <DeptStaff>(); DeptStaff s = new DeptStaff(); list = context.DeptStaffs.Where(x => x.staffID == ID).ToList(); if (list.Count() > 0) { s = list.First(); } return(s.staffName); }
private DeptStaff getDeptStaffByUsername(string username) { List <DeptStaff> staffl = context.DeptStaffs.Where(x => x.email == username).ToList(); DeptStaff staff = new DeptStaff(); staff.staffID = ""; if (staffl.Count > 0) { staff = staffl.First(); } return(staff); }
public virtual void CheckToken(DeptStaff request, DeptStaffResponse response) { //验证旧Token var staff = _deptStaffManager.InsideStaffRepository.GetStaffByToken(request.StaffNo, request.LinkToken); if (staff == null) { throw new Utility.WeChatException("SELECT_STAFF", "查询用户失败"); } staff.TOKEN = Guid.NewGuid().ToString(); _deptStaffManager.InsideStaffRepository.Update(staff); response.LinkToken = staff.TOKEN; response.Result = "OK"; }
public object Post(DeptStaff request) { DeptStaffResponse rsp = new DeptStaffResponse(); if (request.RequestType == (short)DeptStaffRequestType.CardStockOut) { _deptStaffService.GetAssignedStaff(request, rsp); } else if (request.RequestType == (short)DeptStaffRequestType.Report) { _deptStaffService.GetDepartsAndStaffs(request, rsp); } else if (request.RequestType == (short)DeptStaffRequestType.CheckToken) { _deptStaffService.CheckToken(request, rsp); } return(rsp); }
public void terminateDelegate(Models.Delegate delegateItem) { if (delegateItem.status == "active") { delegateItem.status = "cancelled"; } else { delegateItem.status = "terminated"; string currentHeadID = delegateItem.DeptStaff.Department.headStaffID; DeptStaff currendHead = context.DeptStaffs.Where(x => x.staffID == currentHeadID).First(); currendHead.role = "outOfOfficeHead"; DeptStaff employee = context.DeptStaffs.Where(x => x.staffID == delegateItem.staffID).ToList().First(); employee.role = "emp"; } context.SaveChanges(); }
public string[] getUser(string username) { if (getDeptStaffByUsername(username).staffID != "") {//is a department staff DeptStaff staff = getDeptStaffByUsername(username); result[0] = staff.staffID; result[1] = staff.role; result[2] = staff.password; result[3] = staff.staffName; } else if (getStoreStaffByUsername(username).storeStaffID != "") {//is a store staff StoreStaff staff = getStoreStaffByUsername(username); result[0] = staff.storeStaffID; result[1] = staff.role; result[2] = staff.password; result[3] = staff.storeStaffName; } return(result); }
protected void btnUpdateRep_Click(object sender, EventArgs e) { //Update string newRepName = ddlEmp.SelectedValue; DeptStaff newRep = new DeptStaff(); if (newRepName != "---Select Name---") { newRep = deptStaffDAO.findStaffByName(newRepName); logInDept = newRep.deptID; Department dept = deptDAO.findByDeptId(logInDept); DeptStaff oldRep = deptStaffDAO.findDeptRep(logInDept); deptStaffDAO.updateRepName(newRep, oldRep); deptDAO.UpdateDeptRep(dept, newRep); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please Select Name First!')", true); return; } //send feedback email and notification to employee SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); string headID = Session["loginID"].ToString(); string headName = Session["loginName"].ToString(); string staffID = newRep.staffID; string staffName = newRepName; NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(staffID, headName + " chose you as representative. ", DateTime.Now); Email email = new Email(); email.sendRepNotificationToEmployee(staffName, headName); //Refesh display DisplayCurrentRep(logInDept); DisplayAvaliableEmp(logInDept); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('', 'Successful!');</script>"); }
protected void BindGrid() { List <Department> deplist = new List <Department>(); deplist = depDAO.findAll(); DataTable iTable = new DataTable("itemTable"); iTable.Columns.Add(new DataColumn("deptID", typeof(string))); iTable.Columns.Add(new DataColumn("deptName", typeof(string))); iTable.Columns.Add(new DataColumn("staffName", typeof(string))); iTable.Columns.Add(new DataColumn("phone", typeof(string))); iTable.Columns.Add(new DataColumn("fax", typeof(string))); iTable.Columns.Add(new DataColumn("headName", typeof(string))); iTable.Columns.Add(new DataColumn("collectionPointID", typeof(string))); iTable.Columns.Add(new DataColumn("reqName", typeof(string))); foreach (Department i in deplist) { DataRow dr = iTable.NewRow(); DeptStaff HEADSTAFF = depstaffDAO.findStaffByStaffID(i.headStaffID); DeptStaff REPSTAFFID = depstaffDAO.findStaffByStaffID(i.repStaffID); DeptStaff CONTACTNAME = depstaffDAO.findStaffByStaffID(i.contactStaffID); dr["deptID"] = i.deptID; dr["deptName"] = i.deptName; dr["staffName"] = CONTACTNAME.staffName; dr["phone"] = i.phone; dr["fax"] = i.fax; dr["headName"] = HEADSTAFF.staffName; dr["collectionPointID"] = i.collectionPointID; dr["reqName"] = REPSTAFFID.staffName; iTable.Rows.Add(dr); } GridView_DepList.DataSource = iTable; GridView_DepList.DataBind(); }
public virtual void GetDepartsAndStaffs(DeptStaff request, DeptStaffResponse response) { IEnumerable <InsideDepart> departs; IEnumerable <InsideStaff> staffs; if (_deptStaffManager.RolePowerRepository.HasOperPower("201001", request.CurrOper))//主管 { //初始化部门 departs = _deptStaffManager.InsideDepartRepository.GetDepartList(); staffs = _deptStaffManager.InsideStaffRepository.GetStaffList(); } else if (_deptStaffManager.RolePowerRepository.HasOperPower("201002", request.CurrOper))//经理 { departs = _deptStaffManager.InsideDepartRepository.GetDepartList(request.CurrDept); staffs = _deptStaffManager.InsideStaffRepository.GetStaffList(request.CurrDept); } else//员工 { departs = _deptStaffManager.InsideDepartRepository.GetDepartList(request.CurrDept); staffs = _deptStaffManager.InsideStaffRepository.GetStaffList(staffNo: request.CurrOper); } response.Departs = departs; response.Staffs = staffs; }
protected void Page_Load(object sender, EventArgs e) { logInRole = (string)Session["loginRole"]; if (logInRole == "head" || logInRole == "outOfOfficeHead") { logInStaffId = (string)Session["loginID"]; headStaff = deptStaffDAO.findStaffByID(logInStaffId); deptID = headStaff.deptID; List <Models.Delegate> dList = delegateDAO.findDelegatesByDepartment(deptID); headStaff = deptStaffDAO.findStaffByID(logInStaffId); Label_logInRole.Text = headStaff.role; if (!IsPostBack) { delegateDAO.updateDelegateStatus(dList, operationDate); Label_logInRole.Text = headStaff.role; bindData(deptID); } } else { Response.Redirect("login.aspx"); } }
//update the rep of certain department public void updateRepName(DeptStaff newRep, DeptStaff oldRep) { newRep.role = "rep"; oldRep.role = "emp"; context.SaveChanges(); }
public void UpdateDeptRep(Department dept, DeptStaff newRep) { dept.repStaffID = newRep.staffID; context.SaveChanges(); }
public virtual void GetAssignedStaff(DeptStaff request, DeptStaffResponse response) { response.Staffs = _deptStaffManager.InsideStaffRepository.GetAssignedStaff(); }