public async Task <IEnumerable <StaffSkill> > GetStaffSkills() { StaffSkill staffSkill = null; List <StaffSkill> staffSkills = new List <StaffSkill>(); string comandtext = "select * from Monitoring.dbo.StaffSkill"; using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { await sqlConnection.OpenAsync(); SqlCommand sqlCommand = new SqlCommand(comandtext, sqlConnection); using (SqlDataReader reader = sqlCommand.ExecuteReader()) { while (reader.Read()) { staffSkill = new StaffSkill { Id = (int)reader["id"], Name = reader["Name"] as string, Type = reader["Type"] as string }; staffSkills.Add(staffSkill); } } return(staffSkills); } }
public ActionResult Create(StaffSkill staffSkill) { if (ModelState.IsValid) { /*先保存员工技能固定的字段(为了生成主键Id)*/ db.StaffSkills.Add(staffSkill); db.SaveChanges(); /*查找员工技能预留字段(name)*/ var fieldList = (from p in db.ReserveFields where p.TableName == "StaffSkills" select p).ToList(); ViewBag.fieldList = fieldList; /*遍历,保存员工技能变化的字段*/ foreach (var temp in fieldList) { StaffSkillReserve ssr = new StaffSkillReserve(); ssr.Number = staffSkill.Id; ssr.FieldId = temp.Id; ssr.Value = Request[temp.FieldName]; /*占位,为了在Index中显示整齐的格式*/ if (ssr.Value == null) { ssr.Value = " "; } db.StaffSkillReserves.Add(ssr); db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(staffSkill)); }
public ActionResult Edit(StaffSkillViewModel staffSkill) { if (ModelState.IsValid) { StaffSkill ss = db.StaffSkills.Find(staffSkill.Id); /*查找员工技能预留字段(value)*/ var fieldValueList = (from ssr in db.StaffSkillReserves join rf in db.ReserveFields on ssr.FieldId equals rf.Id where ssr.Number == staffSkill.Id && rf.Status == true select new StaffSkillViewModel { Id = ssr.Id, Description = rf.Description, Value = ssr.Value }).ToList(); //ViewBag.fieldValueList = fieldValueList; /*给预留字段赋值*/ foreach (var temp in fieldValueList) { StaffSkillReserve ssr = db.StaffSkillReserves.Find(temp.Id); ssr.Value = Request[temp.Description]; db.SaveChanges(); } ss.ValidDate = staffSkill.ValidDate; ss.StaffNumber = staffSkill.StaffNumber; ss.SkillRemark = staffSkill.SkillRemark; ss.SkillNumber = staffSkill.SkillNumber; ss.BillTypeNumber = staffSkill.BillTypeNumber; ss.BillNumber = staffSkill.BillNumber; ss.ChangePerson = base.Name; ss.ChangeTime = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(staffSkill)); }
//GET: StaffSkill/ManualAudit/5 public ActionResult ManualAudit(int?id, int flag) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSkill staffSkill = db.StaffSkills.Find(id); if (staffSkill == null) { return(HttpNotFound()); } //手动审批;这部分是自己给自己审批 //需要对原表做出的修改 try { if (flag == 1) { //通过审批 staffSkill.AuditStatus = 3; } else { //不通过审批 staffSkill.AuditStatus = 4; } staffSkill.AuditPerson = this.UserName; staffSkill.AuditTime = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
// GET: StaffSkill/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSkill staffSkill = db.StaffSkills.Find(id); if (staffSkill == null) { return(HttpNotFound()); } var skillParameters = db.SkillParameters.Where(sp => sp.SkillNumber.Equals(staffSkill.SkillNumber)); var staffs = db.Staffs.Where(s => s.StaffNumber.Equals(staffSkill.StaffNumber)); foreach (var temp in skillParameters) { staffSkill.SkillName = temp.SkillName; } foreach (var temp in staffs) { staffSkill.StaffName = temp.Name; } return(View(staffSkill)); }
public ActionResult DeleteConfirmed(int id) { StaffSkill staffSkill = db.StaffSkills.Find(id); db.StaffSkills.Remove(staffSkill); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,BillType,BillNumber,StaffNumber,StaffName,SkillNumber,SkillName,SkillGrade,SkillRemark")] StaffSkill staffSkill) { if (ModelState.IsValid) { db.Entry(staffSkill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(staffSkill)); }
public ActionResult Create([Bind(Include = "Id,BillType,BillNumber,StaffNumber,StaffName,SkillNumber,SkillName,SkillGrade,SkillRemark")] StaffSkill staffSkill) { if (ModelState.IsValid) { db.StaffSkills.Add(staffSkill); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(staffSkill)); }
//GET: StaffSkill/Submit/5 public ActionResult Submit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSkill staffSkill = db.StaffSkills.Find(id); if (staffSkill == null) { return(HttpNotFound()); } //提交审批 byte status = AuditApplicationStaffSkill(staffSkill); //需要对原表做出的修改 staffSkill.AuditStatus = status; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: StaffSkill/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSkill staffSkill = db.StaffSkills.Find(id); if (staffSkill == null) { return(HttpNotFound()); } var skillParameters = db.SkillParameters.Where(sp => sp.SkillNumber.Equals(staffSkill.SkillNumber)); var staffs = db.Staffs.Where(s => s.StaffNumber.Equals(staffSkill.StaffNumber)); foreach (var temp in skillParameters) { staffSkill.SkillName = temp.SkillName; } foreach (var temp in staffs) { staffSkill.StaffName = temp.Name; } /*查找员工技能预留字段(name)*/ var fieldNameList = (from p in db.ReserveFields where p.TableName == "StaffSkills" select p).ToList(); ViewBag.fieldNameList = fieldNameList; /*查找员工技能预留字段(value)*/ var fieldValueList = (from ssr in db.StaffSkillReserves join rf in db.ReserveFields on ssr.FieldId equals rf.Id where ssr.Number == staffSkill.Id select new StaffSkillView { Id = ssr.Number, Description = rf.Description, Value = ssr.Value }).ToList(); ViewBag.fieldValueList = fieldValueList; return(View(staffSkill)); }
public ActionResult DeleteConfirmed(int id) { /*Step1:删除预留字段*/ var item = (from ssr in db.StaffSkillReserves where ssr.Number == id select new StaffSkillViewModel { Id = ssr.Id }).ToList(); foreach (var temp in item) { StaffSkillReserve ssr = db.StaffSkillReserves.Find(temp.Id); db.StaffSkillReserves.Remove(ssr); } db.SaveChanges(); /*Step2:删除固定字段*/ StaffSkill staffSkill = db.StaffSkills.Find(id); db.StaffSkills.Remove(staffSkill); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(StaffSkill staffSkill3) { if (ModelState.IsValid) { staffSkill3.RecordTime = DateTime.Now; if (staffSkill3.ValidDate < DateTime.Today) { ModelState.AddModelError("", "生效日期错误!请重新选择"); CreateInite(); StaffSkillViewModel staffSkill = new StaffSkillViewModel(); staffSkill.Id = staffSkill3.Id; staffSkill.BillNumber = staffSkill3.BillNumber; staffSkill.StaffNumber = staffSkill3.StaffNumber; staffSkill.SkillNumber = staffSkill3.SkillNumber; staffSkill.SkillRemark = staffSkill3.SkillRemark; staffSkill.ValidDate = staffSkill3.ValidDate; return(View(staffSkill)); } staffSkill3.BillNumber = GenerateBillNumber(staffSkill3.BillTypeNumber); staffSkill3.RecordPerson = base.Name; /*先保存员工技能固定的字段(为了生成主键Id)*/ db.StaffSkills.Add(staffSkill3); db.SaveChanges(); //提交审核 byte status = AuditApplicationStaffSkill(staffSkill3); if (status == 7) { ViewBag.alertMessage = true; CreateInite(); StaffSkillViewModel staffSkill = new StaffSkillViewModel(); staffSkill.Id = staffSkill3.Id; // staffSkill.BillTypeNumber = GenerateBillNumber(); staffSkill.BillNumber = staffSkill3.BillNumber; staffSkill.StaffNumber = staffSkill3.StaffNumber; staffSkill.SkillNumber = staffSkill3.SkillNumber; staffSkill.SkillRemark = staffSkill3.SkillRemark; staffSkill.ValidDate = staffSkill3.ValidDate; return(View(staffSkill3)); } else { //需要对原表做出的修改 staffSkill3.AuditStatus = status; db.SaveChanges(); } /*查找员工技能预留字段(name)*/ var fieldList = (from p in db.ReserveFields join q in db.TableNameContrasts on p.TableNameId equals q.Id where q.TableName == "StaffSkills" select p).ToList(); ViewBag.fieldList = fieldList; /*遍历,保存员工技能变化的字段*/ foreach (var temp in fieldList) { StaffSkillReserve ssr = new StaffSkillReserve(); ssr.Number = staffSkill3.Id; ssr.FieldId = temp.Id; ssr.Value = Request[temp.FieldName]; /*占位,为了在Index中显示整齐的格式*/ if (ssr.Value == null) { ssr.Value = " "; } db.StaffSkillReserves.Add(ssr); db.SaveChanges(); } return(RedirectToAction("Index")); } else { CreateInite(); StaffSkillViewModel staffSkill = new StaffSkillViewModel(); staffSkill.Id = staffSkill3.Id; // staffSkill.BillTypeNumber = GenerateBillNumber(); staffSkill.BillNumber = staffSkill3.BillNumber; staffSkill.StaffNumber = staffSkill3.StaffNumber; staffSkill.SkillNumber = staffSkill3.SkillNumber; staffSkill.SkillRemark = staffSkill3.SkillRemark; staffSkill.ValidDate = staffSkill3.ValidDate; return(View(staffSkill)); } }
public static void ReturnStatus(int auditProcessAId, byte status, string userName) { UserModels user = (from u in sdb.Users where u.UserName == userName select u).FirstOrDefault(); BonsaiiDbContext db = new BonsaiiDbContext(user.ConnectionString); AuditApplication application = db.AuditApplications.Find(auditProcessAId);//修改Application的状态 application.State = status; string btype = application.BType.Substring(0, 2); switch (btype) { case "21": { //员工 Staff someone = (from p in db.Staffs where (p.BillNumber == application.BNumber) && (p.BillTypeNumber == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; //已审 SystemDbContext sysdb = new SystemDbContext(); /*BindCodes*/ var Ucount = (from p in sysdb.BindCodes where (p.CompanyId == user.CompanyId && p.StaffNumber == someone.StaffNumber) select p).ToList(); if (Ucount.Count == 0) { //木有该员工 BindCode user1 = new BindCode(); string CompanyDbName = "Bonsaii" + user1.CompanyId; user1.ConnectionString = ConfigurationManager.AppSettings["UserDbConnectionString"] + CompanyDbName + ";"; //"Data Source = localhost,1433;Network Library = DBMSSOCN;Initial Catalog = " + CompanyDbName + ";User ID = test;Password = admin;"; user1.CompanyId = user1.CompanyId; user1.StaffNumber = someone.StaffNumber; user1.RealName = someone.Name; user1.BindingCode = someone.BindingCode; user1.Phone = someone.IndividualTelNumber; user1.BindTag = false; user1.LastTime = DateTime.Now; user1.IsAvail = true; sysdb.BindCodes.Add(user1); sysdb.SaveChanges(); } db.SaveChanges(); Push(someone.StaffNumber, user.CompanyId, status); } } break; case "22": { //变更 StaffChange someone = (from p in db.StaffChanges where (p.BillNumber == application.BNumber) && (p.BillTypeNumber == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; if (someone.AuditStatus == 3) { var staffId = (from p in db.Staffs where p.StaffNumber == someone.StaffNumber && p.ArchiveTag != true select p.Number).ToList().FirstOrDefault(); Staff staff = db.Staffs.Find(staffId); staff.Name = someone.Name; staff.Gender = someone.Gender; staff.Department = someone.Department; staff.WorkType = someone.WorkType; staff.Position = someone.Position; staff.IdentificationNumber = someone.IdentificationNumber; staff.Nationality = someone.Nationality; staff.IdentificationNumber = someone.IdentificationNumber; staff.Entrydate = someone.Entrydate; staff.ClassOrder = someone.ClassOrder; staff.ApplyOvertimeSwitch = staff.ApplyOvertimeSwitch; staff.JobState = someone.JobState; staff.AbnormalChange = someone.AbnormalChange; staff.FreeCard = someone.FreeCard; staff.WorkProperty = someone.WorkProperty; staff.WorkType = someone.WorkType; staff.Source = someone.Source; staff.QualifyingPeriodFull = someone.QualifyingPeriodFull; staff.MaritalStatus = someone.MaritalStatus; staff.BirthDate = someone.BirthDate; staff.NativePlace = someone.NativePlace; staff.HealthCondition = someone.HealthCondition; staff.Nation = someone.Nation; staff.Address = someone.Address; staff.VisaOffice = someone.VisaOffice; staff.HomeTelNumber = someone.HomeTelNumber; staff.EducationBackground = someone.EducationBackground; staff.GraduationSchool = someone.GraduationSchool; staff.SchoolMajor = someone.SchoolMajor; staff.Degree = someone.SchoolMajor; staff.Introducer = someone.Introducer; staff.IndividualTelNumber = someone.IndividualTelNumber; staff.BankCardNumber = someone.BankCardNumber; staff.UrgencyContactMan = someone.UrgencyContactMan; staff.UrgencyContactAddress = someone.UrgencyContactAddress; staff.UrgencyContactPhoneNumber = someone.UrgencyContactPhoneNumber; staff.PhysicalCardNumber = someone.PhysicalCardNumber; staff.LeaveDate = someone.LeaveDate; staff.LeaveType = someone.LeaveType; staff.LeaveReason = someone.LeaveReason; staff.AuditStatus = someone.AuditStatus; staff.HealthCondition = someone.HealthCondition; staff.ChangeTime = someone.RecordTime; staff.ChangePerson = someone.RecordPerson; staff.AuditTime = DateTime.Now; staff.AuditPerson = userName; staff.Head = someone.Head; staff.LogicCardNumber = someone.LogicCardNumber; staff.HeadType = someone.HeadType; staff.IDCardNumber = someone.IDCardNumber; staff.DeadlineDate = someone.DeadlineDate; } db.SaveChanges(); Push(someone.StaffNumber, user.CompanyId, status); } } break; case "23": { //离职 StaffApplication someone = (from p in db.StaffApplications where (p.BillNumber == application.BNumber) && (p.BillTypeNumber == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; if (someone.AuditStatus == 3) { //审核通过就在Staff里面把标志置为1 var staffId = (from p in db.Staffs where p.StaffNumber == someone.StaffNumber && p.ArchiveTag != true select p.Number).ToList().FirstOrDefault(); Staff staff = db.Staffs.Find(staffId); staff.ArchiveTag = true; //true 代表离职 staff.BindingCode = null; //要把信息写到离职档案中 StaffArchive staffArchive = new StaffArchive(); staffArchive.BillTypeNumber = someone.BillTypeNumber; staffArchive.BillTypeName = someone.BillTypeName; staffArchive.BillNumber = someone.BillNumber; staffArchive.StaffNumber = staff.StaffNumber; staffArchive.StaffName = staff.Name; staffArchive.LeaveDate = someone.HopeLeaveDate; staffArchive.Department = (from p in db.Departments where p.DepartmentId == staff.Department select p.Name).ToList().FirstOrDefault(); staffArchive.IdenticationNumber = staff.IdentificationNumber; staffArchive.RecordPerson = staff.RecordPerson; staffArchive.RecordTime = staff.RecordTime; staffArchive.BlackList = false; staffArchive.WorkPlus = false; staff.ArchiveTag = true; //true 代表离职 db.StaffArchives.Add(staffArchive); //Users表中离职; //修改系统表 SystemDbContext sysdb = new SystemDbContext(); var Ucount = (from p in sysdb.BindCodes where (p.CompanyId == user.CompanyId && p.StaffNumber == someone.StaffNumber) select p).SingleOrDefault(); if (Ucount != null) { sysdb.BindCodes.Remove(Ucount); sysdb.SaveChanges(); } db.SaveChanges(); Push(someone.StaffNumber, user.CompanyId, status); } } } break; case "24": { //技能 StaffSkill someone = (from p in db.StaffSkills where (p.BillNumber == application.BNumber) && (p.BillTypeNumber == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; case "25": { //招聘 Recruitments someone = (from p in db.Recruitments where (p.BillCode == application.BNumber) && (p.BillType == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } } break; case "26": { //培训 TrainStart someone = (from p in db.TrainStarts where (p.BillNumber == application.BNumber) && (p.BillTypeNumber == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } } break; case "27": { //合同 Contract someone = (from p in db.Contracts where (p.BillNumber == application.BNumber) && (p.BillTypeNumber == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; //已审 } } break; case "31": { //出差 EvectionApplies someone = (from p in db.EvectionApplies where (p.BillNumber == application.BNumber) && (p.BillType == application.BType) select p).SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; case "32": { //请假 VacateApplies someone = (from p in db.VacateApplies where (p.BillNumber == application.BNumber) && (p.BillType == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; case "33": { //加班 OvertimeApplies someone = (from p in db.OvertimeApplies where (p.BillNumber == application.BNumber) && (p.BillType == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { OvertimeApplies correct = db.OvertimeApplies.Find(someone.Id); correct.AuditPerson = someone.AuditPerson; correct.AuditStatus = status; correct.AuditStatusName = someone.AuditStatusName; correct.AuditTime = someone.AuditTime; correct.BillNumber = someone.BillNumber; correct.BillType = someone.BillType; correct.Date = someone.Date; correct.EndDateTime = someone.EndDateTime; correct.Hours = someone.Hours; correct.IsRead = someone.IsRead; correct.Reason = someone.Reason; correct.Remark = someone.Remark; correct.StaffNumber = someone.StaffNumber; correct.StartDateTime = someone.StartDateTime; db.SaveChanges(); } Push(someone.StaffNumber, user.CompanyId, status); } break; case "34": { //签卡 ChargeCardApplies someone = (from p in db.ChargeCardApplies where (p.BillNumber == application.BNumber) && (p.BillType == p.BillType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; case "35": { //调休 DaysOffApplies someone = (from p in db.DaysOffApplies where (p.BillNumber == application.BNumber) && (p.BillType == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; case "36": { //异地 VacateApplies someone = (from p in db.VacateApplies where (p.BillNumber == application.BNumber) && (p.BillType == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; case "37": { //值班 OnDutyApplies someone = (from p in db.OnDutyApplies where (p.BillNumber == application.BNumber) && (p.BillType == application.BType) select p).ToList().SingleOrDefault(); if (someone != null) { someone.AuditStatus = status; } Push(someone.StaffNumber, user.CompanyId, status); } break; default: break; } switch (btype) { case "27": { //合同 Contract someone = (from p in db.Contracts where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; //已审 } break; case "21": { //员工 Staff someone = (from p in db.Staffs where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; //已审 } break; case "24": { //技能 StaffSkill someone = (from p in db.StaffSkills where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; } break; case "26": { //培训 TrainStart someone = (from p in db.TrainStarts where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; } break; case "23": { //离职 StaffApplication someone = (from p in db.StaffApplications where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; if (someone.AuditStatus == 3) { //审核通过就在Staff里面把标志置为1 var staffId = (from p in db.Staffs where p.StaffNumber == someone.StaffNumber && p.ArchiveTag != true select p.Number).ToList().FirstOrDefault(); Staff staff = db.Staffs.Find(staffId); staff.ArchiveTag = true; //true 代表离职 //要把信息写到离职档案中 StaffArchive staffArchive = new StaffArchive(); staffArchive.BillTypeNumber = someone.BillTypeNumber; staffArchive.BillTypeName = someone.BillTypeName; staffArchive.StaffNumber = staff.StaffNumber; staffArchive.StaffName = staff.Name; staffArchive.Department = staff.Department; staffArchive.IdenticationNumber = staff.IdentificationNumber; staffArchive.RecordPerson = staff.RecordPerson; staffArchive.RecordTime = staff.RecordTime; staffArchive.BillNumber = Generate.GenerateBillNumber(staffArchive.BillTypeNumber, user.ConnectionString); db.StaffArchives.Add(staffArchive); db.SaveChanges(); } } break; case "22": { //变更 StaffChange someone = (from p in db.StaffChanges where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; if (someone.AuditStatus == 3) { var staffId = (from p in db.Staffs where p.StaffNumber == someone.StaffNumber && p.ArchiveTag != true select p.Number).ToList().FirstOrDefault(); Staff staff = db.Staffs.Find(staffId); staff.Name = someone.Name; staff.Gender = someone.Gender; staff.Department = someone.Department; staff.WorkType = someone.WorkType; staff.Position = someone.Position; staff.IdentificationNumber = someone.IdentificationNumber; staff.Nationality = someone.Nationality; staff.IdentificationNumber = someone.IdentificationNumber; staff.Entrydate = someone.Entrydate; staff.ClassOrder = someone.ClassOrder; staff.ApplyOvertimeSwitch = staff.ApplyOvertimeSwitch; staff.JobState = someone.JobState; staff.AbnormalChange = someone.AbnormalChange; staff.FreeCard = someone.FreeCard; staff.WorkProperty = someone.WorkProperty; staff.WorkType = someone.WorkType; staff.Source = someone.Source; staff.QualifyingPeriodFull = someone.QualifyingPeriodFull; staff.MaritalStatus = someone.MaritalStatus; staff.BirthDate = someone.BirthDate; staff.NativePlace = someone.NativePlace; staff.HealthCondition = someone.HealthCondition; staff.Nation = someone.Nation; staff.Address = someone.Address; staff.VisaOffice = someone.VisaOffice; staff.HomeTelNumber = someone.HomeTelNumber; staff.EducationBackground = someone.EducationBackground; staff.GraduationSchool = someone.GraduationSchool; staff.SchoolMajor = someone.SchoolMajor; staff.Degree = someone.SchoolMajor; staff.Introducer = someone.Introducer; staff.IndividualTelNumber = someone.IndividualTelNumber; staff.BankCardNumber = someone.BankCardNumber; staff.UrgencyContactMan = someone.UrgencyContactMan; staff.UrgencyContactAddress = someone.UrgencyContactAddress; staff.UrgencyContactPhoneNumber = someone.UrgencyContactPhoneNumber; staff.PhysicalCardNumber = someone.PhysicalCardNumber; staff.LeaveDate = someone.LeaveDate; staff.LeaveType = someone.LeaveType; staff.LeaveReason = someone.LeaveReason; staff.AuditStatus = someone.AuditStatus; staff.HealthCondition = someone.HealthCondition; staff.ChangeTime = someone.RecordTime; staff.ChangePerson = someone.RecordPerson; staff.AuditTime = DateTime.Now; staff.AuditPerson = user.Name; staff.Head = someone.Head; staff.LogicCardNumber = someone.LogicCardNumber; staff.HeadType = someone.HeadType; staff.IDCardNumber = someone.IDCardNumber; staff.DeadlineDate = someone.DeadlineDate; } db.SaveChanges(); } break; case "33": { //加班 OvertimeApplies someone = (from p in db.OvertimeApplies where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; case "32": { //请假 VacateApplies someone = (from p in db.VacateApplies where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; case "34": { //请假 ChargeCardApplies someone = (from p in db.ChargeCardApplies where p.BillNumber == application.BNumber select p).ToList().SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; case "31": { //出差 EvectionApplies someone = (from p in db.EvectionApplies where p.BillNumber == application.BNumber select p).SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; case "35": { //出差 DaysOffApplies someone = (from p in db.DaysOffApplies where p.BillNumber == application.BNumber select p).SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; case "36": { //出差 OffSiteApplies someone = (from p in db.OffSiteApplies where p.BillNumber == application.BNumber select p).SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; case "37": { //出差 OnDutyApplies someone = (from p in db.OnDutyApplies where p.BillNumber == application.BNumber select p).SingleOrDefault(); someone.AuditStatus = status; Push(someone.StaffNumber, user.CompanyId, status); } break; default: break; } db.SaveChanges(); }
public async Task <IActionResult> Update(StaffSkill data) { var result = await _service.UpdateStaffSkillAsync(data); return(Ok(result)); }
public async Task <IActionResult> Save(StaffSkill data) { var result = await _service.SaveStaffSkill(data); return(Ok(result)); }
// GET: StaffSkill/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSkill staffSkill = db.StaffSkills.Find(id); if (staffSkill == null) { return(HttpNotFound()); } StaffSkillViewModel staffSkillViewModel = new StaffSkillViewModel(); staffSkillViewModel.Id = staffSkill.Id; staffSkillViewModel.BillNumber = staffSkill.BillNumber; staffSkillViewModel.BillTypeNumber = staffSkill.BillTypeNumber; staffSkillViewModel.StaffNumber = staffSkill.StaffNumber; staffSkillViewModel.SkillNumber = staffSkill.SkillNumber; staffSkillViewModel.SkillRemark = staffSkill.SkillRemark; staffSkillViewModel.ValidDate = staffSkill.ValidDate; staffSkillViewModel.AuditStatusName = db.States.Find(staffSkill.AuditStatus).Description; var stafflParam = db.StaffParams.Where(sp => sp.Id.ToString().Equals(staffSkill.SkillNumber)); var staffs = (from s in db.Staffs join d in db.Departments on s.Department equals d.DepartmentId where s.StaffNumber == staffSkill.StaffNumber select new { Name = s.Name, Department = d.Name }).ToList(); var billTypeNumber = db.BillProperties.Where(bp => bp.Type.Equals(staffSkill.BillTypeNumber)); foreach (var billTypeNumber1 in billTypeNumber) { staffSkillViewModel.BillTypeName = billTypeNumber1.TypeName; } foreach (var temp in stafflParam) { staffSkillViewModel.SkillName = temp.Value; } foreach (var temp in staffs) { staffSkillViewModel.StaffName = temp.Name; staffSkillViewModel.Department = temp.Department; } /*显示预留字段以及预留字段的值*/ /*查找员工技能预留字段(name)*/ var fieldNameList = (from p in db.ReserveFields join q in db.TableNameContrasts on p.TableNameId equals q.Id where q.TableName == "StaffSkills" && p.Status == true select p).ToList(); ViewBag.fieldNameList = fieldNameList; /*查找员工技能预留字段(value)*/ var fieldValueList = (from ssr in db.StaffSkillReserves join rf in db.ReserveFields on ssr.FieldId equals rf.Id where ssr.Number == staffSkill.Id && rf.Status == true select new StaffSkillViewModel { Id = ssr.Number, Description = rf.Description, Value = ssr.Value }).ToList(); ViewBag.fieldValueList = fieldValueList; return(View(staffSkillViewModel)); }
// GET: StaffSkill/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSkill staffSkill = db.StaffSkills.Find(id); if (staffSkill == null) { return(HttpNotFound()); } StaffSkillViewModel staffSkillViewModel = new StaffSkillViewModel(); staffSkillViewModel.Id = staffSkill.Id; staffSkillViewModel.BillNumber = staffSkill.BillNumber; staffSkillViewModel.BillTypeNumber = staffSkill.BillTypeNumber; staffSkillViewModel.StaffNumber = staffSkill.StaffNumber; staffSkillViewModel.SkillNumber = staffSkill.SkillNumber; staffSkillViewModel.SkillRemark = staffSkill.SkillRemark; staffSkillViewModel.ValidDate = staffSkill.ValidDate; var stafflParam = db.StaffParams.Where(sp => sp.Id.ToString().Equals(staffSkill.SkillNumber)); var staffs = (from s in db.Staffs join d in db.Departments on s.Department equals d.DepartmentId into gc /*左联:显示所有员工表的字段*/ from d in gc.DefaultIfEmpty() where s.StaffNumber == staffSkill.StaffNumber select new { Name = s.Name, Department = d.Name }).ToList(); var billTypeNumber = db.BillProperties.Where(bp => bp.Type.Equals(staffSkill.BillTypeNumber)); foreach (var billTypeNumber1 in billTypeNumber) { staffSkillViewModel.BillTypeName = billTypeNumber1.TypeName; } foreach (var temp in stafflParam) { staffSkillViewModel.SkillName = temp.Value; } foreach (var temp in staffs) { staffSkillViewModel.StaffName = temp.Name; staffSkillViewModel.Department = temp.Department; } //4.员工技能 List <SelectListItem> staffSkill2 = new List <SelectListItem>(); ///linq多表查询 var staffSkill1 = from spt in db.StaffParamTypes join sp in db.StaffParams on spt.Id equals sp.StaffParamTypeId where spt.Name == "员工技能" select new { id = sp.Id, value = sp.Value }; foreach (var tt in staffSkill1) { SelectListItem i = new SelectListItem(); i.Value = tt.id.ToString(); i.Text = tt.value; staffSkill2.Add(i); } ViewBag.staffSkill = staffSkill2; /*查找员工技能预留字段(value)*/ var fieldValueList = (from ssr in db.StaffSkillReserves join rf in db.ReserveFields on ssr.FieldId equals rf.Id //where ssr.Number == staffSkill.Id where ssr.Number == id && rf.Status == true select new StaffSkillViewModel { Description = rf.Description, Value = ssr.Value }).ToList(); ViewBag.fieldValueList = fieldValueList; return(View(staffSkillViewModel)); }
public byte AuditApplicationStaffSkill(StaffSkill staffSkill)//(string BillTypeNumber,int id) { /*访问单据性质,看是否是自动审核*/ var item = (from p in db.BillProperties where p.Type == staffSkill.BillTypeNumber select p).ToList().FirstOrDefault(); if (item.IsAutoAudit == 1) { //如果为0 代表不能自动审核 如果为1 代表可以自动审核 return(3); //代表自动审核 } if (item.IsAutoAudit == 2) { //手动审核,也写到db.AditApplications这个表中但是不走process? return(6);//手动审核 } if (item.IsAutoAudit == 3) { //如果不自动审核,就要走人工审核流程。即,把信息写入db.AditApplications这个表中 AuditApplication auditApplication = new AuditApplication(); auditApplication.BType = item.Type; auditApplication.TypeName = item.TypeName; auditApplication.CreateDate = DateTime.Now; var template = (from p in db.AuditTemplates where ( (staffSkill.BillTypeNumber == p.BType) && (DateTime.Now > p.StartTime) && (DateTime.Now < p.ExpireTime) ) select p).ToList().FirstOrDefault(); if (template != null) { // Staff staff = db.Staffs.Where(c => c.StaffNumber.Equals(staffSkill.StaffNumber)).ToList().Single(); Staff staff = (from p in db.Staffs where p.StaffNumber == staffSkill.StaffNumber && p.AuditStatus == 3 && p.ArchiveTag == false select p).ToList().Single(); var tmpDepartment = (from p in db.Departments where p.DepartmentId == staff.Department select p.Name).ToList().Single(); var tmpBillType = (from p in db.BillProperties where p.Type == staffSkill.BillTypeNumber select p.TypeFullName).ToList().Single(); auditApplication.Info = "单据名称:" + tmpBillType + ";" + "工 号:" + staffSkill.StaffNumber + ";" + "员工名称:" + staff.Name + ";" + "所在部门:" + tmpDepartment + ";" + "性 别:" + staff.Gender + ";" + "职 位:" + staff.Position + ";" + "用工性质:" + staff.WorkProperty + ";"; //"单别:" + staffSkill.BillTypeNumber + ";" + //"单号:" + staffSkill.BillNumber + ";" + //"员工:" + staffSkill.StaffNumber + ";" + //"技能编号:" + staffSkill.SkillNumber + ";" + //"备注:" + staffSkill.SkillRemark + ";" + //"单据类别编号:" + staffSkill.BillTypeNumber + ";" + //"生效日期:" + staffSkill.ValidDate + ";" + //"创建日期:" + staffSkill.RecordTime + ";" + //"录入人员:" + staffSkill.RecordPerson + ";"; auditApplication.BNumber = staffSkill.BillNumber; auditApplication.TId = template.Id; auditApplication.Creator = this.UserName; auditApplication.CreatorName = this.Name; auditApplication.State = 0;//代表等待审核 db.AuditApplications.Add(auditApplication); db.SaveChanges(); AuditStep step = db.AuditSteps.Find(template.FirstStepSId); if (step == null) { return(7); } else { AuditProcess auditProcess = new AuditProcess(); auditProcess.AId = auditApplication.Id; auditProcess.SId = step.SId; auditProcess.TId = step.TId; auditProcess.BType = auditApplication.BType; auditProcess.BNumber = auditApplication.BNumber; auditProcess.TypeName = auditApplication.TypeName; auditProcess.Info = auditApplication.Info; //auditProcess.Info = auditApplication.Info + "提交人员:" + auditApplication.CreatorName + "-" + auditApplication.Creator + ";" + // "提交日期:" + auditApplication.CreateDate + ";"; auditProcess.AuditDate = DateTime.Now; auditProcess.CreateDate = auditApplication.CreateDate; auditProcess.Result = 0; //待审 auditProcess.DeadlineDate = DateTime.Now.AddDays(step.Days); //记录一下该节点最晚的审核时间; auditProcess.Approver = step.Approver; db.AuditProcesses.Add(auditProcess); db.SaveChanges(); } db.SaveChanges(); return(0);//待审 } else { return(7);//待审(未能进入审核流程) } } return(0);//待审 }