public ActionResult Submit(int id)
        {
            AuditApplication auditApplication = db.AuditApplications.Find(id);

            if (auditApplication == null)
            {
                return(HttpNotFound());
            }

            //标记该application的状态为等待审核
            auditApplication.State = 1;

            AuditTemplate template = db.AuditTemplates.Find(auditApplication.TId);
            //找到Template下的第一个Step节点
            AuditStep    step         = db.AuditSteps.Find(template.FirstStepSId);
            AuditProcess auditProcess = new AuditProcess();

            auditProcess.AId        = auditApplication.Id;
            auditProcess.SId        = step.SId;
            auditProcess.TId        = step.TId;
            auditProcess.CreateDate = DateTime.Now;
            auditProcess.Result     = 1;
            auditProcess.AuditDate  = DateTime.Now.AddDays(step.Days);//记录一下该节点最晚的审核时间;
            auditProcess.Approver   = step.Approver;
            db.AuditProcesses.Add(auditProcess);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        // GET: AuditApplication/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuditApplication auditApplication = db.AuditApplications.Find(id);

            if (auditApplication == null)
            {
                return(HttpNotFound());
            }
            auditApplication.StateDescription = db.States.Find(auditApplication.State).Description;
            // List<AuditApplication> list = db.AuditApplications.ToList();
            //foreach (AuditApplication tmp in list)
            //{
            //    tmp.TemplateName = db.AuditTemplates.Find(tmp.TId).Name;
            //    tmp.StateDescription = db.States.Find(tmp.State).Description;
            //}

            var auditProcesses = (from p in db.AuditProcesses where p.AId == auditApplication.Id select p).ToList();

            if (auditProcesses.Count != 0)
            {
                ViewBag.errorMessage = true;
                return(View(auditApplication));
            }

            return(View(auditApplication));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AuditApplication auditApplication = db.AuditApplications.Find(id);

            db.AuditApplications.Remove(auditApplication);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(AuditApplication auditApplication)
 {
     if (ModelState.IsValid)
     {
         db.Entry(auditApplication).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(auditApplication));
 }
        public ActionResult Create(AuditApplication auditApplication)
        {
            if (ModelState.IsValid)
            {
                auditApplication.CreateDate = DateTime.Now;
                auditApplication.Creator    = this.UserName;
                auditApplication.State      = 0;
                db.AuditApplications.Add(auditApplication);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(auditApplication));
        }
        // GET: AuditApplication/Edit/5
        public ActionResult Edit(int?id)
        {
            List <SelectListItem> itemTId = db.AuditTemplates.ToList().Select(c => new SelectListItem
            {
                Value = c.Id.ToString(), //保存的值
                Text  = c.Name           //显示的值
            }).ToList();

            //传值到页面
            ViewBag.TIdList = itemTId;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuditApplication auditApplication = db.AuditApplications.Find(id);

            if (auditApplication == null)
            {
                return(HttpNotFound());
            }
            return(View(auditApplication));
        }
        // GET: AuditApplication/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuditApplication auditApplication = db.AuditApplications.Find(id);

            if (auditApplication == null)
            {
                return(HttpNotFound());
            }
            string[] sArray = auditApplication.Info.Split(new char[] { ';' });
            ///string转html有必要吗
            int       len     = sArray.Length;
            ArrayList newList = new ArrayList(sArray);

            newList.RemoveAt(len - 1);
            sArray             = (string[])newList.ToArray(typeof(string));
            ViewBag.sInfoArray = ConvertDataTableToHtml(sArray);
            //ViewBag.sInfoArray = sArray;

            auditApplication.StateDescription = db.States.Find(auditApplication.State).Description;
            db.SaveChanges();

            //根据AuditApplication的Id寻找AuditProcess,然后寻找结果列表
            var resultList = (from p in db.AuditProcesses where p.AId == id orderby p.SId select p).ToList();

            ViewBag.resultlist = resultList;//存放结果列表
            foreach (var resultListItem in resultList)
            {
                resultListItem.ResultDescription = db.States.Find(resultListItem.Result).Description;
            }

            return(View(auditApplication));
        }
