Ejemplo n.º 1
0
        public ActionResult Delete(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;

            /*
             * 参数获取
             */
            // 申请id
            var id = collection["id"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(id))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(id, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }

            /*
             * 删除申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    // 查询所有对应的履历
                    // 获得所有外出人员id
                    //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList();
                    //var historyList = db.History.Where(n => historyIdList.Contains(n.ID)).ToList();
                    //db.History.RemoveRange(historyList);
                    //db.Apply.Remove(apply);
                    apply.IsDelete = true;
                    db.SaveChanges();
                    return(ResponseUtil.OK(200, "删除成功"));
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult Delete(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 用户ID
            int id = 0;

            /*
             * 参数获取
             */
            // 用户ID
            var userId = collection["id"];

            /*
             * 参数校验
             */
            // 用户ID
            if (string.IsNullOrEmpty(userId))
            {
                return(ResponseUtil.Error(400, "用户ID不能为空"));
            }
            else
            {
                if (!int.TryParse(userId, out id))
                {
                    return(ResponseUtil.Error(400, "用户ID不正确"));
                }
            }

            /*
             * 用户查询
             */
            using (var db = new YGSDbContext())
            {
                var user = db.User.Where(n => n.ID == id).FirstOrDefault();
                if (user == null)
                {
                    return(ResponseUtil.Error(400, "用户不存在"));
                }
                else
                {
                    // 检查该用户是否有护照信息,也要一并删除
                    var credList = db.Cred.Where(n => n.UserID == id).ToList();
                    db.Cred.RemoveRange(credList);
                    db.User.Remove(user);
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "用户删除成功"));
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult Upload()
        {
            try
            {
                // 个人上传文件夹检查
                var folder     = System.Configuration.ConfigurationManager.AppSettings["UploadPath"];
                var folderPath = folder;
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                // 提取上传的文件
                HttpPostedFileBase file = Request.Files[0];

                // 原文件名 Test.txt
                var fileName = Path.GetFileName(file.FileName);
                // 最终文件名 yyyyMMddHHmmss+4random.txt
                var finalFileName = DiskUtil.GetFinalFileName(fileName);
                // 最终存储路径
                var path = Path.Combine(folderPath, finalFileName);

                // 保存文件
                file.SaveAs(path);

                // 判断上传的是反馈文件还是客户签字单
                var att = new YGS_Att();
                att.Name = fileName;
                att.Path = Path.Combine(finalFileName).Replace("\\", "/");

                using (var db = new YGSDbContext())
                {
                    db.Attachment.Add(att);
                    db.SaveChanges();
                }

                return(new JsonNetResult(new
                {
                    status = 200,
                    data = new
                    {
                        id = att.ID,
                        name = att.Name,
                        path = Url.Action("Download", "Common", new { id = att.ID })
                    }
                }));
            }
            catch
            {
                return(ResponseUtil.Error(400, "上传出错"));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            /*
             * 证件查询
             */
            using (var db = new YGSDbContext())
            {
                var cred = db.Cred.Where(n => n.ID == id).FirstOrDefault();
                if (cred == null)
                {
                    return(ResponseUtil.Error(400, "证件不存在"));
                }
                else
                {
                    db.Cred.Remove(cred);
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "删除成功"));
                }
            }
        }
Ejemplo n.º 5
0
        public ActionResult Delete(int id)
        {
            /*
             * 查询履历
             */
            using (var db = new YGSDbContext())
            {
                var history = db.History.Where(n => n.ID == id).FirstOrDefault();

                if (history == null)
                {
                    return(ResponseUtil.Error(400, "履历不存在"));
                }
                else
                {
                    db.History.Remove(history);
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "删除成功"));
                }
            }
        }
Ejemplo n.º 6
0
        public ActionResult Delete(int id)
        {
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == id).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    // 查询所有对应的履历
                    // 获得所有外出人员id
                    //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList();
                    //var historyList = db.History.Where(n => historyIdList.Contains(n.ID)).ToList();
                    //db.History.RemoveRange(historyList);
                    //db.Apply.Remove(apply);
                    apply.IsDelete = true;
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "删除成功"));
                }
            }
        }
