//emp是否有权下载此文档 public Boolean ifEmpCanDownlaodThisDoc(int empNumber, int docid) { DocumentModel tempDocModel = new BLLDocument().getDocumentById(docid); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(empNumber); BLLUserAccount bllAccount = new BLLUserAccount(); if (tempDocModel.PublisherNumber.Equals(empNumber)) { return true; } else { switch (tempDocModel.AuthLevel) { //所有人都能看和下载 case 1: return true; //外部的人不能下载 case 2: //外部的人不能看,也不能下载 case 3: if (empModel.DepartmentId.Equals(bllAccount.GetUserByEmpNumber(tempDocModel.PublisherNumber).DepartmentId)) { return true; } return false; //外部的人不能看,也不能下载,内部人只能看不能下载 case 4: return false; } } return false; }
public ActionResult addFavorite(int docid,string returnURL) { string employeeNumber = User.Identity.Name; UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber)); //这里要先判断是否已经收藏过 if (new BLLFavorite().isFavorite(Convert.ToInt32(employeeNumber),docid)) { TempData["errorMsg"] = "您已经收藏过此文档了。"; return RedirectToAction(returnURL, "User"); } BLLDocument bllDocument = new BLLDocument(); DocumentModel docModel = bllDocument.getDocumentById(docid); if (employeeNumber == "" || docModel == null ) { TempData["errorMsg"] = "您无权进行添加收藏操作,请重新登录。"; return RedirectToAction(returnURL, "User"); } if (docModel.PublisherNumber == Convert.ToInt32(employeeNumber)) { TempData["errorMsg"] = "您不能收藏自己发布的文档。"; return RedirectToAction(returnURL, "User"); } BLLFavorite bllFavorite = new BLLFavorite(); if (bllFavorite.addToMyFavorite(Convert.ToInt32(employeeNumber), docid)) { TempData["successMsg"] = "添加成功。"; } else { TempData["errorMsg"] = "添加失败。"; } return RedirectToAction(returnURL, "User"); }
//过滤LIST<DocumentModel>:过滤到emp无权看的文档 public List<DocumentModel> documentFilter(int empNumber, List<DocumentModel> docModelList) { UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(empNumber); List<DocumentModel> newDocModelList = new List<DocumentModel>(); BLLUserAccount bllAccount = new BLLUserAccount(); foreach (DocumentModel tempDocModel in docModelList) { if (tempDocModel.PublisherNumber.Equals(empNumber)) { newDocModelList.Add(tempDocModel); } else { switch (tempDocModel.AuthLevel) { //所有人都能看和下载 case 1: //外部的人不能下载 case 2: newDocModelList.Add(tempDocModel); break; //外部的人不能看,也不能下载 case 3: //外部的人不能看,也不能下载,内部人只能看不能下载 case 4: if (empModel.DepartmentId.Equals(bllAccount.GetUserByEmpNumber(tempDocModel.PublisherNumber).DepartmentId)) { newDocModelList.Add(tempDocModel); } break; } } } return newDocModelList; }
public ActionResult addFolder(int parentId) { int empNumber = Convert.ToInt32(User.Identity.Name); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(empNumber); ViewData["empModel"] = empModel; BLLFolder bllFolder = new BLLFolder(); ViewData["parentFolderModel"] = bllFolder.GetFolderById(parentId); return View(); }
public ActionResult Login(UserEmployeeModel userEmployeeModel) { BLLUserAccount bllUserAccount = new BLLUserAccount(); Boolean result = bllUserAccount.CheckUserLogin(userEmployeeModel); if (result == true) { FormsAuthentication.SetAuthCookie(Convert.ToString(userEmployeeModel.EmployeeNumber), false); return RedirectToAction("Index", "Index"); } else { ViewData["errorMsg"] = "用户名和密码错误"; return View(); } }
public ActionResult Delete(int empNo) { BLLUserAccount bllUserAccount = new BLLUserAccount(); bllUserAccount.GetUserByEmpNumber(empNo); if (bllUserAccount.DeleteUserAccount(bllUserAccount.GetUserByEmpNumber(empNo), bllUserAccount.GetUserDetailByEmpNumber(empNo))) { TempData["successMsg"] = "删除成功。"; } else { TempData["errorMsg"] = "删除失败。"; } return RedirectToAction("Index", "Employee"); }
public ActionResult CreateUser() { ViewData["employeeNumber"] = new BLLUserAccount().GetMaxEmployeeNumber() + 1; IList<DepartmentModel> deptList = new List<DepartmentModel>(); BLLDepartment bllDepartment = new BLLDepartment(); deptList = bllDepartment.GetAllDepartments(); if (deptList.Count == 0) { ViewData["deptList"] = "nodata"; } else { ViewData["deptList"] = deptList; } return View(); }
public ActionResult deleteMultiEmps(string[] selected_emps) { Boolean result = true; BLLUserAccount bllUserAccount = new BLLUserAccount(); foreach (string checkbox in selected_emps) { if (!bllUserAccount.DeleteUserAccount(bllUserAccount.GetUserByEmpNumber(Convert.ToInt32(checkbox)), bllUserAccount.GetUserDetailByEmpNumber(Convert.ToInt32(checkbox)))) { result = false; } } if (result) { TempData["successMsg"] = "删除成功!"; return RedirectToAction("Index", "Employee"); } else { TempData["errorMsg"] = "删除失败!"; return RedirectToAction("Index", "Employee"); } }
public ActionResult Delete(int docid, string returnURL) { //先要判断当前用户是否有权限删除这篇文档 string employeeNumber = User.Identity.Name; BLLDocument bllDocument = new BLLDocument(); DocumentModel docModel = bllDocument.getDocumentById(docid); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber)); //如果是审核者,则直接删除 if (empModel != null && empModel.IsChecker.Equals(true) && docModel.CheckerNumber.Equals(Convert.ToInt32(employeeNumber))) { if (bllDocument.deleteDocumentById(docid)) { TempData["successMsg"] = "删除成功。"; } else { TempData["errorMsg"] = "删除失败。"; } return RedirectToAction(returnURL, "User"); } //如果不是审核者,也不是这篇文档的发布者,删除失败 if (employeeNumber == "" || docModel == null || docModel.PublisherNumber != Convert.ToInt32(employeeNumber)) { TempData["errorMsg"] = "您无权删除此文件,请重新登录。"; return RedirectToAction(returnURL, "User"); } //如果不是审核者,也是这篇文档的发布者,则删除 if (bllDocument.deleteDocumentById(docid)) { TempData["successMsg"] = "删除成功。"; } else { TempData["errorMsg"] = "删除失败。"; } return RedirectToAction(returnURL, "User"); }
public ActionResult CheckedByMe() { int employeeNumber = Convert.ToInt32(User.Identity.Name); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(employeeNumber); ViewData["empModel"] = empModel; BLLDocument bllDocument = new BLLDocument(); UserEmployeeModel userEmployeeModel = new BLLUserAccount().GetUserByEmpNumber(employeeNumber); if (userEmployeeModel.IsChecker.Equals(false)) { //非审核员 return RedirectToAction("Index", "Index"); } List<DocumentModel> docList = new List<DocumentModel>(); docList = new BLLDocument().getHaveCheckedDocByCheckerNumber(employeeNumber); if (docList.Count == 0) { ViewData["docList"] = "nodata"; } else { ViewData["docList"] = docList; } return View(); }
public ActionResult StationImport(HttpPostedFileBase filebase) { BLLUserAccount bllUserAccount = new BLLUserAccount(); HttpPostedFileBase file = Request.Files["files"]; string FileName; string savePath; if (file == null || file.ContentLength <= 0) { ViewData["errorMsg"] = "文件不能为空"; return View(); } else { string filename = Path.GetFileName(file.FileName); int filesize = file.ContentLength;//获取上传文件的大小单位为字节byte string fileEx = System.IO.Path.GetExtension(filename);//获取上传文件的扩展名 string NoFileName = System.IO.Path.GetFileNameWithoutExtension(filename);//获取无扩展名的文件名 int Maxsize = 4000 * 1024;//定义上传文件的最大空间大小为4M string FileType = ".xls,.xlsx,.cvs";//定义上传文件的类型字符串 FileName = NoFileName + DateTime.Now.ToString("yyyyMMddhhmmss") + fileEx; if (!FileType.Contains(fileEx)) { ViewData["errorMsg"] = "文件类型不对,只能导入xls和xlsx格式的文件"; return View(); } if (filesize >= Maxsize) { ViewData["errorMsg"] = "上传文件超过4M,不能上传"; return View(); } string path = AppDomain.CurrentDomain.BaseDirectory + "Content\\uploads\\excel\\"; if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } savePath = Path.Combine(path, FileName); file.SaveAs(savePath); } //string result = string.Empty; string strConn; strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + savePath + ";" + "Extended Properties=Excel 8.0"; OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn); DataSet myDataSet = new DataSet(); try { myCommand.Fill(myDataSet, "ExcelInfo"); } catch (Exception ex) { ViewData["errorMsg"] = ex.Message; return View(); } DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable(); //引用事务机制,出错时,事物回滚 using (TransactionScope transaction = new TransactionScope()) { for (int i = 0; i < table.Rows.Count; i++) { UserEmployeeModel temp = new UserEmployeeModel(); temp.EmployeeNumber = bllUserAccount.GetMaxEmployeeNumber() + 1; temp.Password = "******"; temp.Name = table.Rows[i].ItemArray[0].ToString(); temp.Email = table.Rows[i].ItemArray[1].ToString(); temp.Phone = table.Rows[i].ItemArray[2].ToString(); temp.DepartmentId = Convert.ToInt32(table.Rows[i].ItemArray[3].ToString()); temp.IsManager = (Convert.ToInt32(table.Rows[i].ItemArray[4].ToString()) == 0 ? false : true); temp.IsChecker = (Convert.ToInt32(table.Rows[i].ItemArray[5].ToString()) == 0 ? false : true); temp.IsAvailable = (Convert.ToInt32(table.Rows[i].ItemArray[6].ToString()) == 0 ? false : true); bllUserAccount.CreateUserAccount(temp); } transaction.Complete(); } ViewData["successMsg"] = "导入成功"; System.Threading.Thread.Sleep(2000); return RedirectToAction("Index"); }
public ActionResult Search() { IList<DepartmentModel> deptList = new List<DepartmentModel>(); BLLDepartment bllDepartment = new BLLDepartment(); deptList = bllDepartment.GetAllDepartments(); if (deptList.Count == 0) { ViewData["deptList"] = "nodata"; } else { ViewData["deptList"] = deptList; } int deptId = Convert.ToInt32(Request.Form["dept_name"]); string conditions = Request.Form["search_key"]; BLLUserAccount bllUserAccount = new BLLUserAccount(); List<UserEmployeeModel> empList = new List<UserEmployeeModel>(); List<UserEmployeeModel> resultList = new List<UserEmployeeModel>(); if (deptId == 0) { empList = bllUserAccount.GetAllEmployeeDetails(); } else { empList = bllUserAccount.GetUserDetailsByDeptId(deptId); } if (conditions.Equals("登录名/姓名")) { ViewData["empList"] = empList; return View(); } else { if (isnumeric(conditions)) { foreach (UserEmployeeModel element in empList) { if (element.EmployeeNumber == Convert.ToInt32(conditions)) resultList.Add(element); } ViewData["empList"] = resultList; } else { foreach (UserEmployeeModel element in empList) { if (element.Name == conditions) resultList.Add(element); } ViewData["empList"] = resultList; } return View(); } }
public ActionResult Index() { IList<DepartmentModel> deptList = new List<DepartmentModel>(); BLLDepartment bllDepartment = new BLLDepartment(); deptList = bllDepartment.GetAllDepartments(); if (deptList.Count == 0) { ViewData["deptList"] = "nodata"; } else { ViewData["deptList"] = deptList; } List<UserEmployeeModel> empList = new List<UserEmployeeModel>(); BLLUserAccount bllUserAccount = new BLLUserAccount(); empList = bllUserAccount.GetAllEmployeeDetails(); if (empList.Count == 0) { ViewData["empList"] = "nodata"; } else { ViewData["empList"] = empList; } return View(); }
public ActionResult Edit(int empNo) { IList<DepartmentModel> deptList = new List<DepartmentModel>(); BLLDepartment bllDepartment = new BLLDepartment(); deptList = bllDepartment.GetAllDepartments(); if (deptList.Count == 0) { ViewData["deptList"] = "nodata"; } else { ViewData["deptList"] = deptList; } BLLUserAccount bllUserAccount = new BLLUserAccount(); UserEmployeeModel userEmployeeModel = bllUserAccount.GetSingleUser(empNo); ViewData["id"] = userEmployeeModel.Id; ViewData["employeeNumber"] = userEmployeeModel.EmployeeNumber; ViewData["password"] = userEmployeeModel.Password; ViewData["dept_name"] = userEmployeeModel.DepartmentId; ViewData["isManager"] = userEmployeeModel.IsManager; ViewData["isChecker"] = userEmployeeModel.IsChecker; ViewData["isAvailable"] = userEmployeeModel.IsChecker; ViewData["name"] = userEmployeeModel.Name; ViewData["email"] = userEmployeeModel.Email; ViewData["phone"] = userEmployeeModel.Phone; return View(); }
//部门经理中心首页 //文件夹最多三级 public ActionResult Manager() { int empNumber = Convert.ToInt32(User.Identity.Name); BLLUserAccount bllUserAccount = new BLLUserAccount(); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(empNumber); ViewData["empModel"] = empModel; BLLFolder bllFolder = new BLLFolder(); ViewData["outsideFolderId"] = new BLLDepartment().GetDepartment(empModel.DepartmentId).FolderId; ViewData["outsideFolderName"] = new BLLDepartment().GetDepartment(empModel.DepartmentId).DepartmentName; if (empModel.IsManager.Equals(false)) { //非部门经理 return RedirectToAction("Index", "Index"); } IList<FolderModel> folderModelList = bllFolder.getAllFoldersByDepartmentId(empModel.DepartmentId); if (folderModelList.Count() == 0) { ViewData["folderModelList"] = "nodata"; } else { ViewData["folderModelList"] = folderModelList.ToList<FolderModel>(); } return View(); }
public ActionResult Profile() { int employeeNumber = Convert.ToInt32(User.Identity.Name); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(employeeNumber); UserEmployeeDetailModel empDetailModel = new BLLUserAccount().GetUserDetailByEmpNumber(employeeNumber); ViewData["empModel"] = empModel; ViewData["empDetailModel"] = empDetailModel; return View(); }
public ActionResult Upload() { string employeeNumber = User.Identity.Name; UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber)); ViewData["empModel"] = empModel; return View("DocumentUpload"); }
//根据标签得到doc public ActionResult getDocByTagId(int tagid) { //带权限过滤的 UserEmployeeDetailModel empDetailModel = new BLLUserAccount().GetUserDetailByEmpNumber(Convert.ToInt32(User.Identity.Name)); List<DocumentModel> docList = new BLLDocument().getDocByTagId(empDetailModel.EmployeeNumber,tagid); ViewData["empDetailModel"] = empDetailModel; if (docList.Count == 0) { ViewData["docList"] = "nodata"; } else { ViewData["docList"] = docList; } return View(); }
//显示某人的所有发布的文档 public ActionResult GetDocByEmpployeeNumber(int empno) { //带权限过滤的 List<DocumentModel> docList = new BLLDocument().GetDocByEmpployeeNumber(empno); UserEmployeeDetailModel empDetailModel = new BLLUserAccount().GetUserDetailByEmpNumber(empno); ViewData["empDetailModel"] = empDetailModel; if (docList.Count == 0) { ViewData["docList"] = "nodata"; } else { ViewData["docList"] = docList; } return View(); }
public ActionResult doCreateUser() { BLLUserAccount bllUserAccount = new BLLUserAccount(); UserEmployeeModel userEmployeeModel = new UserEmployeeModel(); UserEmployeeDetailModel userEmployeeDetailModel = new UserEmployeeDetailModel(); userEmployeeModel.EmployeeNumber = bllUserAccount.GetMaxEmployeeNumber() + 1; userEmployeeModel.Password = "******"; userEmployeeModel.DepartmentId = Convert.ToInt32(Request.Form["dept_name"]); userEmployeeModel.IsManager = (Convert.ToInt32(Request.Form["isManager"]) == 0 ? false : true); userEmployeeModel.IsChecker = (Convert.ToInt32(Request.Form["isChecker"]) == 0 ? false : true); userEmployeeModel.IsAvailable = (Convert.ToInt32(Request.Form["isAvailable"]) == 0 ? false : true); userEmployeeModel.Name = Request.Form["name"]; userEmployeeModel.Email = Request.Form["email"]; userEmployeeModel.Phone = Request.Form["phone"]; if (userEmployeeModel.Email == null || !isEmail(userEmployeeModel.Email)) { TempData["employeeNumberErrorMsg"] = "请输入正确的邮箱地址!"; return RedirectToAction("CreateUser", "Employee"); } if (userEmployeeModel.Phone == null ||!isPhone(userEmployeeModel.Phone)) { TempData["phoneErrorMsg"] = "请输入正确的手机号!"; return RedirectToAction("CreateUser", "Employee"); } Boolean result = bllUserAccount.CreateUserAccount(userEmployeeModel); if (result == true) { ViewData["successMsg"] = "添加成功"; return RedirectToAction("Index", "Employee"); } else { ViewData["errorMsg"] = "添加失败"; return RedirectToAction("Index", "Employee"); } }
public void ExportMsg() { List <UserEmployeeModel> emps = new BLLUserAccount().GetAllEmployeeDetails(); DataTable dt = new DataTable(); string strFileName; int cloumns = 8; //生成文件名: 当前年月日小时分钟秒+ 随机数 Random rd = new Random(int.Parse(DateTime.Now.ToString("MMddhhmmss"))); strFileName = DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + rd.Next(999999).ToString() + ".csv"; StringWriter sw = new StringWriter(); string title = string.Empty; string content = string.Empty; string[] titlearray = { "员工号", "姓名", "email", "手机号", "部门id", "是否为经理", "是否为审核员", "是否可用" }; for(int i = 0; i< titlearray.Count(); i++ ) { if (i == 0) title = title + titlearray[i]; else title = title + "," +titlearray[i]; } sw.WriteLine(title); for (int i = 0; i < emps.Count(); i++) { content = content + emps[i].EmployeeNumber.ToString(); content = content + "," + emps[i].Name; content = content + "," + emps[i].Email; content = content + "," + emps[i].Phone; content = content + "," + emps[i].DepartmentId.ToString(); content = content + "," + (emps[i].IsManager == true ? 1 : 0).ToString(); content = content + "," + (emps[i].IsChecker == true ? 1 : 0).ToString(); content = content + "," + (emps[i].IsAvailable == true ? 1 : 0).ToString(); sw.WriteLine(content); content = string.Empty; } sw.Close(); Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(strFileName)); Response.ContentType = "vnd.ms-excel.numberformat:yyyy-MM-dd "; Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.Write(sw); Response.End(); }
public ActionResult doCheck(int docid, string returnURL) { //先要判断当前用户是否有权设置这篇文档 string employeeNumber = User.Identity.Name; BLLDocument bllDocument = new BLLDocument(); DocumentModel docModel = bllDocument.getDocumentById(docid); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber)); //如果不是审核者,则返回错误 if (empModel == null || empModel.IsChecker.Equals(false)) { TempData["errorMsg"] = "您无权操作此文件,请重新登录。"; return RedirectToAction(returnURL, "User"); } //如果是审核者,可以操作 if (bllDocument.setDocCheckedById(docid, Convert.ToInt32(employeeNumber))) { TempData["successMsg"] = "操作成功。"; } else { TempData["errorMsg"] = "操作失败。"; } return RedirectToAction(returnURL, "User"); }
public ActionResult Workshop() { string empno = User.Identity.Name; List<DocumentModel> docList = new List<DocumentModel>(); int employeeNumber = Convert.ToInt32(empno); UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(employeeNumber); ViewData["empModel"] = empModel; docList = new BLLDocument().getMyCheckedDocList(employeeNumber); if (docList.Count == 0) { ViewData["docList"] = "nodata"; } else { ViewData["docList"] = docList; } return View(); }
public ActionResult doEdit() { BLLUserAccount bllUserAccount = new BLLUserAccount(); int id = Convert.ToInt32(Request.Form["id"]); UserEmployeeModel userEmployeeModel = bllUserAccount.GetUserByEmpNumber(Convert.ToInt32(Request.Form["empno"])); if (Convert.ToString(Request.Form["password"]) != null) { userEmployeeModel.Password = Convert.ToString(Request.Form["password"]); } userEmployeeModel.DepartmentId = Convert.ToInt32(Request.Form["dept_name"]); userEmployeeModel.IsManager = (Convert.ToInt32(Request.Form["isManager"]) == 0 ? false : true); userEmployeeModel.IsChecker = (Convert.ToInt32(Request.Form["isChecker"]) == 0 ? false : true); userEmployeeModel.IsAvailable = (Convert.ToInt32(Request.Form["isAvailable"]) == 0 ? false : true); userEmployeeModel.EmployeeNumber = Convert.ToInt32(Request.Form["empno"]); userEmployeeModel.Name = Request.Form["name"]; userEmployeeModel.Email = Request.Form["email"]; userEmployeeModel.Phone = Request.Form["phone"]; if (userEmployeeModel.Email == "" || !isEmail(userEmployeeModel.Email)) { TempData["employeeNumberErrorMsg"] = "请输入正确的邮箱地址!"; return RedirectToAction("Edit", "Employee", userEmployeeModel.EmployeeNumber); } if (userEmployeeModel.Phone == "" || !isPhone(userEmployeeModel.Phone)) { TempData["phoneErrorMsg"] = "请输入正确的手机号!"; return RedirectToAction("Edit", "Employee", userEmployeeModel.EmployeeNumber); } Boolean result = bllUserAccount.UpdateUserAccount(userEmployeeModel); if (result == true) { ViewData["successMsg"] = "修改成功"; return RedirectToAction("Index", "Employee"); } else { ViewData["errorMsg"] = "修改失败"; return RedirectToAction("Index", "Employee"); } }
public ActionResult DeleteFavorite(int docid) { string employeeNumber = User.Identity.Name; UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber)); ViewData["empModel"] = empModel; BLLDocument bllDocument = new BLLDocument(); DocumentModel docModel = bllDocument.getDocumentById(docid); if (employeeNumber == "" || docModel == null || docModel.PublisherNumber != Convert.ToInt32(employeeNumber)) { TempData["errorMsg"] = "您无权进行删除操作,请重新登录。"; return RedirectToAction("MyFavorite", "User"); } BLLFavorite bllFavorite = new BLLFavorite(); if (bllFavorite.deleteMyFavorite(Convert.ToInt32(employeeNumber),docid)) { TempData["successMsg"] = "删除成功。"; } else { TempData["errorMsg"] = "删除失败。"; } return RedirectToAction("MyFavorite", "User"); }