/// <summary> /// 获取人员列表 /// </summary> /// <param name="model">查询参数实体</param> /// <returns>返回人员列表集合</returns> public List <E_tb_InPersonnel> GetList(E_tb_InPersonnel model) { List <E_tb_InPersonnel> list = new List <E_tb_InPersonnel>(); //拼接查询条件 StringBuilder strwhere = new StringBuilder(); strwhere.AddWhere($"isdelete=0"); //未删除数据 if (model.AreaID > 0) //区域ID { strwhere.AddWhere($"AreaID={model.AreaID}"); } //主查询Sql StringBuilder search = new StringBuilder(); search.AppendFormat(@"select * from tb_InPersonnel {0} ", strwhere.ToString()); //执行查询语句 using (IDbConnection conn = new SqlConnection(PubConstant.GetConnectionString())) { list = conn.Query <E_tb_InPersonnel>(search.ToString(), model)?.ToList(); } return(list); }
/// <summary> /// 根本登陆用户ID和文件ID查找权限 /// 作者:章建国 /// </summary> /// <param name="_fileid"></param> /// <returns></returns> public JsonResult GetLimitByUserIDandFileID(string _fileid) { try { tb_Limit _limit = null; E_tb_InPersonnel _inpersonnel = Session["UserInfo"] as Model.PersonnelManage.E_tb_InPersonnel; tb_LimitBLL _limitBLL = new tb_LimitBLL(); string where = string.Format(" limitId = {0} and fileId = {1} and limitType = '用户'", _inpersonnel.PersonnelID, _fileid); var limitList = _limitbll.GetModelList(where); if (limitList != null && limitList.Count > 0) { _limit = limitList[0]; } else { where = string.Format(" limitId = {0} and fileId = {1} and limitType = '用户组'", _inpersonnel.AreaID, _fileid); limitList = _limitbll.GetModelList(where); if (limitList != null && limitList.Count > 0) { _limit = limitList[0]; } } return(Json(_limit, JsonRequestBehavior.AllowGet)); } catch { return(Json("", JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 保存信息 /// 作者:小朱 /// </summary> /// <param name="eInPersonnel">要处理的对象</param> /// <returns>返回是否处理成功</returns> public string Save(E_tb_InPersonnel eInPersonnel) { string msg = "0"; if (eInPersonnel.EditType == "Add") { eInPersonnel.PersonnelID = tInPersonnel.Add(eInPersonnel); E_tb_UserRole eUserRole = new E_tb_UserRole(); eUserRole.RoleID = eInPersonnel.RoleID; eUserRole.PersonnelID = eInPersonnel.PersonnelID; tUserRole.Add(eUserRole); msg = "1"; } else { tInPersonnel.Update(eInPersonnel); tUserRole.DeleteByWhere("PersonnelID=" + eInPersonnel.PersonnelID); E_tb_UserRole eUserRole = new E_tb_UserRole(); eUserRole.RoleID = eInPersonnel.RoleID; eUserRole.PersonnelID = eInPersonnel.PersonnelID; tUserRole.Add(eUserRole); msg = "1"; } return(msg); }
/// <summary> /// 判断用户输入的信息是否正确,[HttpPost] /// </summary> /// <param name="UserName">用户名</param> /// <param name="userInfo">用户的实体类</param> /// <param name="Code">验证码</param> /// <returns>返回是否执行成功的标志</returns> public ActionResult CheckUserInfo(string UserName, E_tb_InPersonnel userInfo, string Code) { /* * //首先我们拿到系统的验证码 * string sessionCode = this.TempData["ValidateCode"] == null * ? new Guid().ToString() * : this.TempData["ValidateCode"].ToString(); * //然后我们就将验证码去掉,避免了暴力破解 * this.TempData["ValidateCode"] = new Guid(); * //判断用户输入的验证码是否正确 * if (sessionCode != Code) * { * return Content("验证码输入不正确"); * } */ //调用业务逻辑层(BLL)去校验用户是否正确,,,定义变量存取获取到的用户的错误信息 string UserInfoError = ""; E_tb_InPersonnel eInPersonnel = tInPersonnel.Login(userInfo.UserName, userInfo.PassWord); if (eInPersonnel != null) { Session["UserInfo"] = eInPersonnel; FormsAuthentication.SetAuthCookie(eInPersonnel.UserName, false); UserInfoError = "OK"; } else { UserInfoError = "用户名或密码错误"; } return(Content(UserInfoError)); }
/// <summary> /// 判断用户输入的信息是否正确,[HttpPost] /// </summary> /// <param name="UserName">用户名</param> /// <param name="userInfo">用户的实体类</param> /// <param name="Code">验证码</param> /// <returns>返回是否执行成功的标志</returns> public ActionResult CheckUserInfo(string UserName, E_tb_InPersonnel userInfo, string Code) { //调用业务逻辑层(BLL)去校验用户是否正确,,,定义变量存取获取到的用户的错误信息 string UserInfoError = ""; E_tb_InPersonnel eInPersonnel = tInPersonnel.Login(userInfo.UserName, userInfo.PassWord); if (eInPersonnel != null) { Session["UserInfo"] = eInPersonnel; //添加登陆Cookies 若出入安全考虑应该进行加密处理 HttpCookie cookie = new HttpCookie("lims.userinfo"); cookie["passport"] = Utils.Md5(eInPersonnel.PersonnelID.ToString() + eInPersonnel.UserName.ToString() + eInPersonnel.PassWord.ToString(), 32); cookie["uid"] = eInPersonnel.PersonnelID.ToString(); cookie["personnelname"] = HttpUtility.UrlEncode(eInPersonnel.PersonnelName); cookie["rolename"] = HttpUtility.UrlEncode(eInPersonnel.rolename); cookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(cookie); FormsAuthentication.SetAuthCookie(eInPersonnel.UserName, false); UserInfoError = "OK"; } else { UserInfoError = "用户名或密码错误"; } return(Content(UserInfoError)); }
/// <summary> /// 重新基类在Action执行之前的事情 /// </summary> /// <param name="filterContext">重写方法的参数</param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); //得到用户登录的信息 CurrentUserInfo = Session["UserInfo"] as E_tb_InPersonnel; //判断用户是否为空 if (CurrentUserInfo == null) { Response.Redirect("/Login/Login"); } //权限按钮控制 T_tb_Action tAction = new T_tb_Action(); T_tb_UserRole tUserRole = new T_tb_UserRole(); T_tb_RoleAction tRoleAction = new T_tb_RoleAction(); //获取用户对应角色 List <E_tb_UserRole> UserRoleList = new List <E_tb_UserRole>(); if (CurrentUserInfo != null) { UserRoleList = tUserRole.GetModelList("PersonnelID=" + CurrentUserInfo.PersonnelID); } string RoleIDS = ""; UserRoleList.ForEach(p => { RoleIDS += p.RoleID + ","; }); RoleIDS = RoleIDS.TrimEnd(','); if (CurrentUserInfo != null) { CurrentUserInfo.RoleIDS = RoleIDS; if (RoleIDS.IndexOf(',') < 0) { CurrentUserInfo.RoleID = Convert.ToInt32(RoleIDS); } } //获取角色对应操作 List <E_tb_RoleAction> RoleActionList = new List <E_tb_RoleAction>(); if (RoleIDS.Length > 0) { RoleActionList = tRoleAction.GetModelList("RoleID in (" + RoleIDS + ")"); } //加载所有权限代码 List <E_tb_Action> ActionList = tAction.GetModelList(""); ActionList.ForEach(p => { ViewData[p.ActionCode] = (RoleActionList.Where(o => o.ActionID == p.ActionID).Count() > 0); //ViewData[p.ActionCode] =true; }); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(E_tb_InPersonnel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_InPersonnel("); strSql.Append("AreaID,PersonnelName,Department,Sex,Birthday,Educational,Title,Post,WorkingTime,Description,Tel,CID,UserName,PassWord)"); strSql.Append(" values ("); strSql.Append("@AreaID,@PersonnelName,@Department,@Sex,@Birthday,@Educational,@Title,@Post,@WorkingTime,@Description,@Tel,@CID,@UserName,@PassWord)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@AreaID", SqlDbType.Int, 4), new SqlParameter("@PersonnelName", SqlDbType.NVarChar, 50), new SqlParameter("@Department", SqlDbType.NVarChar, 50), new SqlParameter("@Sex", SqlDbType.NVarChar, 50), new SqlParameter("@Birthday", SqlDbType.DateTime), new SqlParameter("@Educational", SqlDbType.NVarChar, 50), new SqlParameter("@Title", SqlDbType.NVarChar, 50), new SqlParameter("@Post", SqlDbType.NVarChar, 50), new SqlParameter("@WorkingTime", SqlDbType.NVarChar, 50), new SqlParameter("@Description", SqlDbType.Text), new SqlParameter("@Tel", SqlDbType.NVarChar, 50), new SqlParameter("@CID", SqlDbType.NVarChar, 50), new SqlParameter("@UserName", SqlDbType.NVarChar, 50), new SqlParameter("@PassWord", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.AreaID; parameters[1].Value = model.PersonnelName; parameters[2].Value = model.Department; parameters[3].Value = model.Sex; parameters[4].Value = model.Birthday; parameters[5].Value = model.Educational; parameters[6].Value = model.Title; parameters[7].Value = model.Post; parameters[8].Value = model.WorkingTime; parameters[9].Value = model.Description; parameters[10].Value = model.Tel; parameters[11].Value = model.CID; parameters[12].Value = model.UserName; parameters[13].Value = model.PassWord; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 用户登录验证 /// </summary> public E_tb_InPersonnel Login(string UserName, string PassWord) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 A.*,C.DataRange,C.RoleName from tb_InPersonnel as A join tb_UserRole as B on A.PersonnelID=B.PersonnelID join tb_Role as C on B.RoleID=C.RoleID"); strSql.Append(" where A.isdelete=0 and A.UserName=@UserName and A.PassWord=@PassWord"); E_tb_InPersonnel model = null; using (IDbConnection conn = new SqlConnection(PubConstant.GetConnectionString())) { model = conn.Query <E_tb_InPersonnel>(strSql.ToString(), new { UserName = UserName, PassWord = PassWord })?.FirstOrDefault(); } return(model); }
/// <summary> /// 显示详情页 /// </summary> /// <param name="EditType">编辑类型</param> /// <returns>返回编辑结果</returns> public ActionResult InPersonnelEdit(E_tb_InPersonnel eInPersonnel, string EditType, int?InfoID) { ViewData["SexList"] = GetSexList(); ViewData["RoleList"] = GetRoleList(); ViewData["AreaList"] = GetAreaList(); ViewBag.PassWord = ""; if (EditType == "Edit") { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(InfoID)); E_tb_UserRole eUserRole = tUserRole.GetModelList("PersonnelID=" + eInPersonnel.PersonnelID).FirstOrDefault(); if (eUserRole != null) { eInPersonnel.RoleID = eUserRole.RoleID; } ViewBag.PassWord = eInPersonnel.PassWord; } eInPersonnel.EditType = EditType; return(View(eInPersonnel)); }
/// <summary> /// 保存实验室信息 /// 作者:小朱 /// </summary> /// <param name="eDetectProject">要处理的对象</param> /// <returns>返回是否处理成功</returns> public string Save(E_tb_DetectProject eDetectProject) { string msg = "0"; eDetectProject.ProjectName = tProject.GetModel(int.Parse(eDetectProject.RelationProjectID.ToString())).ProjectName; //项目名称 E_tb_InPersonnel eInPersonnel = tInPersonnel.GetModel(int.Parse(eDetectProject.HeadPersonnelID.ToString())); //负责人名称 eDetectProject.MainPerson = eInPersonnel.PersonnelName; //联系电话 eDetectProject.Tel = eInPersonnel.Tel; if (eDetectProject.EditType == "Add") { tDetectProject.Add(eDetectProject); msg = "1"; } else { tDetectProject.Update(eDetectProject); msg = "1"; } return(msg); }
/// <summary> /// 获得数据列表 /// </summary> public List <E_tb_InPersonnel> DataTableToList(DataTable dt) { List <E_tb_InPersonnel> modelList = new List <E_tb_InPersonnel>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { E_tb_InPersonnel model; for (int n = 0; n < rowsCount; n++) { model = new E_tb_InPersonnel(); if (dt.Rows[n]["PersonnelID"].ToString() != "") { model.PersonnelID = int.Parse(dt.Rows[n]["PersonnelID"].ToString()); } if (dt.Rows[n]["AreaID"].ToString() != "") { model.AreaID = int.Parse(dt.Rows[n]["AreaID"].ToString()); } model.PersonnelName = dt.Rows[n]["PersonnelName"].ToString(); model.Department = dt.Rows[n]["Department"].ToString(); model.Sex = dt.Rows[n]["Sex"].ToString(); if (dt.Rows[n]["Birthday"].ToString() != "") { model.Birthday = DateTime.Parse(dt.Rows[n]["Birthday"].ToString()); } model.Educational = dt.Rows[n]["Educational"].ToString(); model.Title = dt.Rows[n]["Title"].ToString(); model.Post = dt.Rows[n]["Post"].ToString(); model.WorkingTime = dt.Rows[n]["WorkingTime"].ToString(); model.Description = dt.Rows[n]["Description"].ToString(); model.Tel = dt.Rows[n]["Tel"].ToString(); model.CID = dt.Rows[n]["CID"].ToString(); model.UserName = dt.Rows[n]["UserName"].ToString(); model.PassWord = dt.Rows[n]["PassWord"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(E_tb_InPersonnel model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_tb_InPersonnel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_InPersonnel set "); strSql.Append("AreaID=@AreaID,"); strSql.Append("PersonnelName=@PersonnelName,"); strSql.Append("Department=@Department,"); strSql.Append("Sex=@Sex,"); strSql.Append("Birthday=@Birthday,"); strSql.Append("Educational=@Educational,"); strSql.Append("Title=@Title,"); strSql.Append("Post=@Post,"); strSql.Append("WorkingTime=@WorkingTime,"); strSql.Append("Description=@Description,"); strSql.Append("Tel=@Tel,"); strSql.Append("CID=@CID,"); strSql.Append("UserName=@UserName,"); strSql.Append("PassWord=@PassWord"); strSql.Append(" where PersonnelID=@PersonnelID"); SqlParameter[] parameters = { new SqlParameter("@AreaID", SqlDbType.Int, 4), new SqlParameter("@PersonnelName", SqlDbType.NVarChar, 50), new SqlParameter("@Department", SqlDbType.NVarChar, 50), new SqlParameter("@Sex", SqlDbType.NVarChar, 50), new SqlParameter("@Birthday", SqlDbType.DateTime), new SqlParameter("@Educational", SqlDbType.NVarChar, 50), new SqlParameter("@Title", SqlDbType.NVarChar, 50), new SqlParameter("@Post", SqlDbType.NVarChar, 50), new SqlParameter("@WorkingTime", SqlDbType.NVarChar, 50), new SqlParameter("@Description", SqlDbType.Text), new SqlParameter("@Tel", SqlDbType.NVarChar, 50), new SqlParameter("@CID", SqlDbType.NVarChar, 50), new SqlParameter("@UserName", SqlDbType.NVarChar, 50), new SqlParameter("@PassWord", SqlDbType.NVarChar, 50), new SqlParameter("@PersonnelID", SqlDbType.Int, 4) }; parameters[0].Value = model.AreaID; parameters[1].Value = model.PersonnelName; parameters[2].Value = model.Department; parameters[3].Value = model.Sex; parameters[4].Value = model.Birthday; parameters[5].Value = model.Educational; parameters[6].Value = model.Title; parameters[7].Value = model.Post; parameters[8].Value = model.WorkingTime; parameters[9].Value = model.Description; parameters[10].Value = model.Tel; parameters[11].Value = model.CID; parameters[12].Value = model.UserName; parameters[13].Value = model.PassWord; parameters[14].Value = model.PersonnelID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 重新基类在Action执行之前的事情 /// </summary> /// <param name="filterContext">重写方法的参数</param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); //得到用户登录的信息 CurrentUserInfo = Session["UserInfo"] as E_tb_InPersonnel; //判断用户是否为空 if (CurrentUserInfo == null) { if (HttpContext.Request.Cookies["lims.userinfo"] == null || string.IsNullOrEmpty(HttpContext.Request.Cookies["lims.userinfo"].Value)) { filterContext.Result = new RedirectResult("/Login/login"); } else { HttpCookie cookie = HttpContext.Request.Cookies.Get("lims.userinfo"); string passportinfo = cookie["passport"].ToString(); int uid = Convert.ToInt32(cookie["uid"]); E_tb_InPersonnel eInPersonnel = new T_tb_InPersonnel().GetModel(uid); if (passportinfo == Utils.Md5(eInPersonnel.PersonnelID + eInPersonnel.UserName + eInPersonnel.PassWord)) { CurrentUserInfo = new T_tb_InPersonnel().Login(eInPersonnel.UserName, eInPersonnel.PassWord); filterContext.HttpContext.Session["UserInfo"] = CurrentUserInfo; } else { filterContext.Result = new RedirectResult("/Login/login"); } } } //权限按钮控制 T_tb_Action tAction = new T_tb_Action(); T_tb_UserRole tUserRole = new T_tb_UserRole(); T_tb_RoleAction tRoleAction = new T_tb_RoleAction(); //获取用户对应角色 List <E_tb_UserRole> UserRoleList = new List <E_tb_UserRole>(); if (CurrentUserInfo != null) { UserRoleList = tUserRole.GetModelList("PersonnelID=" + CurrentUserInfo.PersonnelID); } string RoleIDS = ""; UserRoleList.ForEach(p => { RoleIDS += p.RoleID + ","; }); RoleIDS = RoleIDS.TrimEnd(','); if (CurrentUserInfo != null) { CurrentUserInfo.RoleIDS = RoleIDS; if (RoleIDS.IndexOf(',') < 0) { CurrentUserInfo.RoleID = Convert.ToInt32(RoleIDS); } } //获取角色对应操作 List <E_tb_RoleAction> RoleActionList = new List <E_tb_RoleAction>(); if (RoleIDS.Length > 0) { RoleActionList = tRoleAction.GetModelList("RoleID in (" + RoleIDS + ")"); } //加载所有权限代码 List <E_tb_Action> ActionList = tAction.GetModelList(""); ActionList.ForEach(p => { ViewData[p.ActionCode] = (RoleActionList.Where(o => o.ActionID == p.ActionID).Count() > 0); //ViewData[p.ActionCode] =true; }); }
/// <summary> /// 用户登录验证 /// </summary> public E_tb_InPersonnel Login(string UserName, string PassWord) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 A.*,C.DataRange from tb_InPersonnel as A join tb_UserRole as B on A.PersonnelID=B.PersonnelID join tb_Role as C on B.RoleID=C.RoleID"); strSql.Append(" where A.UserName=@UserName and A.PassWord=@PassWord"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.NVarChar, 50), new SqlParameter("@PassWord", SqlDbType.NVarChar, 50) }; parameters[0].Value = UserName; parameters[1].Value = PassWord; E_tb_InPersonnel model = new E_tb_InPersonnel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PersonnelID"].ToString() != "") { model.PersonnelID = int.Parse(ds.Tables[0].Rows[0]["PersonnelID"].ToString()); } if (ds.Tables[0].Rows[0]["AreaID"].ToString() != "") { model.AreaID = int.Parse(ds.Tables[0].Rows[0]["AreaID"].ToString()); } if (ds.Tables[0].Rows[0]["PersonnelName"] != null) { model.PersonnelName = ds.Tables[0].Rows[0]["PersonnelName"].ToString(); } if (ds.Tables[0].Rows[0]["Department"] != null) { model.Department = ds.Tables[0].Rows[0]["Department"].ToString(); } if (ds.Tables[0].Rows[0]["Sex"] != null) { model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString(); } if (ds.Tables[0].Rows[0]["Birthday"].ToString() != "") { model.Birthday = DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString()); } if (ds.Tables[0].Rows[0]["Educational"] != null) { model.Educational = ds.Tables[0].Rows[0]["Educational"].ToString(); } if (ds.Tables[0].Rows[0]["Title"] != null) { model.Title = ds.Tables[0].Rows[0]["Title"].ToString(); } if (ds.Tables[0].Rows[0]["Post"] != null) { model.Post = ds.Tables[0].Rows[0]["Post"].ToString(); } if (ds.Tables[0].Rows[0]["WorkingTime"] != null) { model.WorkingTime = ds.Tables[0].Rows[0]["WorkingTime"].ToString(); } if (ds.Tables[0].Rows[0]["Description"] != null) { model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); } if (ds.Tables[0].Rows[0]["Tel"] != null) { model.Tel = ds.Tables[0].Rows[0]["Tel"].ToString(); } if (ds.Tables[0].Rows[0]["CID"] != null) { model.CID = ds.Tables[0].Rows[0]["CID"].ToString(); } if (ds.Tables[0].Rows[0]["UserName"] != null) { model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString(); } if (ds.Tables[0].Rows[0]["PassWord"] != null) { model.PassWord = ds.Tables[0].Rows[0]["PassWord"].ToString(); } if (ds.Tables[0].Rows[0]["DataRange"].ToString() != "") { model.DataRange = int.Parse(ds.Tables[0].Rows[0]["DataRange"].ToString()); } return(model); } else { return(null); } }
T_tb_Area tArea = new T_tb_Area(); //区域/单位 public ActionResult TestReportView(E_tb_TestReport eTestReport) { ViewData["ReportDataList"] = tTestReportData.GetList("ReportID=" + eTestReport.ReportID).Tables[0]; //检验数据 eTestReport = tTestReport.GetModel(eTestReport.ReportID); E_tb_TypeDict eTypeDict = tTypeDict.GetModel(Convert.ToInt32(eTestReport.TestType)); eTestReport.TestTypeName = (eTypeDict != null ? eTypeDict.TypeName : ""); E_tb_InPersonnel eInPersonnel = new E_tb_InPersonnel(); if (eTestReport.ApprovalPersonnelID != null && eTestReport.ApprovalPersonnelID > 0) { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(eTestReport.ApprovalPersonnelID)); if (eInPersonnel != null) { eTestReport.ApprovalPersonnelName = eInPersonnel.PersonnelName; } } if (eTestReport.examinePersonnelID != null && eTestReport.examinePersonnelID > 0) { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(eTestReport.examinePersonnelID)); if (eInPersonnel != null) { eTestReport.examinePersonnelName = eInPersonnel.PersonnelName; } } if (eTestReport.MainTestPersonnelID != null && eTestReport.MainTestPersonnelID > 0) { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(eTestReport.MainTestPersonnelID)); if (eInPersonnel != null) { eTestReport.MainTestPersonnelName = eInPersonnel.PersonnelName; } } //eTestReport.SampleName = Regex.Replace(eTestReport.SampleName, @"[^\u4e00-\u9fa5]", ""); if (eTestReport.SampleName.ToString().IndexOf(')') > -1) { eTestReport.SampleName = eTestReport.SampleName.ToString().Substring(0, eTestReport.SampleName.ToString().IndexOf(')') + 1); } else if (eTestReport.SampleName.ToString().IndexOf(')') > -1) { eTestReport.SampleName = eTestReport.SampleName.ToString().Substring(0, eTestReport.SampleName.ToString().IndexOf(')') + 1); } else { eTestReport.SampleName = Regex.Replace(eTestReport.SampleName, @"[^\u4e00-\u9fa5|(|)]", ""); } var sampleModel = new BLL.tb_SampleBLL().GetModelList(" sampleNum = '" + eTestReport.SampleNum + "'").FirstOrDefault(); ViewBag._cydw = "none"; ViewBag._sydw = "none"; ViewBag._scjdw = ""; if (sampleModel != null) { if (sampleModel.isDetection) { eTestReport.ToSampleMode = "抽样"; ViewBag._cydw = ""; ViewBag._scjdw = eTestReport.SamplingCompany; eTestReport.Department = "/"; } else { eTestReport.ToSampleMode = "送样"; ViewBag._sydw = ""; eTestReport.SamplingCompany = "/"; ViewBag._scjdw = eTestReport.Department; } } if (String.IsNullOrEmpty(eTestReport.Specifications)) { eTestReport.Specifications = "/"; } if (String.IsNullOrEmpty(eTestReport.Packing)) { eTestReport.Packing = "/"; } if (String.IsNullOrEmpty(eTestReport.productNum)) { eTestReport.productNum = "/"; } ViewBag._IssuedTime = ""; if (eTestReport.IssuedTime != null) { ViewBag._IssuedTime = eTestReport.IssuedTime.Value.ToString("yyyy/MM/dd"); } var _orlist = new BLL.OriginalRecord.T_tb_OriginalRecord().GetModelList(" RecordID in (" + eTestReport.RecordIDS + ")"); String _projectIds = ""; int _tempProjectId = 0; for (int i = 0; i < _orlist.Count; i++) { if (_tempProjectId == _orlist[i].ProjectID) { continue; } if (String.IsNullOrEmpty(_projectIds)) { _projectIds = _orlist[i].ProjectID.ToString(); } else { _projectIds += "," + _orlist[i].ProjectID.ToString(); } } eTestReport.TestBasis = ""; var _projectlist = new BLL.Laboratory.T_tb_Project().GetModelList(" ProjectID in (" + _projectIds + ")"); foreach (var item in _projectlist) { if (String.IsNullOrEmpty(eTestReport.TestBasis)) { eTestReport.TestBasis = item.ExpeMethod; } else { eTestReport.TestBasis += "," + item.ExpeMethod; } } ViewBag.AreaName = tArea.GetModel(int.Parse(eTestReport.AreaID.ToString())).TestReportName; return(View(eTestReport)); }
/// <summary> /// 得到一个对象实体 /// </summary> public E_tb_InPersonnel GetModel(int PersonnelID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PersonnelID,AreaID,PersonnelName,Department,Sex,Birthday,Educational,Title,Post,WorkingTime,Description,Tel,CID,UserName,PassWord from tb_InPersonnel "); strSql.Append(" where PersonnelID=@PersonnelID"); SqlParameter[] parameters = { new SqlParameter("@PersonnelID", SqlDbType.Int, 4) }; parameters[0].Value = PersonnelID; E_tb_InPersonnel model = new E_tb_InPersonnel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PersonnelID"].ToString() != "") { model.PersonnelID = int.Parse(ds.Tables[0].Rows[0]["PersonnelID"].ToString()); } if (ds.Tables[0].Rows[0]["AreaID"].ToString() != "") { model.AreaID = int.Parse(ds.Tables[0].Rows[0]["AreaID"].ToString()); } if (ds.Tables[0].Rows[0]["PersonnelName"] != null) { model.PersonnelName = ds.Tables[0].Rows[0]["PersonnelName"].ToString(); } if (ds.Tables[0].Rows[0]["Department"] != null) { model.Department = ds.Tables[0].Rows[0]["Department"].ToString(); } if (ds.Tables[0].Rows[0]["Sex"] != null) { model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString(); } if (ds.Tables[0].Rows[0]["Birthday"].ToString() != "") { model.Birthday = DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString()); } if (ds.Tables[0].Rows[0]["Educational"] != null) { model.Educational = ds.Tables[0].Rows[0]["Educational"].ToString(); } if (ds.Tables[0].Rows[0]["Title"] != null) { model.Title = ds.Tables[0].Rows[0]["Title"].ToString(); } if (ds.Tables[0].Rows[0]["Post"] != null) { model.Post = ds.Tables[0].Rows[0]["Post"].ToString(); } if (ds.Tables[0].Rows[0]["WorkingTime"] != null) { model.WorkingTime = ds.Tables[0].Rows[0]["WorkingTime"].ToString(); } if (ds.Tables[0].Rows[0]["Description"] != null) { model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); } if (ds.Tables[0].Rows[0]["Tel"] != null) { model.Tel = ds.Tables[0].Rows[0]["Tel"].ToString(); } if (ds.Tables[0].Rows[0]["CID"] != null) { model.CID = ds.Tables[0].Rows[0]["CID"].ToString(); } if (ds.Tables[0].Rows[0]["UserName"] != null) { model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString(); } if (ds.Tables[0].Rows[0]["PassWord"] != null) { model.PassWord = ds.Tables[0].Rows[0]["PassWord"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 显示详情页 /// </summary> /// <param name="EditType">编辑类型</param> /// <returns>返回编辑结果</returns> public ActionResult TestReportEdit(E_tb_TestReport eTestReport, string EditType, int?InfoID) { //ViewData["RecordList"] = tOriginalRecord.GetList("").Tables[0]; ViewData["_abclist"] = PageTools.GetSelectList(tTypeDict.GetList("SubjectID=5").Tables[0], "TypeID", "TypeName", false); ViewData["RecordSelect"] = new DataTable(); ViewData["ReportDataList"] = new DataTable(); ViewBag._userName = CurrentUserInfo.UserName; if (EditType == "Edit") { eTestReport = tTestReport.GetModel(Convert.ToInt32(InfoID)); //ViewData["RecordList"] = tOriginalRecord.GetList("RecordID not in (" + eTestReport.RecordIDS + ")").Tables[0]; //ViewData["RecordSelect"] = tOriginalRecord.GetList("RecordID in (" + eTestReport.RecordIDS + ")").Tables[0]; ViewData["ReportDataList"] = tTestReportData.GetList("ReportID=" + eTestReport.ReportID).Tables[0]; //检验数据 E_tb_InPersonnel eInPersonnel = null; if (eTestReport.ApprovalPersonnelID != null && eTestReport.ApprovalPersonnelID > 0) { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(eTestReport.ApprovalPersonnelID)); eTestReport.ApprovalPersonnelName = (eInPersonnel != null ? eInPersonnel.PersonnelName : ""); } if (eTestReport.examinePersonnelID != null && eTestReport.examinePersonnelID > 0) { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(eTestReport.examinePersonnelID)); eTestReport.examinePersonnelName = (eInPersonnel != null ? eInPersonnel.PersonnelName : ""); } if (eTestReport.MainTestPersonnelID != null && eTestReport.MainTestPersonnelID > 0) { eInPersonnel = tInPersonnel.GetModel(Convert.ToInt32(eTestReport.MainTestPersonnelID)); eTestReport.MainTestPersonnelName = (eInPersonnel != null ? eInPersonnel.PersonnelName : ""); } if (string.IsNullOrEmpty(eTestReport.Explain)) { eTestReport.Explain = @" 一、 本检验报告复印、涂改无效;封面未加盖检验专用章和无检验专用骑缝章(如2页以上)的检验报告无效。<br/> 二、 检验报告仅对送检、抽检样品负责。<br/> 三、 本检验报告及检验单位名称不得用于产品的标签、广告评优及商品宣传等。<br/> 四、 本检验报告一式二份,一份由检验单位存档,一份交送检、抽检单位。<br/> 五、 本检验报告由出具报告单位负责,并进行解释说明。<br/> 六、 检验单位保存该检验报告6年。<br/><br/>" ; if (eTestReport.MainTestPersonnelID > 0) { try { eInPersonnel = tInPersonnel.GetModel(eTestReport.MainTestPersonnelID.Value); var _areaid = (eInPersonnel != null ? eInPersonnel.AreaID : 0); if (_areaid > 0) { switch (_areaid) { case 2: { eTestReport.Explain += @"食品检测中心<br/> 检验单位地址:天津市塘沽区东沽石油新村配餐采购加工中心院内<br/> 邮政编码:300452<br/> 联系电话:022-66917343<br/> 传真:022-66917343<br/><br/>"; break; } case 3: { eTestReport.Explain += @"食品检测中心(葫芦岛)<br/> 检验单位地址:辽宁省葫芦岛市龙港区北港码头配餐公司葫芦岛配送基地<br/> 邮政编码:125000<br/> 联系电话:0429-2080522<br/> 传真:0429-2082522<br/><br/>"; break; } case 4: { eTestReport.Explain += @"食品检测中心(深圳)<br/> 检验单位地址:广东省惠州市大亚湾区石化大道中滨海十二路9号惠州物流基地W18<br/> 邮政编码:516082<br/> 联系电话:0752-5952819<br/> 传真:0752-5952818<br/><br/>"; break; } case 5: { eTestReport.Explain += @"食品检测中心(湛江)<br/> 检验单位地址:广东省湛江市坡头区南油一区配餐服务公司湛江分公司<br/> 邮政编码:524057<br/> 联系电话:0759-3910316<br/> 传真:0759-3901145<br/><br/>"; break; } case 6: { eTestReport.Explain += @"食品检测中心(龙口)<br/> 检验单位地址::山东省烟台市龙口市环海中路中海油物流码头配餐公司龙口配送基地<br/> 邮政编码:265700<br/> 联系电话:0535-8838131<br/> 传真:0535-8838131<br/><br/>"; break; } } } } catch { } } } } ViewBag.SampleName = eTestReport.SampleName; if (eTestReport.SampleName.ToString().IndexOf(')') > -1) { ViewBag.SampleName = eTestReport.SampleName.ToString().Substring(0, eTestReport.SampleName.ToString().IndexOf(')') + 1); } else { ViewBag.SampleName = Regex.Replace(ViewBag.SampleName, @"[^\u4e00-\u9fa5|(|)]", ""); } ViewBag.AreaName = tArea.GetModel(int.Parse(eTestReport.AreaID.ToString())).TestReportName; var sampleModel = new BLL.tb_SampleBLL().GetModelList(" sampleNum = '" + eTestReport.SampleNum + "'").FirstOrDefault(); ViewBag._cydw = "none"; ViewBag._sydw = "none"; if (sampleModel.isDetection) { eTestReport.ToSampleMode = "抽样"; ViewBag._cydw = ""; } else { eTestReport.ToSampleMode = "送样"; ViewBag._sydw = ""; } ViewBag.Department = eTestReport.Department; var _orlist = new BLL.OriginalRecord.T_tb_OriginalRecord().GetModelList(" RecordID in (" + eTestReport.RecordIDS + ")"); String _projectIds = ""; int _tempProjectId = 0; for (int i = 0; i < _orlist.Count; i++) { if (_tempProjectId == _orlist[i].ProjectID) { continue; } if (String.IsNullOrEmpty(_projectIds)) { _projectIds = _orlist[i].ProjectID.ToString(); } else { _projectIds += "," + _orlist[i].ProjectID.ToString(); } } eTestReport.TestBasis = ""; var _projectlist = new BLL.Laboratory.T_tb_Project().GetModelList(" ProjectID in (" + _projectIds + ")"); foreach (var item in _projectlist) { if (String.IsNullOrEmpty(eTestReport.TestBasis)) { eTestReport.TestBasis = item.ExpeMethod; } else { eTestReport.TestBasis += "," + item.ExpeMethod; } } //ViewBag.Department = ""; //if (sampleModel != null) //{ // if (sampleModel.isDetection) // { // ViewBag.Department = sampleModel.detectionCompany; // } // else // { // var clint = new BLL.ClientManage.T_tb_ClientManage().GetModel(Convert.ToInt32(sampleModel.InspectCompany)); // ViewBag.Department = clint.ClientName; // } //} ViewBag._TestType = ""; if (eTestReport.TestType != null) { ViewBag._TestType = tTypeDict.GetModel(int.Parse(eTestReport.TestType.ToString())).TypeName; } //ViewBag.TestTime = eTestReport.TestTime == null ? "" : Convert.ToDateTime(eTestReport.TestTime).ToString("yyyy/MM/dd"); ViewBag.TestTime = eTestReport.IssuedTime == null ? "" : Convert.ToDateTime(eTestReport.IssuedTime).ToString("yyyy/MM/dd"); ViewBag.DetectPersonnelID = CurrentUserInfo.PersonnelID; ViewBag.DetectPersonnelName = CurrentUserInfo.PersonnelName; if (string.IsNullOrEmpty(eTestReport.Remarks)) { eTestReport.Remarks = "无"; } eTestReport.EditType = EditType; return(View(eTestReport)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_tb_InPersonnel model) { return(dal.Update(model)); }
public ActionResult Top() { E_tb_InPersonnel eInPersonnel = (E_tb_InPersonnel)Session["UserInfo"]; return(View(eInPersonnel)); }