コード例 #1
0
        public string AddEmployee(Panasia.Gemini.FL.Models.ProcessModel model)
        {
            bool   IsFuzzy             = model.IsFuzzy;
            string dept_id             = IsFuzzy ? "" : model.dept_id;
            string job_id              = IsFuzzy ? "" : model.job_id;
            string emp_id_emp          = IsFuzzy ? "" : model.emp_id_emp;
            int    emp_sort            = model.emp_sort;
            int    TemplateID          = model.FormID;
            int    FuzzyType           = IsFuzzy ? model.FuzzyType : 0;
            string CompanyID           = model.CompanyID;
            string Message             = "OK";
            string EmployeeIDCondition = model.hEmployeeIDCondition;
            string DeptIDCondition     = model.hDeptIDCondition;
            bool   IsGroupApprover     = model.IsGroupApprover;

            if (emp_id_emp == "333333" && model.hEmployeeIDCondition == null)
            {
                emp_id_emp = "";
            }
            if (dept_id == "222222" && model.hDeptIDCondition == null)
            {
                dept_id = "111111";
            }
            using (SysContext db = new SysContext())
            {
                try
                {
                    //bool isg = db.fl_Approver.Where(a => a.FormID == TemplateID && a.Employee_Sort == emp_sort).First().IsGroupApprover;
                    //if (isg == IsGroupApprover)
                    //{
                    fl_Approver entity_fl_Approve = new fl_Approver();
                    entity_fl_Approve.FormID              = TemplateID;
                    entity_fl_Approve.Employee_Sort       = emp_sort;
                    entity_fl_Approve.EmployeeID          = emp_id_emp == null ? "" : emp_id_emp;
                    entity_fl_Approve.DeptID              = dept_id;
                    entity_fl_Approve.JobID               = job_id;
                    entity_fl_Approve.IsFuzzy             = IsFuzzy;
                    entity_fl_Approve.FuzzyType           = FuzzyType;
                    entity_fl_Approve.TemplateID          = model.TemplateID;
                    entity_fl_Approve.CompanyID           = CompanyID;
                    entity_fl_Approve.DeptIDCondition     = DeptIDCondition;
                    entity_fl_Approve.EmployeeIDCondition = EmployeeIDCondition;
                    entity_fl_Approve.IsGroupApprover     = IsGroupApprover;
                    entity_fl_Approve.CreatedUser         = LoginInfo.UserID;
                    entity_fl_Approve.ModifiedUser        = LoginInfo.UserID;
                    entity_fl_Approve.ResetCreated();


                    db.fl_Approver.Add(entity_fl_Approve);
                    db.SaveChanges();
                    //}
                    //else
                    //{
                    //    Message = "同一次序必须选择相同的签核次序";
                    //}
                }
                catch
                {
                    Message = "Error";
                }
            }
            return(Message);
        }
