public ActionResult AssessModify(int id) { assess1 assessInfo = ae.Set <assess1>().Where(u => u.id == id).FirstOrDefault(); return(View(assessInfo)); }
public ActionResult AssessModify(assess1 NewAssess1) { //NewAssess1.id = Guid.NewGuid().ToInt32(); //评估单的ID,随机生成 //NewAssess1.auditID = RandomStr.RandomAuditID(); //评估提交日期,系统时间 //NewAssess1.date = DateTime.Now; //loginID,直接读 //NewAssess1.loginID = loginID; //审核状态,0为未审核,期初都填0 NewAssess1.auditstatus = 1; //后台给分,刚开始默认-1; //NewAssess1.backres = -1; //工资,刚开始也是0 NewAssess1.wage = 0; //总结果,也是0 //int self1 = int.Parse(NewAssess1.self); string chazhii = (NewAssess1.self - NewAssess1.backres).ToString(); int chazhi = Math.Abs(int.Parse(chazhii)); if (chazhi < 3) { string res1 = (NewAssess1.self + NewAssess1.backres).ToString(); int res2 = int.Parse(res1); float res = res2 / 2; NewAssess1.result = res; } else if (chazhi >= 3) { string self1 = NewAssess1.self.ToString(); string backres1 = NewAssess1.backres.ToString(); int self2 = int.Parse(self1); int backres2 = int.Parse(backres1); //int res2 = int.Parse(res1); float res = (self2 / 5) + (backres2 / 5) * 4; NewAssess1.result = res; } try { InfoLoadConn.Open(); MySqlCommand WageInfoReadCommand = InfoLoadConn.CreateCommand(); WageInfoReadCommand.CommandText = "select * from wage where type = '" + NewAssess1.type + "'"; MySqlDataReader WageInfoReader = WageInfoReadCommand.ExecuteReader(); while (WageInfoReader.Read()) { basis = float.Parse(WageInfoReader["basis"].ToString()); performance = float.Parse(WageInfoReader["performance"].ToString()); manqin = float.Parse(WageInfoReader["manqin"].ToString()); craft = float.Parse(WageInfoReader["craft"].ToString()); } InfoLoadConn.Close(); } catch (Exception e) { string ee = e.ToString(); return(View(ee)); } float wageres = basis + basis * manqin / 100 + craft + basis * performance * float.Parse((NewAssess1.result).ToString()) / 1000; NewAssess1.wage = wageres; if (!ModelState.IsValid) { return(Content("error")); } //publishInfo.EditTime = DateTime.Now; //NewAssess1.edittime = DateTime.Now; UpdateModel <assess1>(NewAssess1); ae.Entry(NewAssess1).State = EntityState.Modified; ae.SaveChanges(); AssessList = ae.Set <assess1>().ToList(); ViewBag.NewAssess1 = NewAssess1; return(RedirectToAction("Index")); }
public ActionResult StartAssess(assess1 NewAssess1) { HttpCookie ReadCookie = Request.Cookies.Get("Remeuser"); //判断cookie是否空值 if (ReadCookie != null) { User reUser = new User(); //把保存的用户名和密码赋值给对应的文本框 //用户名 name3 = ReadCookie.Values["UserName"].ToString(); //Response.Write("<script>alert(' name3 = " + name3 + "');</script>"); if (name3 == null) { return(Redirect("../Login/Index")); } ViewBag.UserName = name3; //ViewBag.UserName = "******"; //密码 string pwd3 = ReadCookie.Values["UserPwd"].ToString(); ViewBag.Password = pwd3; reUser.Username = name3; reUser.Password = pwd3; try { InfoLoadConn.Open(); MySqlCommand loginIdReadCommand = InfoLoadConn.CreateCommand(); loginIdReadCommand.CommandText = "select loginID from user_information where username = '******'"; MySqlDataReader loginIDReader = loginIdReadCommand.ExecuteReader(); while (loginIDReader.Read()) { loginID = loginIDReader["loginID"].ToString(); } InfoLoadConn.Close(); } catch (Exception e) { string ee = e.ToString(); return(View(ee)); } ViewData["remeuser"] = reUser; } else { return(RedirectToAction("../Login/Index")); } if (!ModelState.IsValid) { return(Content("error")); } NewAssess1.id = Guid.NewGuid().ToInt32(); //评估单的ID,随机生成 NewAssess1.auditID = RandomStr.RandomAuditID(); //评估提交日期,系统时间 NewAssess1.date = DateTime.Now; //loginID,直接读 NewAssess1.loginID = loginID; //审核状态,0为未审核,期初都填0 NewAssess1.auditstatus = 0; //后台给分,刚开始默认-1; NewAssess1.backres = -1; //工资,刚开始也是0 NewAssess1.wage = 0; //总结果,也是0 NewAssess1.result = -1; ae.assess1.Add(NewAssess1); //ne.publishes.Add(NewNote); ae.SaveChanges(); AssessList = ae.Set <assess1>().Where(x => x.loginID == loginID).ToList(); ViewBag.AssessList = AssessList; return(RedirectToAction("AssessIndex")); }