//创建流程
        private void StartFlow()
        {
            if (op == "c" || op == "create")
            {
                ent           = this.GetPostedData <UsrTravelWelfare>();
                ent.ApplyTime = DateTime.Now;
                ent.DoCreate();
                id = ent.Id;
            }
            else
            {
                ent = UsrTravelWelfare.Find(id);
            }

            //受理人
            string UserId   = ent.ApproveUserId;
            string UserName = ent.ApproveName;

            string FlowKey = "EmpUsrWelfare";   //工作流key

            if (!string.IsNullOrEmpty(FlowKey))
            {
                string formUrl = "/EmpWelfare/UsrTravelWelfareEdit.aspx?op=r&id=" + id;
                Guid   guid    = Aim.WorkFlow.WorkFlow.StartWorkFlow(id, formUrl, "员工旅游申请", FlowKey, UserInfo.UserID, UserInfo.Name);
                ent.WorkFlowState = "Start";
                ent.WorkFLowCode  = guid.ToString(); //InstanceId
                ent.DoUpdate();
                this.PageState.Add("NextInfo", guid.ToString() + "$" + UserId + "|" + UserName);
            }
        }
        private void DoCreate()
        {
            ent               = this.GetPostedData <UsrTravelWelfare>();
            ent.ApplyTime     = DateTime.Now;
            ent.NoticeId      = RequestData.Get <string>("noticeid");
            ent.TravelAddr    = RequestData.Get("TravelAddr") + "";
            ent.TravelTime    = RequestData.Get("TravelTime") + "";
            ent.Ext1          = RequestData.Get("Ext1") + "";
            ent.CreateId      = UserInfo.UserID;
            ent.CreateName    = UserInfo.LoginName;
            ent.CreateTime    = DateTime.Now;
            ent.WorkFlowState = "1";    //标识 0未提交状态 1已申报

            ent.DoCreate();
            SaveEveryForm(RequestData.GetList <string>("data"), ent);
        }
