public ActionResult GetEmployee() { try { int pageIndex = Convert.ToInt32(Request.QueryString["page"]); int pageSize = Convert.ToInt32(Request.QueryString["limit"]); string branchIds = Request.QueryString["id"]; string[] _ids = branchIds.Split(','); int[] ids = Array.ConvertAll<string, int>(_ids, id => { return int.Parse(id); }); EmployeeBLL eBll = new EmployeeBLL(); int rows = 0; int totalPages = 0; List<Employee> list = eBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t => ids.Contains(t.branchId), true, t => t.Id); if (list != null && list.Count > 0) { List<Branch> branchList = new BranchBLL().GetEntitys(); list.ForEach(t => { branchList.ForEach(y => { if (t.branchId == y.Id) { t.branchName = y.branchName; } }); }); List<Role> roleList = new RoleBLL().GetEntitys(); list.ForEach(t => { roleList.ForEach(y => { if (t.roleId == y.Id) { t.roleName = y.roleName; } }); }); List<Position> positionList = new PositionBLL().GetEntitys(); list.ForEach(t => { positionList.ForEach(y => { if (t.positionId == y.Id) { t.positionName = y.positionName; } }); }); } string resJson = Common.Common.JsonSerialize(list); resJson = "{total:" + rows + ",root:" + resJson + "}"; return Content(resJson); } catch { } return Content("{}"); }
public void ResolveName() { Guid?receiverGuid = EmployeeBLL.ResolveEmployeeName(this.ReceiverName); if (receiverGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.ReceivedBy = receiverGuid.Value; } //Guid? delivererGuid = EmployeeBLL.ResolveEmployeeName(this.DelivererName); //if (delivererGuid == null) // throw new Exception("No employee found with the specified name!"); //else // this.DeliveredBy = delivererGuid.Value; Guid?verifierGuid = EmployeeBLL.ResolveEmployeeName(this.VerifierName); if (verifierGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.VerifiedBy = verifierGuid.Value; } }
public void ResolveName() { Guid?requesterGuid = EmployeeBLL.ResolveEmployeeName(this.RequesterName); if (requesterGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.RequestedBy = requesterGuid.Value; } Guid?approverGuid = EmployeeBLL.ResolveEmployeeName(this.ApproverName); if (approverGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.ApprovedBy = approverGuid.Value; } }
public DataTable GeStoreIssueVoucherList(Guid WorkUnit, Guid ItemID, string strIssuedTo, DateTime IssueDate, DateTime IssueDate2, DateTime ApprovedDate, DateTime ApprovedDate2) { Guid?IssuedTo = EmployeeBLL.ResolveEmployeeName(strIssuedTo); if (IssuedTo == null) { IssuedTo = new Guid("00000000-0000-0000-0000-000000000000"); } return(SQLHelper.getDataTable(ConnectionString, "GetStoreIssueVouchers", WorkUnit, ItemID, IssuedTo, IssueDate, IssueDate2, ApprovedDate, ApprovedDate2)); }
public ActionResult DeleteEmployee() { string ids = Request.Form["ids"]; EmployeeBLL eBll = new EmployeeBLL(); if (eBll.DeletePhysicsById(ids)) { return Content("{'success':'ok'}"); } else { return Content("{}"); } }
public static Guid?ResolveEmployeeName(string employeeName) { Guid?_empId; var emp = (from empObj in EmployeeBLL.GetEmployeeList(employeeName) where empObj.EmployeeName.ToUpper() == employeeName.ToUpper() select empObj).FirstOrDefault(); if (emp == null) { return(null); } _empId = emp.ID; return(_empId.Value); }
public void Display() { EmployeeBLL bll = new EmployeeBLL(); List<EmployeeBO> list = bll.ReadAll(); foreach (var employee in list) { Console.WriteLine("Name =" + employee.Name); Console.WriteLine("Age =" + employee.Age); Console.WriteLine("Salary =" + employee.Salary); Console.WriteLine("------------------------------"); } }
public void Input() { Console.Write("Enter Name = "); string name = Console.ReadLine(); Console.Write("Enter Age = "); string age = Console.ReadLine(); EmployeeBO bo = new EmployeeBO(); bo.Name = name; bo.Age = int.Parse( age); EmployeeBLL employeeBll = new EmployeeBLL(); employeeBll.Save(bo); Console.WriteLine("Data saved"); }
public List <EmployeeBLL> GetAllEmployeeusersList() { DataTable dt = GetAlluseremployees(); List <EmployeeBLL> empList = new List <EmployeeBLL>(); foreach (DataRow dr in dt.Rows) { EmployeeBLL emp = new EmployeeBLL(); emp.ID = new Guid(dr["Guid"].ToString()); //emp.EmployeeId = dr["EmployeeId"].ToString(); emp.EmployeeName = dr["UserName"].ToString(); emp.Status = Convert.ToInt32(dr["Active"]); empList.Add(emp); } return(empList); }
/// <summary> /// Use this method to facilitate the caching proccess /// </summary> /// <returns></returns> public List <EmployeeBLL> GetAllEmployeeList() { DataTable dt = GetAllEmployees(); List <EmployeeBLL> empList = new List <EmployeeBLL>(); foreach (DataRow dr in dt.Rows) { EmployeeBLL emp = new EmployeeBLL(); emp.ID = new Guid(dr["ID"].ToString()); emp.EmployeeId = dr["EmployeeId"].ToString(); emp.EmployeeName = dr["EmployeeName"].ToString(); emp.Status = int.Parse(dr["Status"].ToString()); empList.Add(emp); } return(empList); }
public static void InitEmpoyeeCache() { DateTime _requestedTime = DateTime.Now; if (EmployeeCacheExpiration == null) { EmployeeCacheExpiration = _requestedTime; } TimeSpan _elapsedTime = _requestedTime.Subtract(EmployeeCacheExpiration.Value); if (EmployeeCache.Count == 0 || _elapsedTime.Minutes >= int.Parse(ConfigurationManager.AppSettings["EmployeeCacheRefreshRate"])) { EmployeeBLL empObj = new EmployeeBLL(); List <EmployeeBLL> newListOfEmp = empObj.GetAllEmployeeusersList(); EmployeeCache = newListOfEmp; //New list assigned to cache EmployeeCacheExpiration = _requestedTime; //Last cache timestamp is updated } }
public void ResolveName() { Guid?preparerGuid = EmployeeBLL.ResolveEmployeeName(this.PreparerName); if (preparerGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.PreparedBy = preparerGuid.Value; } Guid?checkerGuid = EmployeeBLL.ResolveEmployeeName(this.CheckerName); if (checkerGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.CheckedBy = checkerGuid.Value; } Guid?approverGuid = EmployeeBLL.ResolveEmployeeName(this.ApproverName); if (approverGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.ApprovedBy = approverGuid.Value; } if (this.ReceiverName != "") { Guid?receiverGuid = EmployeeBLL.ResolveEmployeeName(this.ReceiverName); if (receiverGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.ReceivedBy = receiverGuid.Value; } } if (this.ArrivalConfirmerName != "") { Guid?arrivalConfirmerGuid = EmployeeBLL.ResolveEmployeeName(this.ArrivalConfirmerName); if (arrivalConfirmerGuid == null) { throw new Exception("No employee found with the specified name!"); } else { this.ArrivalConfirmedBy = arrivalConfirmerGuid.Value; } } }
private void LoadExcel(string path) { try { DataTable dt = null; try { dt = ExcelService.ImportDataTableFromExcel(path, int.Parse(ddl_Name.SelectedItem.Value), 0); } catch { } if (dt != null) { EmployeeBLL iBLL = new EmployeeBLL(); IList<Employee> iList = new List<Employee>(); IList<int> iListErrorRowNumber = new List<int>(); IList<int> iListFailRowNumber = new List<int>(); int _OrganID = Convert.ToInt32(ddl_Organ.SelectedValue); string _InputBy = Session["UserID"].ToString(); int count = 0; int row = 0; foreach (DataRow dr in dt.Rows) { //excel内容 string _UserName = dr["姓名"].ToString(); string _PQ = dr["片区"].ToString(); string _DZ = dr["大组"].ToString(); string _XZ = dr["小组"].ToString(); string _RoleName = dr["梯队任职"].ToString(); string _IsPrivateStr = dr["是否公估"].ToString(); if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PQ) || !ValidateService.IsNumber(_DZ) || string.IsNullOrEmpty(_XZ) || string.IsNullOrEmpty(_RoleName) || string.IsNullOrEmpty(_IsPrivateStr)) { row++; iListErrorRowNumber.Add(row); continue; } bool _isPrivate = _IsPrivateStr == "否" ? false : true; //添加用户 string _userID = AddUser(_UserName, _OrganID); //添加组织 string _PQname = "",_DZname="",_XZname=""; string _PQcode = "",_DZcode="",_XZcode=""; if (_PQ != "0") { _PQname = _PQ + "片区"; _PQcode = AddPosition(_PQname, _OrganID, "市级管理层"); } else { _PQcode = AddPosition("市级管理层", _OrganID, "市级管理层"); } if (_DZ != "0") { _DZname =_PQname + _DZ + "大组"; } _DZcode = AddPosition(_DZname, _OrganID, _PQname); if (_XZ != "0") { if (_DZname != string.Empty) { _XZname = _DZname + _XZ + "小组"; } else { _XZname = _PQname + _XZ + "小组"; } } _XZcode = AddPosition(_XZname, _OrganID, _DZname); string _posiCode = ""; if (!string.IsNullOrEmpty(_PQcode)) { _posiCode = _PQcode; } if (!string.IsNullOrEmpty(_DZcode)) { _posiCode = _DZcode; } if (!string.IsNullOrEmpty(_XZcode)) { _posiCode = _XZcode; } //添加组织关联 if (!string.IsNullOrEmpty(_posiCode)) { List<string> posiList = new List<string>(); posiList.Add(_posiCode); int rePU = new PositionBLL().AddPosi2User(_userID, posiList); } //添加角色 string _roleCode = AddRole(_RoleName, _OrganID); //添加角色关联 if (!string.IsNullOrEmpty(_roleCode)) { List<string> roleList = new List<string>(); roleList.Add(_roleCode); int reRU = new UserBLL().AddRole2User(_userID, roleList); } //添加员工 AddEmployee(_UserName,_OrganID,_isPrivate); count++; } string msg = ""; if (count > 0) { msg = msg + "成功上传数据" + count + "条!"; msg = msg + "\\n"; } if (iListErrorRowNumber.Count > 0) { msg = msg + "数据不全或有误共" + iListErrorRowNumber.Count + "条,请核对以下行号的数据是否有误,并进行修改!"; msg = msg + "\\n 有误行号:"; foreach (int i in iListErrorRowNumber) { msg += i + ","; } msg = msg + "\\n"; } if (iListFailRowNumber.Count > 0) { msg = msg + "车架号已存在共" + iListFailRowNumber.Count + "条!"; msg = msg + "\\n 已存在行号:"; foreach (int i in iListFailRowNumber) { msg += i + ","; } msg = msg + "\\n"; } UtilityService.Alert(this.Page, msg); } } catch (Exception ex) { UtilityService.Alert(this.Page, "导入失败!,详细:" + ex.Message); } }
private void AddEmployee(string name, int organID, bool isPrivate) { EmployeeBLL pBLL = new EmployeeBLL(); int i = 0; string newName = name; while (true) { bool _re = pBLL.Exists(newName, organID); if (_re) { i++; newName = name + i.ToString(); } else { Employee e = new Employee(); e.Name = name; e.IsPrivate = isPrivate; e.JoinDate = null; e.LeaveDate = null; e.OrganID = organID; e.InputBy = Session["UserID"].ToString(); bool re = new EmployeeBLL().Add(e); break; } } }
public ActionResult Save() { Employee employee = new Employee(); try { string stated = Request.Form["stated"]; employee.Id = Convert.ToInt32(Request.Form["Id"]); employee.employeeNo = Request.Form["employeeNo"]; employee.chineseName = Request.Form["chineseName"]; employee.englishName = Request.Form["englishName"]; employee.userName = Request.Form["userName"]; employee.passWord = Request.Form["passWord"]; employee.telPhone = Request.Form["telPhone"]; employee.email = Request.Form["email"]; employee.roleId = Convert.ToInt32(Request.Form["roleId"]); employee.positionId = Convert.ToInt32(Request.Form["positionId"]); employee.branchId = Convert.ToInt32(Request.Form["branchId"]); EmployeeBLL eBll = new EmployeeBLL(); if (stated == "add") { if (eBll.AddEntity(employee)) { return Content("{'success':'ok'}"); } } else if (stated == "update") { if (eBll.ModifyEntity(employee)) { return Content("{'success':'ok'}"); } } } catch { } return Content("{}"); }