コード例 #2
0
        public string AddEmployee(Panasia.Gemini.FL.Models.ProcessModel model)
        {
            bool   IsFuzzy             = model.IsFuzzy;
            string dept_id             = IsFuzzy ? "" : model.dept_id;
            string job_id              = IsFuzzy ? "" : model.job_id;
            string emp_id_emp          = IsFuzzy ? "" : model.emp_id_emp;
            int    emp_sort            = model.emp_sort;
            int    TemplateID          = model.FormID;
            int    FuzzyType           = IsFuzzy ? model.FuzzyType : 0;
            string CompanyID           = model.CompanyID;
            string Message             = "OK";
            string EmployeeIDCondition = model.hEmployeeIDCondition;
            string DeptIDCondition     = model.hDeptIDCondition;
            bool   IsGroupApprover     = model.IsGroupApprover;
            string Approverid          = model.Approverid;
            string Approver            = model.Approver;

            if (emp_id_emp == "333333" && model.hEmployeeIDCondition == null)
            {
                emp_id_emp = "";
            }
            if (dept_id == "222222" && model.hDeptIDCondition == null)
            {
                dept_id = "111111";
            }
            using (SysContext db = new SysContext())
            {
                try
                {
                    //bool isg = db.fl_Approver.Where(a => a.FormID == TemplateID && a.Employee_Sort == emp_sort).First().IsGroupApprover;
                    //if (isg == IsGroupApprover)
                    //{
                    if (string.IsNullOrEmpty(Approverid))
                    {
                        fl_Approver entity_fl_Approve = new fl_Approver();
                        entity_fl_Approve.FormID              = TemplateID;
                        entity_fl_Approve.Employee_Sort       = emp_sort;
                        entity_fl_Approve.EmployeeID          = emp_id_emp == null ? "" : emp_id_emp;
                        entity_fl_Approve.DeptID              = dept_id;
                        entity_fl_Approve.JobID               = job_id;
                        entity_fl_Approve.IsFuzzy             = IsFuzzy;
                        entity_fl_Approve.FuzzyType           = FuzzyType;
                        entity_fl_Approve.TemplateID          = model.TemplateID;
                        entity_fl_Approve.CompanyID           = CompanyID;
                        entity_fl_Approve.DeptIDCondition     = DeptIDCondition;
                        entity_fl_Approve.EmployeeIDCondition = EmployeeIDCondition;
                        entity_fl_Approve.IsGroupApprover     = IsGroupApprover;
                        entity_fl_Approve.CreatedUser         = LoginInfo.UserID;
                        entity_fl_Approve.ModifiedUser        = LoginInfo.UserID;
                        entity_fl_Approve.ResetCreated();


                        db.fl_Approver.Add(entity_fl_Approve);
                        db.SaveChanges();
                    }
                    else
                    {
                        string[] Approverids = Approverid.Split(',');
                        foreach (var arr in Approverids)
                        {
                            int         aid               = int.Parse(arr.ToString());
                            fl_Approver fl_Approve        = db.fl_Approver.Single(a => a.ApproverID == aid);
                            fl_Approver entity_fl_Approve = new fl_Approver();
                            entity_fl_Approve.FormID              = int.Parse(model.form_id);
                            entity_fl_Approve.Employee_Sort       = fl_Approve.Employee_Sort;
                            entity_fl_Approve.EmployeeID          = fl_Approve.EmployeeID;
                            entity_fl_Approve.DeptID              = fl_Approve.DeptID;
                            entity_fl_Approve.JobID               = fl_Approve.JobID;
                            entity_fl_Approve.IsFuzzy             = fl_Approve.IsFuzzy;
                            entity_fl_Approve.FuzzyType           = fl_Approve.FuzzyType;
                            entity_fl_Approve.TemplateID          = fl_Approve.TemplateID;
                            entity_fl_Approve.CompanyID           = fl_Approve.CompanyID;
                            entity_fl_Approve.DeptIDCondition     = fl_Approve.DeptIDCondition;
                            entity_fl_Approve.EmployeeIDCondition = fl_Approve.EmployeeIDCondition;
                            entity_fl_Approve.IsGroupApprover     = fl_Approve.IsGroupApprover;
                            entity_fl_Approve.CreatedUser         = fl_Approve.CreatedUser;
                            entity_fl_Approve.ModifiedUser        = fl_Approve.ModifiedUser;
                            entity_fl_Approve.ResetCreated();

                            db.fl_Approver.Add(entity_fl_Approve);
                            db.SaveChanges();
                        }
                        if (!string.IsNullOrEmpty(Approver))
                        {
                            string[] Approvers = Approver.Split('|');
                            foreach (var arr in Approvers)
                            {
                                string[]    fl_Approves       = arr.Replace("undefined", "").Split(',');
                                fl_Approver entity_fl_Approve = new fl_Approver();
                                entity_fl_Approve.FormID              = int.Parse(model.form_id);
                                entity_fl_Approve.Employee_Sort       = int.Parse(fl_Approves[5].ToString());
                                entity_fl_Approve.EmployeeID          = fl_Approves[4];
                                entity_fl_Approve.DeptID              = fl_Approves[2];
                                entity_fl_Approve.JobID               = fl_Approves[3];
                                entity_fl_Approve.IsFuzzy             = false;
                                entity_fl_Approve.FuzzyType           = 1;
                                entity_fl_Approve.TemplateID          = int.Parse(fl_Approves[0].ToString());
                                entity_fl_Approve.CompanyID           = fl_Approves[1];
                                entity_fl_Approve.DeptIDCondition     = fl_Approves[6];
                                entity_fl_Approve.EmployeeIDCondition = fl_Approves[7];
                                entity_fl_Approve.IsGroupApprover     = bool.Parse(fl_Approves[8].ToString());
                                entity_fl_Approve.CreatedUser         = LoginInfo.UserID;
                                entity_fl_Approve.ModifiedUser        = LoginInfo.UserID;
                                entity_fl_Approve.ResetCreated();

                                db.fl_Approver.Add(entity_fl_Approve);
                                db.SaveChanges();
                            }
                        }
                    }
                    //}
                    //else
                    //{
                    //    Message = "同一次序必须选择相同的签核次序";
                    //}
                }
                catch
                {
                    Message = "Error";
                }
            }
            return(Message);
        }