Ejemplo n.º 7
0
        public ActionResult DoUpdate(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;

            /*
             * 参数获取
             */
            // 申请ID
            var id = collection["id"];
            // 团组名
            var outName = collection["outName"];
            // 出访任务
            var descn = collection["desc"];
            // 出访类型
            var credType = collection["credType"];
            // 人员ID列表
            var outUsers = collection["outUsers"];
            // 申请附件ID列表
            var applyAtt = collection["applyAtt"];
            // 资料回传附件ID列表
            var afterAtt = collection["afterAtt"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(id))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(id, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 团组名
            if (string.IsNullOrEmpty(outName))
            {
                return(ResponseUtil.Error(400, "团组名不能为空"));
            }
            // 出访任务
            if (string.IsNullOrEmpty(descn))
            {
                return(ResponseUtil.Error(400, "出访类型不能为空"));
            }
            // 人员ID列表
            if (string.IsNullOrEmpty(outUsers))
            {
                return(ResponseUtil.Error(400, "出访人员不能为空"));
            }
            // 申请附件ID不能为空
            if (string.IsNullOrEmpty(applyAtt))
            {
                return(ResponseUtil.Error(400, "申请附件不能为空"));
            }

            /*
             * 查询申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    apply.OutName  = outName;
                    apply.Desc     = descn;
                    apply.CredType = credType;
                    apply.OutUsers = outUsers;
                    apply.ApplyAtt = applyAtt;
                    if (!string.IsNullOrEmpty(afterAtt))
                    {
                        apply.AfterAtt = afterAtt;
                    }
                    else
                    {
                        apply.AfterAtt = null;
                    }
                    // 如果当前申请是被拒绝,则重新到待审核中
                    if (apply.ApplyStatus == WHConstants.Apply_Status_Rejected)
                    {
                        apply.ApplyStatus = WHConstants.Apply_Status_Examing;

                        var notifyUserIdList = NotificationUtil.GetNotificationUsers();
                        foreach (var user in notifyUserIdList)
                        {
                            NotificationUtil.SendNotification(user, "您有新的出国申请审核", "/Apps/YGS/Home/Check");
                        }
                    }
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "申请更新成功"));
                }
            }
        }
Ejemplo n.º 8
0
        public ActionResult DoUpdate(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 履历ID
            int id = 0;
            // 签证时间
            DateTime signTime = new DateTime();
            // 是否出行
            bool isOut = true;

            /*
             * 参数获取
             */
            // 履历ID
            var idString = collection["id"];
            // 签证号
            var signNo = collection["signNo"];
            // 签证地
            var signNation = collection["signNation"];
            // 签证时间
            var signTimeString = collection["signTime"];
            // 是否出行
            var isOutString = collection["isOut"];

            /*
             * 参数校验
             */
            // 履历ID
            if (string.IsNullOrEmpty(idString))
            {
                return(ResponseUtil.Error(400, "履历ID不能为空"));
            }
            else
            {
                if (!int.TryParse(idString, out id))
                {
                    return(ResponseUtil.Error(400, "履历ID格式不正确"));
                }
            }
            // 签证号
            if (string.IsNullOrEmpty(signNo))
            {
                return(ResponseUtil.Error(400, "签证号不能为空"));
            }
            // 签证时间
            if (!string.IsNullOrEmpty(signTimeString))
            {
                if (!DateTime.TryParse(signTimeString, out signTime))
                {
                    return(ResponseUtil.Error(400, "签证时间格式错误"));
                }
            }
            // 是否出行
            if (!string.IsNullOrEmpty(isOutString))
            {
                if (!bool.TryParse(isOutString, out isOut))
                {
                    return(ResponseUtil.Error(400, "是否出行格式不正确"));
                }
            }

            /*
             * 更新履历
             */
            using (var db = new YGSDbContext())
            {
                var history = db.History.Where(n => n.ID == id).FirstOrDefault();
                if (history == null)
                {
                    return(ResponseUtil.Error(400, "履历不存在"));
                }
                else
                {
                    history.SignNo = signNo;                    // 签证号
                    if (!string.IsNullOrEmpty(signTimeString))  // 签证时间
                    {
                        history.SignTime = signTime;
                    }
                    else
                    {
                        history.SignTime = null;
                    }
                    if (!string.IsNullOrEmpty(signNation))      // 签证地
                    {
                        history.SignNation = signNation;
                    }
                    else
                    {
                        history.SignNation = null;
                    }
                    if (!string.IsNullOrEmpty(isOutString))
                    {
                        history.IsOut = isOut;                      // 是否出行
                    }
                    else
                    {
                        history.IsOut = null;
                    }
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "履历更新成功"));
                }
            }
        }