Exemplo n.º 3
0
        private void AnalysUser(DataTable Dt)
        {
            //判断文件是否为模板格式
            if (Dt.Columns.Count != 11 && Dt.Columns[0].ColumnName != "姓名")
            {
                throw new Exception("文件内容格式不符合模板定义的格式!");
            }

            string guid = string.Empty; //guid

            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                SysUser UserEnt = null; //

                try
                {
                    if (!string.IsNullOrEmpty(Dt.Rows[i]["姓名"] + ""))
                    {
                        UsrTravelWelfare UW = new UsrTravelWelfare();
                        UW.DoCreate();

                        //guid = Guid.NewGuid().ToString();                  //guid
                        guid    = UW.Id;                                     //guid
                        UserEnt = SysUser.FindFirstByProperties(SysUser.Prop_WorkNo, Dt.Rows[i]["工号"]);

                        UW.Id     = guid;
                        UW.UserId = UserEnt.UserID;
                        UW.WorkNo = UserEnt.WorkNo;
                        if (UserEnt.Name != Dt.Rows[i]["姓名"] + "")
                        {
                            UW.UserName = Dt.Rows[i]["姓名"] + "/[" + UserEnt.Name + "]";
                        }
                        else
                        {
                            UW.UserName = UserEnt.Name;
                        }
                        UW.Sex           = UserEnt.Sex;
                        UW.ImpState      = "1";          //导入状态 1成功
                        UW.WorkFlowState = "2";          //标识 同意
                        UW.Result        = "同意";
                        UW.ApplyTime     = DateTime.Now; //申请日期

                        //公司
                        SysGroup GroupEnt = SysGroup.TryFind(UserEnt.Pk_corp);
                        if (GroupEnt != null)
                        {
                            UW.CompanyName = Dt.Rows[i]["公司"] + "";
                            UW.CompanyId   = GroupEnt.GroupID; //通过工号 强制关联公司和部门
                        }
                        //部门
                        GroupEnt = SysGroup.TryFind(UserEnt.Pk_deptdoc);
                        if (GroupEnt != null)
                        {
                            UW.DeptId   = GroupEnt.GroupID;
                            UW.DeptName = Dt.Rows[i]["部门"] + "";
                        }

                        UW.TravelAddr  = Dt.Rows[i]["旅游地点"] + "";        //旅游地点
                        UW.TravelTime  = Dt.Rows[i]["出行时间"] + "";        //出行时间
                        UW.TravelMoney = (decimal)GetMoney(UserEnt, ""); //旅游金额

                        //入职日期
                        if (!string.IsNullOrEmpty(UserEnt.Indutydate))
                        {
                            UW.IndutyDate = DateTime.Parse(UserEnt.Indutydate);
                        }

                        //员工类型 正式员工,实习生
                        string WorkerType = DataHelper.QueryValue("select psnclassname from HR_OA_MiddleDB..fld_rylb where pk_fld_rylb='" + UserEnt.Pk_rylb + "'") + "";
                        UW.WorkerType = WorkerType;

                        //HaveFamily Y
                        if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + ""))
                        {
                            UW.HaveFamily = "Y";
                            UsrTravelInfo UT = new UsrTravelInfo();

                            //家属姓名
                            if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + ""))
                            {
                                UT.Name            = Dt.Rows[i]["家属姓名"] + "";
                                UT.WelfareTravelId = guid;     //* 关联的主键ID
                                UT.CreateTime      = DateTime.Now;
                            }
                            //家属年龄
                            int age = 0;
                            if (int.TryParse(Dt.Rows[i]["家属年龄"] + "", out age))
                            {
                                UT.Age = age;
                                if (age <= 13)  //14 岁为标志
                                {
                                    UT.IsChild = "是";
                                }
                            }

                            //家属性别
                            if (!string.IsNullOrEmpty(Dt.Rows[i]["家属性别"] + ""))
                            {
                                UT.Sex = Dt.Rows[i]["家属性别"] + "";
                            }

                            //家属身高
                            if (!string.IsNullOrEmpty(Dt.Rows[i]["家属身高"] + ""))
                            {
                                Decimal dlb = 0;
                                if (Decimal.TryParse(Dt.Rows[i]["家属身高"] + "", out dlb))
                                {
                                    UT.Height = dlb;
                                }
                            }
                            UT.DoCreate();  //创建家属记录
                        }
                        //计算金额
                        UW.CreateId   = UserInfo.UserID;
                        UW.CreateName = UserInfo.Name;
                        UW.CreateTime = DateTime.Now;
                        UW.DoUpdate();
                    }
                    else
                    {  //家属信息
                        UsrTravelInfo UT = null;
                        if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + ""))
                        {
                            UT = new UsrTravelInfo();

                            //家属姓名
                            if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + ""))
                            {
                                UT.Name            = Dt.Rows[i]["家属姓名"] + "";
                                UT.WelfareTravelId = guid;     //* 关联的主键ID
                                UT.CreateTime      = DateTime.Now;
                            }
                            //家属年龄
                            int age = 0;
                            if (int.TryParse(Dt.Rows[i]["家属年龄"] + "", out age))
                            {
                                UT.Age = age;
                                if (age <= 13)  //14 岁为标志
                                {
                                    UT.IsChild = "是";
                                }
                            }

                            //家属性别
                            if (!string.IsNullOrEmpty(Dt.Rows[i]["家属性别"] + ""))
                            {
                                UT.Sex = Dt.Rows[i]["家属性别"] + "";
                            }

                            //家属身高
                            if (!string.IsNullOrEmpty(Dt.Rows[i]["家属身高"] + ""))
                            {
                                Decimal dlb = 0;
                                if (Decimal.TryParse(Dt.Rows[i]["家属身高"] + "", out dlb))
                                {
                                    UT.Height = dlb;
                                }
                            }
                            UT.DoCreate();  //创建家属记录
                        }
                    }
                }
                catch
                {
                    UsrTravelWelfare UW = new UsrTravelWelfare();
                    UW.ImpState      = "0";         //无该人员或异常
                    UW.WorkFlowState = "Exception"; //异常标识

                    UW.UserName    = Dt.Rows[i]["姓名"] + " [异常]";
                    UW.WorkNo      = Dt.Rows[i]["工号"] + "";
                    UW.CompanyName = Dt.Rows[i]["公司"] + "";
                    UW.DeptName    = Dt.Rows[i]["部门"] + "";
                    UW.TravelAddr  = Dt.Rows[i]["旅游地点"] + "";
                    UW.TravelTime  = Dt.Rows[i]["出行时间"] + "";
                    UW.OtherName   = Dt.Rows[i]["家属姓名"] + " [异常]";
                    UW.CreateTime  = DateTime.Now;
                    UW.DoCreate();
                }
            }
        }