Example #8
0
        public byte AuditApplicationEvection(EvectionApplies evectionApplies)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == evectionApplies.BillType select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是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 (
                                    (evectionApplies.BillType == p.BType) && (DateTime.Now > p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();

                if (template != null)//如果没有用于审批的模板 那么这里没法运行
                {
                    Staff tmpStaff = db.Staffs.Where(p => p.StaffNumber.Equals(evectionApplies.StaffNumber)).ToList().First();
                    auditApplication.BNumber     = evectionApplies.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审核
                    auditApplication.Info        =
                        "单据名称:" + db.BillProperties.Where(p => p.Type.Equals(evectionApplies.BillType)).ToList().First().TypeName + ";" +
                        "工      号:" + evectionApplies.StaffNumber + ";" +
                        "姓      名:" + tmpStaff.Name + ";" +
                        "所在部门:" + db.Departments.Where(p => p.DepartmentId.Equals(tmpStaff.Department)).ToList().First().Name + ";" +
                        "性       别:" + tmpStaff.Gender + ";" +
                        "职      位:" + tmpStaff.Position + ";" +
                        "用工性质:" + tmpStaff.WorkProperty + ";" +
                        "出差时间:" + evectionApplies.StartDateTime + ";" +
                        "结束时间:" + evectionApplies.EndDateTime + ";" +
                        "出差天数:" + evectionApplies.Days + ";" +
                        "出差事由:" + evectionApplies.Reason + ";" +
                        "出差地点:" + evectionApplies.Location + ";" +
                        "备注:" + evectionApplies.Remark + ";";
                    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 + "提交人员:" + 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);//待审
        }
Example #9
0
        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 static void Initialize(AuditContext context)
        {
            context.Database.EnsureCreated();
            context.ClientId = "3inpv3ubfmag4k97cu5iqsesg8";

            // Look for any audits.
            if (context.Audits.IgnoreQueryFilters().Any())
            {
                return;   // DB has been seeded
            }

            //Audit Application
            var application = new AuditApplication()
            {
                Id           = 123456,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now,
                Description  = "Test Audit Application",
                Name         = "TestAuditApplication",
                ClientId     = "3inpv3ubfmag4k97cu5iqsesg8"
            };

            context.AuditApplications.Add(application);
            context.SaveChanges();

            var audits = new AuditEntity[]
            {
                new AuditEntity {
                    Id = 1, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 2, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 3, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 4, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 5, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 6, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 7, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 8, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 9, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                },
                new AuditEntity {
                    Id = 10, DateCreated = DateTime.Now, AuditApplication = application, ClientId = "3inpv3ubfmag4k97cu5iqsesg8", SubjectId = 123456789, Subject = "Subject Info", ActorId = 987654321, Actor = "Actor Info", Description = "Subject updated", Properties = "{json: 'stuff'}"
                }
            };

            foreach (AuditEntity s in audits)
            {
                context.Audits.Add(s);
            }
            context.SaveChanges();
        }
Example #11
0
        //private BonsaiiDbContext db = new BonsaiiDbContext();
        public byte AuditApplicationContract(Contract contract)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == contract.BillTypeNumber select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是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 (
                                    (contract.BillTypeNumber == p.BType) && (DateTime.Now >= p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();

                if (template != null)//如果没有用于审批的模板 那么这里没法运行
                {
                    var    tmpBillType    = (from p in db.BillProperties where p.Type == contract.BillTypeNumber select p.TypeFullName).ToList().Single();
                    Staff  staff          = db.Staffs.Where(c => c.StaffNumber.Equals(contract.SecondParty)).ToList().Single();
                    string departmentName = (from p in db.Departments where p.DepartmentId == contract.SecondParty select p.Name).SingleOrDefault();
                    auditApplication.BNumber     = contract.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审核
                    auditApplication.Info        =
                        "单据名称:" + tmpBillType + ";" +
                        "工       号:" + contract.SecondParty + ";" +
                        "姓       名:" + contract.SecondParty + ";" +
                        "所在部门:" + departmentName + ";" +
                        "性       别:" + staff.Gender + ";" +
                        "职       位:" + staff.Position + ";" +
                        "用工性质:" + staff.WorkProperty + ";" +
                        "合同标题:" + contract.ContractObject + ";" +
                        "合同编号:" + contract.ContractNumber + ";" +
                        "签订时间:" + contract.SignDate + ";" +
                        "到期时间:" + contract.DueDate + ";" +
                        "合同金额:" + contract.Amount + ";" +
                        "备注:" + contract.Remark + ";" +

                        db.AuditApplications.Add(auditApplication);
                    db.SaveChanges();

                    AuditStep    step         = db.AuditSteps.Find(template.FirstStepSId);
                    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();
                    return(0);//待审
                }
                else
                {
                    return(7);//待审(未能进入审核流程)
                }
            }
            return(0);//待审
        }
Example #12
0
        public byte AuditApplication(StaffApplication staffApplication)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == staffApplication.BillTypeNumber select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是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 (
                                    (staffApplication.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(staffApplication.StaffNumber)).ToList().Single();
                    string   departmentName     = (from p in db.Departments where p.DepartmentId == staff.Department select p.Name).SingleOrDefault();
                    DateTime entryDate_dateTime = (DateTime)staff.Entrydate;
                    DateTime leaveDate_dateTime = (DateTime)staffApplication.HopeLeaveDate;

                    auditApplication.BNumber = staffApplication.BillNumber;
                    auditApplication.TId     = template.Id;
                    auditApplication.Creator = this.UserName;
                    auditApplication.State   = 0;//代表等待审
                    auditApplication.Info    =
                        "单据名称:" + staffApplication.BillTypeName + ";" +
                        "工       号:" + staffApplication.StaffNumber + ";" +
                        "员工名称:" + staffApplication.StaffName + ";" +
                        "所在部门:" + departmentName + ";" +
                        "性       别:" + staff.Gender + ";" +
                        "职       位:" + staff.Position + ";" +
                        "用工性质:" + staff.WorkProperty + ";" +
                        "入职日期:" + entryDate_dateTime.Date.ToString("yyyy/MM/dd") + ";" +
                        "离职日期:" + leaveDate_dateTime.ToString("yyyy/MM/dd") + ";" +
                        "离职类型:" + staffApplication.LeaveType + ";" +
                        "离职原因:" + staffApplication.LeaveReason + ";" +
                        "备       注:" + staffApplication.Remark + ";" +
                        //"单别:" + staffApplication.BillTypeNumber + ";" +
                        //"单号:" + staffApplication.BillNumber + ";" +
                        //"员工工号:" + staffApplication.StaffNumber + ";" +
                        //"姓名:" + staffApplication.StaffName + ";" +
                        //"期望离职日期" + staffApplication.HopeLeaveDate + ";" +
                        //"离职类别" + staffApplication.LeaveType + ";" +
                        //"离职原因" + staffApplication.LeaveReason + ";" +
                        //"备注:" + staffApplication.Remark + ";" +
                        //"单据类别编号:" + staffApplication.BillTypeNumber + ";" +
                        //"创建日期:" + staffApplication.RecordTime + ";" +
                        //"录入人员:" + staffApplication.RecordPerson + ";";
                        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);//待审
        }