Ejemplo n.º 9
0
        public ActionResult DoUpdate(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 证件ID
            int tradeId = 0;
            // 发照日期
            DateTime credDate = new DateTime();
            // 有效期
            DateTime validDate = new DateTime();

            /*
             * 参数获取
             */
            // 证件ID
            var tradeIdString = collection["tradeId"];
            // 证件号
            var tradeCode = collection["tradeCode"];
            // 证件类型
            var credType = collection["credType"];
            // 发照机关
            var credUnit = collection["credUnit"];
            // 发照日期
            var credDateString = collection["credDate"];
            // 有效期
            var validDateString = collection["validDate"];
            // 有效状态
            var validStatus = collection["validStatus"];

            /*
             * 参数校验
             */
            // 证件ID
            if (string.IsNullOrEmpty(tradeIdString))
            {
                return(ResponseUtil.Error(400, "证件ID不能为空"));
            }
            else
            {
                if (!int.TryParse(tradeIdString, out tradeId))
                {
                    return(ResponseUtil.Error(400, "证件ID不正确"));
                }
            }
            // 证件号
            if (string.IsNullOrEmpty(tradeCode))
            {
                return(ResponseUtil.Error(400, "证件号不能为空"));
            }
            // 证件类型
            //if (string.IsNullOrEmpty(credType))
            //{
            //    return ResponseUtil.Error(400, "证件类型不能为空");
            //}
            // 发照机关
            //if (string.IsNullOrEmpty(credUnit))
            //{
            //    return ResponseUtil.Error(400, "发照机关不能为空");
            //}
            // 发照日期
            if (!string.IsNullOrEmpty(credDateString))
            {
                if (!DateTime.TryParse(credDateString, out credDate))
                {
                    return(ResponseUtil.Error(400, "发照日期格式不正确"));
                }
            }
            // 有效期
            if (!string.IsNullOrEmpty(validDateString))
            {
                if (!DateTime.TryParse(validDateString, out validDate))
                {
                    return(ResponseUtil.Error(400, "有效期格式不正确"));
                }
            }
            // 有效状态
            //if (string.IsNullOrEmpty(validStatus))
            //{
            //    return ResponseUtil.Error(400, "有效状态不能为空");
            //}

            /*
             * 证件查询
             */
            using (var db = new YGSDbContext())
            {
                var cred = db.Cred.Where(n => n.ID == tradeId).FirstOrDefault();
                if (cred == null)
                {
                    return(ResponseUtil.Error(400, "证件不存在"));
                }
                else
                {
                    var existsCred = db.Cred.Where(n => n.TradeCode == tradeCode).FirstOrDefault();
                    if (existsCred != null && existsCred.ID != cred.ID)
                    {
                        return(ResponseUtil.Error(400, "相同证件号已存在"));
                    }
                    else
                    {
                        cred.TradeCode = tradeCode;
                        cred.CredType  = credType;
                        cred.CredUnit  = credUnit;
                        if (string.IsNullOrEmpty(credDateString))
                        {
                            cred.CredDate = null;
                        }
                        else
                        {
                            cred.CredDate = credDate;
                        }
                        if (string.IsNullOrEmpty(validDateString))
                        {
                            cred.ValidDate = null;
                        }
                        else
                        {
                            cred.ValidDate = validDate;
                        }
                        cred.ValidStatus = validStatus;
                        db.SaveChanges();
                        return(ResponseUtil.OK(200, "更新成功"));
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public ActionResult DoAdd(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 用户ID
            int uid = 0;
            // 发照日期
            DateTime credDate = new DateTime();
            // 有效期
            DateTime validDate = new DateTime();

            /*
             * 参数获取
             */
            // 用户ID
            var userId = collection["userId"];
            // 证件号
            var tradeCode = collection["tradeCode"];
            // 证件类型
            var credType = collection["credType"];
            // 发照机关
            var credUnit = collection["credUnit"];
            // 发照日期
            var credDateString = collection["credDate"];
            // 有效期
            var validDateString = collection["validDate"];
            // 有效状态
            var validStatus = collection["validStatus"];

            /*
             * 参数校验
             */
            // 用户ID
            if (string.IsNullOrEmpty(userId))
            {
                return(ResponseUtil.Error(400, "用户ID不能为空"));
            }
            else
            {
                if (!int.TryParse(userId, out uid))
                {
                    return(ResponseUtil.Error(400, "用户ID不正确"));
                }
            }
            // 证件号
            if (string.IsNullOrEmpty(tradeCode))
            {
                return(ResponseUtil.Error(400, "证件号不能为空"));
            }
            // 证件类型
            //if (string.IsNullOrEmpty(credType))
            //{
            //    return ResponseUtil.Error(400, "证件类型不能为空");
            //}
            // 发照机关
            //if (string.IsNullOrEmpty(credUnit))
            //{
            //    return ResponseUtil.Error(400, "发照机关不能为空");
            //}
            // 发照日期
            if (!string.IsNullOrEmpty(credDateString))
            {
                if (!DateTime.TryParse(credDateString, out credDate))
                {
                    return(ResponseUtil.Error(400, "发照日期格式不正确"));
                }
            }
            // 有效期
            if (!string.IsNullOrEmpty(validDateString))
            {
                if (!DateTime.TryParse(validDateString, out validDate))
                {
                    return(ResponseUtil.Error(400, "有效期格式不正确"));
                }
            }
            // 有效状态
            //if (string.IsNullOrEmpty(validStatus))
            //{
            //    return ResponseUtil.Error(400, "有效状态不能为空");
            //}

            /*
             * 用户查询
             */
            using (var db = new YGSDbContext())
            {
                var existsCred = db.Cred.Where(n => n.TradeCode == tradeCode).FirstOrDefault();
                if (existsCred != null)
                {
                    return(ResponseUtil.Error(400, "相同证件号已存在"));
                }
                else
                {
                    var user = db.User.Where(n => n.ID == uid).FirstOrDefault();
                    if (user == null)
                    {
                        return(ResponseUtil.Error(400, "用户不存在"));
                    }
                    else
                    {
                        var cred = new YGS_Cred();
                        cred.UserID    = uid;
                        cred.Name      = user.Name;
                        cred.Sex       = user.Sex;
                        cred.TradeCode = tradeCode;
                        cred.CredType  = credType;
                        cred.CredUnit  = credUnit;
                        if (string.IsNullOrEmpty(credDateString))
                        {
                            cred.CredDate = null;
                        }
                        else
                        {
                            cred.CredDate = credDate;
                        }
                        if (string.IsNullOrEmpty(validDateString))
                        {
                            cred.ValidDate = null;
                        }
                        else
                        {
                            cred.ValidDate = validDate;
                        }
                        cred.ValidStatus = validStatus;
                        cred.CreateTime  = DateTime.Now;
                        cred.UpdateTime  = DateTime.Now;

                        db.Cred.Add(cred);
                        db.SaveChanges();

                        return(ResponseUtil.OK(200, "添加成功"));
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public ActionResult Check(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;

            /*
             * 参数获取
             */
            // 申请ID
            var id = collection["id"];
            // 审批意见
            var checkOpinion = collection["checkOpinion"];
            // 审批状态
            var checkStatus = collection["checkStatus"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(id))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(id, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 审批意见
            if (string.IsNullOrEmpty(checkOpinion))
            {
                return(ResponseUtil.Error(400, "审批意见不能为空"));
            }
            // 审批状态
            if (string.IsNullOrEmpty(checkStatus))
            {
                return(ResponseUtil.Error(400, "审批状态不能为空"));
            }

            /*
             * 审核逻辑
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    apply.CheckOpinion = checkOpinion;
                    if (checkStatus == WHConstants.Check_Status_Pass)
                    {
                        // 获得所有外出人员id
                        //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList();
                        //var outUserIds = db.History.Where(n => historyIdList.Contains(n.ID)).Select(n => n.UserId).ToList();
                        //var illegalUsers = db.User.Where(m => outUserIds.Contains(m.ID) && string.IsNullOrEmpty(m.CredNo)).ToList();

                        //if (illegalUsers.Count > 0)
                        //{
                        //    return ResponseUtil.Error(400, "出国人员缺少身份证号,请先到申请详情中补全");
                        //}
                        //else
                        //{
                        //    apply.ApplyStatus = WHConstants.Apply_Status_Passed;
                        //    NotificationUtil.SendNotification(apply.UserId, "您的出国申请已通过", "/Apps/YGS/Home/");
                        //}
                        apply.ApplyStatus = WHConstants.Apply_Status_Passed;
                        NotificationUtil.SendNotification(apply.UserId, "您的出国申请已通过", "/Apps/YGS/Home/");
                    }
                    else
                    {
                        apply.ApplyStatus = WHConstants.Apply_Status_Rejected;
                        NotificationUtil.SendNotification(apply.UserId, "您的出国申请被拒绝", "/Apps/YGS/Home/");
                    }
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "审批成功"));
                }
            }
        }
Ejemplo n.º 12
0
        public ActionResult DoUpdate(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;
            // 出访日期
            DateTime outDate = new DateTime();

            /*
             * 参数获取
             */
            // 申请ID
            var id = collection["id"];
            // 出访日期
            var outDateString = collection["outDate"];
            // 签证情况
            var signStatus = collection["signStatus"];
            // 履历ID列表
            var outUsers = collection["outUsers"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(id))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(id, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 出访日期
            //if(string.IsNullOrEmpty(outDateString))
            //{
            //    return ResponseUtil.Error(400, "出访日期不能为空");
            //}
            //else
            //{
            //    if(!DateTime.TryParse(outDateString, out outDate))
            //    {
            //        return ResponseUtil.Error(400, "出访日期格式不正确");
            //    }
            //}
            if (!string.IsNullOrEmpty(outDateString))
            {
                if (!DateTime.TryParse(outDateString, out outDate))
                {
                    return(ResponseUtil.Error(400, "出访日期格式不正确"));
                }
            }

            // 履历ID列表
            if (string.IsNullOrEmpty(outUsers))
            {
                return(ResponseUtil.Error(400, "出访人员不能为空"));
            }

            /*
             * 更新申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不能为空"));
                }
                else
                {
                    // 原有的outUsers
                    //var oldOutUsers = apply.OutUsers.Split(',').ToList().Select(int.Parse).ToList();
                    // 最新的outUsers
                    //var currentOutUsers = outUsers.Split(',').ToList().Select(int.Parse).ToList();
                    // 获得筛选掉的用户,并移除
                    //foreach(int outUid in oldOutUsers)
                    //{
                    //    if (!currentOutUsers.Contains(outUid))
                    //    {
                    //        var deleteUser = db.User.Where(n => n.ID == outUid).FirstOrDefault();
                    //        if(deleteUser != null)
                    //        {
                    //            db.User.Remove(deleteUser);
                    //        }
                    //    }
                    //}
                    if (!string.IsNullOrEmpty(outDateString))
                    {
                        apply.OutDate = outDate;
                    }
                    else
                    {
                        apply.OutDate = null;
                    }
                    apply.SignStatus = signStatus;
                    apply.OutUsers   = outUsers;
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "更新成功"));
                }
            }
        }
Ejemplo n.º 13
0
        public ActionResult DoAdd(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 当前用户
            var employee = (User.Identity as AppkizIdentity).Employee;
            // 出访日期
            DateTime outDate = new DateTime();
            // 履历IDs
            List <int> historyIdList = new List <int>();

            /*
             * 参数获取
             */
            // 组团名
            var outName = collection["outName"];
            // 任务描述
            var descn = collection["desc"];
            // 出访类型
            var credType = collection["credType"];
            // 出访人员履历
            var outUsers = collection["outUsers"];
            // 出访日期
            var outDateString = collection["outDate"];
            // 履历ID列表
            var historyIds = collection["historyIds"];

            /*
             * 参数校验
             */
            // 团组名
            if (string.IsNullOrEmpty(outName))
            {
                return(ResponseUtil.Error(400, "团组名不能为空"));
            }
            // 出访任务
            if (string.IsNullOrEmpty(descn))
            {
                return(ResponseUtil.Error(400, "任务描述不能为空"));
            }
            // 出访类型
            if (string.IsNullOrEmpty(credType))
            {
                return(ResponseUtil.Error(400, "出访类型不能为空"));
            }
            // 人员ID列表
            if (string.IsNullOrEmpty(outUsers))
            {
                return(ResponseUtil.Error(400, "出访人员不能为空"));
            }
            // 出访日期
            if (!string.IsNullOrEmpty(outDateString))
            {
                if (!DateTime.TryParse(outDateString, out outDate))
                {
                    return(ResponseUtil.Error(400, "出访日期格式不正确"));
                }
            }
            // 履历ID列表
            if (!string.IsNullOrEmpty(historyIds))
            {
                historyIdList = historyIds.Split(',').Select(int.Parse).ToList();
            }

            /*
             * 存储申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = new YGS_Apply();
                apply.OutName  = outName;
                apply.Desc     = descn;
                apply.UserId   = employee.EmplID;
                apply.CredType = credType;
                apply.OutUsers = outUsers;
                //apply.ApplyAtt = applyAtt;
                apply.ApplyStatus = WHConstants.Apply_Status_Passed;
                apply.ApplyDate   = DateTime.Now;
                apply.NextStep    = "";
                if (!string.IsNullOrEmpty(outDateString))
                {
                    apply.OutDate = outDate;
                }
                apply.CreateTime = DateTime.Now;
                apply.UpdateTime = DateTime.Now;
                apply.IsDelete   = true;
                db.Apply.Add(apply);
                db.SaveChanges();

                // 更新对应的履历
                if (historyIdList.Count > 0)
                {
                    var histories = db.History.Where(n => historyIdList.Contains(n.ID)).ToList();
                    foreach (var history in histories)
                    {
                        history.ApplyId = apply.ID;
                    }
                    db.SaveChanges();
                }

                return(ResponseUtil.OK(200, "创建成功"));
            }
        }
Ejemplo n.º 14
0
        public ActionResult DoAdd(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 当前用户
            var employee = (User.Identity as AppkizIdentity).Employee;

            /*
             * 参数获取
             */
            // 组团名
            var outName = collection["outName"];
            // 任务描述
            var descn = collection["desc"];
            // 出访类型
            var credType = collection["credType"];
            // 出访人员履历
            var outUsers = collection["outUsers"];
            // 申请附件
            var applyAtt = collection["applyAtt"];

            /*
             * 参数校验
             */
            // 团组名
            if (string.IsNullOrEmpty(outName))
            {
                return(ResponseUtil.Error(400, "团组名不能为空"));
            }
            // 出访任务
            if (string.IsNullOrEmpty(descn))
            {
                return(ResponseUtil.Error(400, "任务描述不能为空"));
            }
            // 出访类型
            if (string.IsNullOrEmpty(credType))
            {
                return(ResponseUtil.Error(400, "出访类型不能为空"));
            }
            // 人员ID列表
            if (string.IsNullOrEmpty(outUsers))
            {
                return(ResponseUtil.Error(400, "出访人员不能为空"));
            }
            // 申请附件ID不能为空
            if (string.IsNullOrEmpty(applyAtt))
            {
                return(ResponseUtil.Error(400, "申请附件不能为空"));
            }

            /*
             * 存储申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = new YGS_Apply();
                apply.OutName     = outName;
                apply.Desc        = descn;
                apply.UserId      = employee.EmplID;
                apply.CredType    = credType;
                apply.OutUsers    = outUsers;
                apply.ApplyAtt    = applyAtt;
                apply.ApplyStatus = WHConstants.Apply_Status_Examing;
                apply.ApplyDate   = DateTime.Now;
                apply.NextStep    = "下载并填写表格";
                apply.CreateTime  = DateTime.Now;
                apply.UpdateTime  = DateTime.Now;
                apply.IsDelete    = false;
                db.Apply.Add(apply);
                db.SaveChanges();

                var notifyUserIdList = NotificationUtil.GetNotificationUsers();

                foreach (var user in notifyUserIdList)
                {
                    NotificationUtil.SendNotification(user, "您有新的出国申请审核", "/Apps/YGS/Home/Check");
                }

                return(ResponseUtil.OK(200, "创建成功"));
            }
        }
Ejemplo n.º 15
0
        public ActionResult Add(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 用户ID
            int uid = 0;
            // 申请ID
            int aid = 0;
            // 签证时间
            DateTime signTime = new DateTime();
            // 是否出行
            bool isOut = true;

            /*
             * 参数获取
             */
            // 申请ID
            var aidString = collection["aid"];
            // 用户ID
            var uidString = collection["uid"];
            // 签证号
            var signNo = collection["signNo"];
            // 签证地
            var signNation = collection["signNation"];
            // 签证时间
            var signTimeString = collection["signTime"];
            // 是否出行
            var isOutString = collection["isOut"];

            /*
             * 参数校验
             */
            // 申请ID
            if (!string.IsNullOrEmpty(aidString))
            {
                if (!int.TryParse(aidString, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 用户ID
            if (string.IsNullOrEmpty(uidString))
            {
                return(ResponseUtil.Error(400, "用户ID不能为空"));
            }
            else
            {
                if (!int.TryParse(uidString, out uid))
                {
                    return(ResponseUtil.Error(400, "用户ID不正确"));
                }
            }
            // 签证号
            if (string.IsNullOrEmpty(signNo) && string.IsNullOrEmpty(signTimeString) && string.IsNullOrEmpty(isOutString) && string.IsNullOrEmpty(signNation))
            {
                return(ResponseUtil.Error(400, "至少填写一项"));
            }
            // 签证时间
            if (!string.IsNullOrEmpty(signTimeString))
            {
                if (!DateTime.TryParse(signTimeString, out signTime))
                {
                    return(ResponseUtil.Error(400, "签证时间格式错误"));
                }
            }
            // 是否出行
            if (!string.IsNullOrEmpty(isOutString))
            {
                if (!bool.TryParse(isOutString, out isOut))
                {
                    return(ResponseUtil.Error(400, "是否出行格式不正确"));
                }
            }

            /*
             * 添加履历
             */
            using (var db = new YGSDbContext())
            {
                var history = new YGS_History();
                if (!string.IsNullOrEmpty(aidString))
                {
                    history.ApplyId = aid;                  // 申请ID
                }
                history.UserId = uid;                       // 用户ID
                history.SignNo = signNo;                    // 签证号
                if (!string.IsNullOrEmpty(signTimeString))  // 签证时间
                {
                    history.SignTime = signTime;
                }
                if (!string.IsNullOrEmpty(signNation))      // 签证地
                {
                    history.SignNation = signNation;
                }
                if (!string.IsNullOrEmpty(isOutString))
                {
                    history.IsOut = isOut;                      // 是否出行
                }

                db.History.Add(history);
                db.SaveChanges();

                return(new JsonNetResult(new
                {
                    code = 200,
                    data = new
                    {
                        id = history.ID
                    }
                }));
            }
        }
Ejemplo n.º 16
0
        public ActionResult Delete(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;
            // 用户ID
            int uid = 0;

            /*
             * 参数获取
             */
            // 申请ID
            var applyId = collection["applyId"];
            // 用户ID
            var userId = collection["userId"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(applyId))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(applyId, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 用户ID
            if (string.IsNullOrEmpty(userId))
            {
                return(ResponseUtil.Error(400, "用户ID不能为空"));
            }
            else
            {
                if (!int.TryParse(userId, out uid))
                {
                    return(ResponseUtil.Error(400, "用户ID不正确"));
                }
            }

            /*
             * 将userId用户从申请的出国人员中去掉
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    // 原有的outUsers
                    var oldOutUsers = apply.OutUsers.Split(',').ToList().Select(int.Parse).ToList();
                    // 最新的outUsers
                    var currentOutUsers = new List <int>();

                    // 获得筛选掉的用户,并移除
                    foreach (int outUid in oldOutUsers)
                    {
                        if (outUid != uid)
                        {
                            currentOutUsers.Add(outUid);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    // 判断是否还有出国人员
                    if (currentOutUsers.Count == 0)
                    {
                        db.Apply.Remove(apply);
                        db.SaveChanges();
                    }
                    else
                    {
                        var finalOutUsers = string.Join(",", currentOutUsers);
                        apply.OutUsers = finalOutUsers;
                        db.SaveChanges();
                    }

                    return(ResponseUtil.Error(200, "删除成功"));
                }
            }
        }
Ejemplo n.º 17
0
        public ActionResult DoUpdate(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;
            // 用户ID
            int id = 0;
            // 性别
            int sex = 0;
            // 出生日期
            DateTime birthday = new DateTime();

            /*
             * 参数获取
             */
            // 申请ID
            var applyId = collection["aid"];
            // 用户ID
            var userId = collection["id"];
            // 姓名
            var name = collection["name"];
            // 性别
            var sexString = collection[@"sex"];
            // 出生地
            var location = collection["location"];
            // 出生日期
            var birthDay = collection["birthDay"];
            // 身份证号
            var credNo = collection["credNo"];
            // 工作单位
            var unit = collection["unit"];
            // 工作部门
            var depart = collection["depart"];
            // 级别
            var level = collection["level"];
            // 职务
            var duty = collection["duty"];

            /*
             * 参数校验
             */
            // 申请ID
            if (!string.IsNullOrEmpty(applyId))
            {
                if (!int.TryParse(applyId, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 用户ID
            if (string.IsNullOrEmpty(userId))
            {
                return(ResponseUtil.Error(400, "用户ID不能为空"));
            }
            else
            {
                if (!int.TryParse(userId, out id))
                {
                    return(ResponseUtil.Error(400, "用户ID不正确"));
                }
            }
            // 姓名
            if (string.IsNullOrEmpty(name))
            {
                return(ResponseUtil.Error(400, "姓名不能为空"));
            }
            // 性别
            if (!string.IsNullOrEmpty(sexString))
            {
                if (int.TryParse(sexString, out sex))
                {
                    if (sex != 0 && sex != 1)
                    {
                        return(ResponseUtil.Error(400, "性别错误"));
                    }
                }
                else
                {
                    return(ResponseUtil.Error(400, "性别错误"));
                }
            }
            // 出生地
            //if (string.IsNullOrEmpty(location))
            //{
            //    return ResponseUtil.Error(400, "出生地不能为空");
            //}
            // 出生日期
            if (!string.IsNullOrEmpty(birthDay))
            {
                if (!DateTime.TryParse(birthDay, out birthday))
                {
                    return(ResponseUtil.Error(400, "出生日期无效"));
                }
            }
            // 身份证号
            if (!string.IsNullOrEmpty(credNo))
            {
                // 校验身份证格式
                if ((!Regex.IsMatch(credNo, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase)))
                {
                    return(ResponseUtil.Error(400, "身份证格式不正确"));
                }
            }
            // 工作单位
            //if (string.IsNullOrEmpty(unit))
            //{
            //    return ResponseUtil.Error(400, "工作单位不能为空");
            //}
            // 工作部门
            //if (string.IsNullOrEmpty(depart))
            //{
            //    return ResponseUtil.Error(400, "工作部门不能为空");
            //}
            // 级别
            //if (string.IsNullOrEmpty(level))
            //{
            //    return ResponseUtil.Error(400, "级别不能为空");
            //}
            // 职务
            //if (string.IsNullOrEmpty(duty))
            //{
            //    return ResponseUtil.Error(400, "职务不能为空");
            //}

            /*
             * 更新用户信息
             */
            using (var db = new YGSDbContext())
            {
                var user = db.User.Where(n => n.ID == id).FirstOrDefault();
                if (user == null)
                {
                    return(ResponseUtil.Error(400, "用户不存在"));
                }
                else
                {
                    var credUser = db.User.Where(n => n.CredNo == credNo && !string.IsNullOrEmpty(credNo)).FirstOrDefault();

                    if (credUser != null)
                    {
                        if (credUser.Name != user.Name)
                        {
                            return(ResponseUtil.Error(400, "相同身份证号用户已存在"));
                        }
                        else
                        {
                            if (credUser.ID == user.ID)
                            {
                                // 同一个用户
                                user.Name     = name;
                                user.Sex      = sex;
                                user.Location = location;
                                if (string.IsNullOrEmpty(birthDay))
                                {
                                    user.BirthDay = null;
                                }
                                else
                                {
                                    user.BirthDay = birthday;
                                }
                                user.CredNo     = credNo;
                                user.Unit       = unit;
                                user.Depart     = depart;
                                user.Level      = level;
                                user.Duty       = duty;
                                user.UpdateTime = DateTime.Now;
                                db.SaveChanges();
                                return(new JsonNetResult(new
                                {
                                    code = 200,
                                    data = new
                                    {
                                        id = user.ID
                                    }
                                }));
                            }
                            else
                            {
                                // 不同用户,同一个名字和身份号,则需要用原有的用户替换现有的用户
                                // 2中情况:
                                // 1. 从审核列表中点击进来,需要替换对应的审核中【外出人员】和对应履历表中【人员ID】
                                // 2. 从人员管理中点击进来,表明该用户已经具有身份证信息,这种情况下说明用户冲突
                                if (string.IsNullOrEmpty(applyId))
                                {
                                    return(ResponseUtil.Error(400, "相同身份证号用户已存在"));
                                }
                                else
                                {
                                    return(new JsonNetResult(new
                                    {
                                        code = 200,
                                        data = new
                                        {
                                            id = credUser.ID
                                        }
                                    }));
                                }
                            }
                        }
                    }
                    else
                    {
                        // 同一个用户
                        user.Name     = name;
                        user.Sex      = sex;
                        user.Location = location;
                        if (string.IsNullOrEmpty(birthDay))
                        {
                            user.BirthDay = null;
                        }
                        else
                        {
                            user.BirthDay = birthday;
                        }
                        user.CredNo     = credNo;
                        user.Unit       = unit;
                        user.Depart     = depart;
                        user.Level      = level;
                        user.Duty       = duty;
                        user.UpdateTime = DateTime.Now;
                        db.SaveChanges();
                        return(new JsonNetResult(new
                        {
                            code = 200,
                            data = new
                            {
                                id = user.ID
                            }
                        }));
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public ActionResult DoAddTempUser(FormCollection collection)
        {
            /*
             * 参数获取
             */
            // 姓名
            var name = collection["name"];
            // 身份证号
            var credNo = collection["credNo"];

            /*
             * 参数校验
             */
            // 姓名
            if (string.IsNullOrEmpty(name))
            {
                return(ResponseUtil.Error(400, "姓名不能为空"));
            }

            /*
             * 查询重复
             */
            using (var db = new YGSDbContext())
            {
                // 身份证号
                if (string.IsNullOrEmpty(credNo))
                {
                    // 身份证号为空,说明只填写了姓名,直接建立新用户,返回新用户ID给前端
                    var user = new YGS_User();
                    user.Name       = name;
                    user.CreateTime = DateTime.Now;

                    db.User.Add(user);
                    db.SaveChanges();

                    return(new JsonNetResult(new
                    {
                        code = 200,
                        data = new
                        {
                            id = user.ID
                        }
                    }));
                }
                else
                {
                    // 校验身份证格式
                    if ((!Regex.IsMatch(credNo, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase)))
                    {
                        return(ResponseUtil.Error(400, "身份证格式不正确"));
                    }
                    // 输入了身份证号,则进行校验,身份信息是否正确。
                    // 如果身份证与姓名一致,则返回用户ID,如果不正确,则该用户已存在,输入身份证重复
                    var user = db.User.Where(n => n.CredNo == credNo).FirstOrDefault();
                    if (user == null)
                    {
                        user            = new YGS_User();
                        user.Name       = name;
                        user.CredNo     = credNo;
                        user.CreateTime = DateTime.Now;

                        db.User.Add(user);
                        db.SaveChanges();

                        return(new JsonNetResult(new
                        {
                            code = 200,
                            data = new
                            {
                                id = user.ID
                            }
                        }));
                    }
                    else
                    {
                        if (user.Name == name)
                        {
                            return(new JsonNetResult(new
                            {
                                code = 200,
                                data = new
                                {
                                    id = user.ID
                                }
                            }));
                        }
                        else
                        {
                            // 不同人,同身份证
                            return(ResponseUtil.Error(400, "已存在身份证相同的其他用户"));
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public ActionResult DoAdd(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 性别
            int sex = 0;
            // 出生日期
            DateTime birthday = new DateTime();

            /*
             * 参数获取
             */
            // 姓名
            var name = collection["name"];
            // 性别
            var sexString = collection[@"sex"];
            // 出生地
            var location = collection["location"];
            // 出生日期
            var birthDay = collection["birthDay"];
            // 身份证号
            var credNo = collection["credNo"];
            // 工作单位
            var unit = collection["unit"];
            // 工作部门
            var depart = collection["depart"];
            // 级别
            var level = collection["level"];
            // 职务
            var duty = collection["duty"];

            /*
             * 参数校验
             */
            // 姓名
            if (string.IsNullOrEmpty(name))
            {
                return(ResponseUtil.Error(400, "姓名不能为空"));
            }
            // 性别
            if (!string.IsNullOrEmpty(sexString))
            {
                if (int.TryParse(sexString, out sex))
                {
                    if (sex != 0 && sex != 1)
                    {
                        return(ResponseUtil.Error(400, "性别错误"));
                    }
                }
                else
                {
                    return(ResponseUtil.Error(400, "性别错误"));
                }
            }
            // 出生地
            //if (string.IsNullOrEmpty(location))
            //{
            //    return ResponseUtil.Error(400, "出生地不能为空");
            //}
            // 出生日期
            if (!string.IsNullOrEmpty(birthDay))
            {
                if (!DateTime.TryParse(birthDay, out birthday))
                {
                    return(ResponseUtil.Error(400, "出生日期无效"));
                }
            }
            // 身份证号
            if (!string.IsNullOrEmpty(credNo))
            {
                // 校验身份证格式
                if ((!Regex.IsMatch(credNo, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase)))
                {
                    return(ResponseUtil.Error(400, "身份证格式不正确"));
                }
            }
            // 工作单位
            //if (string.IsNullOrEmpty(unit))
            //{
            //    return ResponseUtil.Error(400, "工作单位不能为空");
            //}
            // 工作部门
            //if (string.IsNullOrEmpty(depart))
            //{
            //    return ResponseUtil.Error(400, "工作部门不能为空");
            //}
            // 级别
            //if (string.IsNullOrEmpty(level))
            //{
            //    return ResponseUtil.Error(400, "级别不能为空");
            //}
            // 职务
            //if (string.IsNullOrEmpty(duty))
            //{
            //    return ResponseUtil.Error(400, "职务不能为空");
            //}

            /*
             * 添加用户
             */
            using (var db = new YGSDbContext())
            {
                var user = db.User.Where(n => n.CredNo == credNo && !string.IsNullOrEmpty(credNo)).FirstOrDefault();
                if (user == null)
                {
                    user      = new YGS_User();
                    user.Name = name;
                    if (!string.IsNullOrEmpty(sexString))
                    {
                        user.Sex = sex;
                    }
                    if (!string.IsNullOrEmpty(location))
                    {
                        user.Location = location;
                    }
                    if (!string.IsNullOrEmpty(birthDay))
                    {
                        user.BirthDay = birthday;
                    }
                    if (!string.IsNullOrEmpty(credNo))
                    {
                        user.CredNo = credNo;
                    }
                    if (!string.IsNullOrEmpty(unit))
                    {
                        user.Unit = unit;
                    }
                    if (!string.IsNullOrEmpty(depart))
                    {
                        user.Depart = depart;
                    }
                    if (!string.IsNullOrEmpty(level))
                    {
                        user.Level = level;
                    }
                    if (!string.IsNullOrEmpty(duty))
                    {
                        user.Duty = duty;
                    }
                    user.CreateTime = DateTime.Now;
                    user.UpdateTime = DateTime.Now;
                    db.User.Add(user);
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "创建成功!"));
                }
                else
                {
                    return(ResponseUtil.Error(400, "用户已存在"));
                }
            }
        }