Ejemplo n.º 1
0
        public string GetEmployeeByTemplateID()
        {
            int template_id = int.Parse(Request.Params["template_id"]);
            //string companyID = Request.Params["company_id"];
            SysContext db        = new SysContext();
            string     companyID = db.fl_Form.Single(f => f.FormID == template_id).Companys;
            var        query     = (from form in db.fl_Approver
                                    join emp in db.hr_Employee on form.EmployeeID equals emp.EmployeeID into Join_1
                                    from j1 in Join_1.DefaultIfEmpty()
                                    join job in db.hr_Job on form.JobID equals job.JobID into Join_2
                                    from j2 in Join_2.DefaultIfEmpty()
                                    join dept in db.hr_Department on form.DeptID equals dept.DeptID into Join_3
                                    from j3 in Join_3.DefaultIfEmpty()
                                    where form.FormID == template_id && companyID.Contains(form.CompanyID)
                                    orderby form.Employee_Sort, ((j1 == null ? "" : j1.Name))
                                    select new
            {
                Value = form.ApproverID.ToString(),
                form.IsFuzzy,
                FuzzyType = form.FuzzyType.Value,
                Name = ((j3 == null) ? "" : j3.Name) + "-" + (j1 == null ? ((j2 == null) ? "" : j2.Name) : j1.Name),
                DeptID = form.DeptID,
            }).ToList();
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (var item in query)
            {
                string Text = "";
                if (item.DeptID == "111111")
                {
                    Text = "发起部门" + item.Name;
                }
                else if (item.DeptID == "222222")
                {
                    Text = "自定义部门" + item.Name;
                }
                else if (item.DeptID == "444444")
                {
                    Text = "事业部" + item.Name;
                }
                else
                {
                    Text = item.Name;
                }
                items.Add(new SelectListItem {
                    Text = Text, Value = item.Value
                });
            }

            System.Text.StringBuilder optionItems = new System.Text.StringBuilder();
            items.ForEach(delegate(SelectListItem item)
            {
                optionItems.AppendFormat("<option value='{0}'>{1}</option>", item.Value, item.Text);
            });

            return(optionItems.ToString());
        }
Ejemplo n.º 2
0
        public ActionResult ProcessList()
        {
            int tid = int.Parse(Request.QueryString["tid"]);
            //string companyID = Request.QueryString["cid"];
            //string Message = "OK";
            JsonResult json = null;

            try
            {
                SysContext db       = new SysContext();
                var        forms    = db.fl_Approver.AsEnumerable();
                var        emps     = db.hr_Employee.AsEnumerable();
                var        jobs     = db.hr_Job.AsEnumerable();
                var        depts    = db.hr_Department.AsEnumerable();
                var        companys = db.hr_Company.AsEnumerable();

                //string companyID = db.fl_Form.Single(f => f.FormID == tid).CompanyID;
                var tfd   = db.fl_FormTemplate.Where(d => d.FormID == tid).AsEnumerable();
                var query = from form in forms
                            join emp in emps on form.EmployeeID equals emp.EmployeeID into Join_1
                            from j1 in Join_1.DefaultIfEmpty()
                            join job in jobs on form.JobID equals job.JobID into Join_2
                            from j2 in Join_2.DefaultIfEmpty()
                            join dept in depts on form.DeptID equals dept.DeptID into Join_3
                            from j3 in Join_3.DefaultIfEmpty()
                            join template_detail in tfd on form.TemplateID equals template_detail.TemplateID into Join_4
                            from j4 in Join_4.DefaultIfEmpty()
                            join company in companys on form.CompanyID equals company.CompanyID into Join_5
                            from j5 in Join_5.DefaultIfEmpty()
                            where form.FormID == tid
                            orderby form.Employee_Sort, ((j1 == null ? "" : j1.Name))
                select new
                {
                    approveform_id = form.ApproverID,
                    CompanyID      = (j5 == null) ? "" : j5.Name,
                    emp_sort       = form.Employee_Sort,
                    emp_name       = (form.EmployeeID == "333333") ? "自定义签核" : (j1 == null) ? "" : j1.Name,
                    dept_name      = (form.DeptID == "111111" || form.DeptID == "222222" || form.DeptID == "444444") ? Getdept_id(form.DeptID) : (j3 == null) ? "" : j3.Name,
                    job_name       = form.IsFuzzy ? GetFuzzyName(form.FuzzyType.Value) : (j2 == null) ? "" : j2.Name,
                    template_name  = (j4 == null) ? "" : j4.Template_Name,
                    isGroup        = form.IsGroupApprover?"同组":"逐一",
                    dept_id        = (j3 == null) ? "" : j3.DeptID,
                    job_id         = (j2 == null) ? "" : j2.JobID,
                    emp_id_emp     = (form.EmployeeID == "333333")?"自定义签核":(j1 == null) ? "" : j1.EmployeeID
                };
                json = Json(new { rows = query }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                //Message = "Error";
            }
            return(json);
        }
Ejemplo n.º 3
0
        public ActionResult RuleList()
        {
            int tid = int.Parse(Request.QueryString["tid"]);
            //string companyID = Request.QueryString["cid"];
            //string Message = "OK";
            JsonResult json = null;

            try
            {
                SysContext db        = new SysContext();
                var        rules     = db.fl_ApproveRules.AsEnumerable();
                var        forms     = db.fl_Approver.AsEnumerable();
                var        emps      = db.hr_Employee.AsEnumerable();
                var        jobs      = db.hr_Job.AsEnumerable();
                var        depts     = db.hr_Department.AsEnumerable();
                string     companyID = db.fl_Form.Single(f => f.FormID == tid).Companys;
                var        query     = from rule in rules
                                       join form in forms on rule.ApproverID equals form.ApproverID
                                       join emp in emps on form.EmployeeID equals emp.EmployeeID into Join_1
                                       from j1 in Join_1.DefaultIfEmpty()
                                       join job in jobs on form.JobID equals job.JobID into Join_2
                                       from j2 in Join_2.DefaultIfEmpty()
                                       join dept in depts on form.DeptID equals dept.DeptID into Join_3
                                       from j3 in Join_3.DefaultIfEmpty()
                                       where rule.FormID == tid && companyID.Contains(form.CompanyID)
                                       orderby rule.Col_Name, form.Employee_Sort, ((j1 == null ? "" : j1.Name))
                select new
                {
                    ApproveRulesid  = rule.ApproveRulesid,
                    Col_Name        = rule.Col_Name,
                    Condition       = rule.Condition,
                    ApproveFormName = GetNameForRule(form, j1, j2, j3)
                };
                json = Json(new { rows = query }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                //Message = "Error";
            }
            return(json);
        }