Example #13
0
 public BaseResult POST(AuditApplication request)
 {
     return(AuditManager.AuditApplication(request));
 }
Example #14
0
        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);//待审
        }
        /// <summary>
        /// 审核申请提交
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public BaseResult AuditApplication(AuditApplication request)
        {
            BaseResult bs      = new BaseResult();
            var        _year   = System.DateTime.Now.Year;
            var        addtime = DateTime.Now;

            try
            {
                using (var db = DbFactory.Open())
                {
                    var builder = db.From <Model.Audit.Audit>();
                    if (request.adcd != adcd)
                    {
                        bs.IsSuccess = false; bs.ErrorMsg = "操作账号异常"; return(bs);
                    }
                    if (request.year.Value != _year)
                    {
                        bs.IsSuccess = false; bs.ErrorMsg = "年份时间异常,申报年份仅限本年度"; return(bs);
                    }
                    #region 更新数据检测
                    var nnum         = AuditNums + 1;
                    var townperson   = db.Select <TownPersonLiable>(w => w.Year == request.year && w.adcd.StartsWith(request.adcd.Substring(0, 9)) && w.AuditNums == nnum);
                    var workgroup    = db.Select <VillageWorkingGroup>(w => w.Year == request.year && w.VillageADCD.StartsWith(request.adcd.Substring(0, 9)) && w.AuditNums == nnum);
                    var workgrid     = db.Select <VillageGridPersonLiable>(w => w.Year == request.year && w.VillageADCD.StartsWith(request.adcd.Substring(0, 9)) && w.AuditNums == nnum);
                    var worktransfer = db.Select <VillageTransferPerson>(w => w.Year == request.year && w.adcd.StartsWith(request.adcd.Substring(0, 9)) && w.AuditNums == nnum);
                    var villagepic   = db.Select <VillagePic>(w => w.Year == request.year && w.adcd.StartsWith(request.adcd.Substring(0, 9)) && w.AuditNums == nnum);
                    if (AuditNums != null)
                    {
                        if (townperson.Count == 0 && workgroup.Count == 0 && workgrid.Count == 0 && worktransfer.Count == 0 && villagepic.Count == 0)
                        {
                            bs.IsSuccess = false; bs.ErrorMsg = "系统检测到,您没有更新过任何数据,所以不需提交审核!"; return(bs);
                        }
                    }
                    #endregion
                    GrassrootsFloodCtrl.Model.Audit.Audit _audit = new Model.Audit.Audit();
                    _audit.TownADCD    = request.adcd;
                    _audit.Year        = request.year;
                    _audit.TownAddTime = addtime;
                    _audit.Status      = int.Parse(PublicClass.GetAudit(null, AuditStatusEnums.待审批.ToString()));
                    //
                    var log = new operateLog();
                    log.userName    = RealName;
                    log.operateTime = addtime;
                    if (null == request.id)
                    {
                        log.operateMsg = RealName + "提交了审核申请";
                    }
                    else
                    {
                        log.operateMsg = RealName + "修改后提交审核申请";
                    }
                    var listLog = new List <operateLog>();
                    listLog.Add(log);
                    _audit.operateLog = JsonTools.ObjectToJson(listLog);
                    //
                    if (null != request.id && request.id.Value > 0)
                    {
                        _audit.ID    = request.id;
                        bs.IsSuccess = db.Update(_audit) == 1 ? true : false;
                        #region 日志
                        StringBuilder sb = new StringBuilder();
                        sb.Append("在栏目{组织责任/提交审核}下," + RealName + "提交了审批第" + (AuditNums + 1) + "次申请");
                        _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新);
                        #endregion
                    }
                    else
                    {
                        //写入前判断,在当前一年是否已经存在
                        var b = db.From <Model.Audit.Audit>();
                        b.Where(w => w.TownADCD == request.adcd && w.Year == _year);
                        b.OrderByDescending(w => w.TownAddTime);
                        var r = db.Single <AuditViewModel>(b);
                        if (null != r)
                        {
                            _audit.AuditNums = r.AuditNums + 1;
                            _audit.ID        = r.ID;
                            bs.IsSuccess     = db.Update(_audit) == 1 ? true : false;
                            #region 日志
                            StringBuilder sb = new StringBuilder();
                            sb.Append("在栏目{组织责任/提交审核}下,{" + RealName + "}第{" + _audit.AuditNums + "}次提交了审批申请");
                            _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新);
                            #endregion
                        }
                        else
                        {
                            _audit.AuditNums = 1;
                            bs.IsSuccess     = db.Insert(_audit) == 1 ? true : false;
                            #region 日志
                            StringBuilder sb = new StringBuilder();
                            sb.Append("在栏目{组织责任/提交审核}下,{" + RealName + "}第{" + _audit.AuditNums + "}次提交了审批申请");
                            _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增);
                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                bs.IsSuccess = false;
                bs.ErrorMsg  = ex.Message;
            }
            return(bs);
        }
        public byte AuditApplicationStaffSkill(TrainStart 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) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是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)//如果没有用于审批的模板 那么这里没法运行
                {
                    auditApplication.BNumber     = staffSkill.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审
                    auditApplication.Info        =
                        "单据名称:" + staffSkill.BillTypeNumber + ";" +
                        "培训类型:" + staffSkill.TrainType + ";" +
                        "培训主题:" + staffSkill.TrainTheme + ";" +
                        "培训讲师:" + staffSkill.TrainPerson + ";" +
                        "培训地址:" + staffSkill.TrainPlace + ";" +
                        "开始时间:" + staffSkill.StartDate + ";" +
                        "结束时间:" + staffSkill.EndDate + ";" +
                        "培训费用:" + staffSkill.TrainCost + "元" + ";" +
                        "联系电话:" + staffSkill.TellNumber + ";" +
                        "参加人员:" + staffSkill.JoinPerson + ";" +
                        "列席人员:" + staffSkill.TrainManage + ";" +
                        "培训内容:" + staffSkill.TrainContent + ";" +
                        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);//待审
        }