/// <summary>
        /// 服务年限奖励金额修正
        /// </summary>
        private void DoEditMoney()
        {
            string prefix   = FileModule.FindFirstByProperties("Name", "Portal").RootPath + "\\Default\\";
            string FilePath = RequestData.Get("FileId") + "";

            FilePath = prefix + FilePath;
            DataTable      Dt = ExcelToDataTable(FilePath, 4);
            CommPowerSplit Ps = new CommPowerSplit();

            bool IsPower = false;

            if (Ps.IsHR(UserInfo.UserID, UserInfo.LoginName) || Ps.IsAdmin(UserInfo.LoginName) || Ps.IsInAdminsRole(UserInfo.LoginName))
            {
                IsPower = true;
            }

            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                try
                {
                    string   workno  = Dt.Rows[i]["工号"] + "";
                    SysUser  UserEnt = SysUser.FindFirstByProperties(SysUser.Prop_WorkNo, Dt.Rows[i]["工号"]);
                    SysGroup Group   = SysGroup.TryFind(UserEnt.Pk_corp);

                    TravelMoneyConfig TM    = new TravelMoneyConfig();
                    decimal           Money = 0.0m;

                    if (!string.IsNullOrEmpty(Dt.Rows[i]["服务年限奖励金"] + ""))
                    {
                        decimal M = 0.0m;
                        if (decimal.TryParse(Dt.Rows[i]["服务年限奖励金"] + "", out M))
                        {
                            Money = M;
                        }
                    }

                    string HasUsed = string.Empty;
                    if (!string.IsNullOrEmpty(Dt.Rows[i]["是否已用"] + ""))
                    {
                        HasUsed = ((Dt.Rows[i]["是否已用"] + "") == "是" || (Dt.Rows[i]["是否已用"] + "") == "Y") ? "Y" : "N";
                    }

                    string UpdateSQL = @"declare @id varchar(36)
                                        select top 1 @id=Id from FL_Culture..TravelMoneyConfig where WorkNo='{0}' and {3}
                                        order by CreateTime desc ;
                                        update FL_Culture..TravelMoneyConfig set Money={1}, HaveUsed='{2}'
                                        where Id=@id";
                    //权限
                    string Condition = string.Empty;
                    Condition = IsPower ? " 1=1 " : " Corp ='" + Group.GroupID + "'  ";
                    UpdateSQL = string.Format(UpdateSQL, workno, Money, HasUsed, Condition);
                    DataHelper.ExecSql(UpdateSQL);
                }
                catch (Exception e)
                {
                    //throw new Exception(e.Message);
                }
            }
            this.PageState.Add("State", "1");
        }
예제 #2
0
        /// <summary>
        /// 导入人员
        /// </summary>
        private void DoImpUser()
        {
            string prefix   = FileModule.FindFirstByProperties("Name", "Portal").RootPath + "\\Default\\";
            string FilePath = RequestData.Get("FileId") + "";

            FilePath = prefix + FilePath;
            DataTable SourDt = ExcelToDataTable(FilePath);

            AnalysUser(SourDt);  //创建人员

            this.PageState.Add("State", "1");
        }
        /// <summary>
        /// 导入数据
        /// </summary>
        private void DoImpData()
        {
            string prefix   = FileModule.FindFirstByProperties("Name", "Portal").RootPath + "\\Default\\";
            string FilePath = RequestData.Get("FileId") + "";

            FilePath = prefix + FilePath;
            DataTable Dt = ExcelToDataTable(FilePath, 4);

            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                try
                {
                    string   workno    = Dt.Rows[i]["工号"] + "";
                    SysUser  UserEnt   = SysUser.FindFirstByProperties(SysUser.Prop_WorkNo, Dt.Rows[i]["工号"]);
                    SysGroup Group     = SysGroup.TryFind(UserEnt.Pk_corp);
                    SysGroup DeptGroup = SysGroup.TryFind(UserEnt.Pk_deptdoc); //Dept

                    TravelMoneyConfig TM      = new TravelMoneyConfig();
                    ComUtility        Utility = new ComUtility();
                    string            Money   = string.Empty;

                    if (string.IsNullOrEmpty(Dt.Rows[i]["服务年限奖励金"] + ""))
                    {
                        Money = Utility.GetTravelMoney(workno);
                        decimal M = 0.0m;
                        if (decimal.TryParse(Money, out M))
                        {
                            TM.Money = M;
                        }
                    }
                    else
                    {
                        decimal M = 0.0m;
                        if (decimal.TryParse(Dt.Rows[i]["服务年限奖励金"] + "", out M))
                        {
                            TM.Money = M;
                        }
                    }

                    //基本津贴
                    decimal MK        = 0.0m;
                    string  BaseMoney = Utility.GetTravelBaseMoney(workno);
                    if (decimal.TryParse(BaseMoney, out MK))
                    {
                        TM.BaseMoney = MK;
                    }

                    TM.UserId   = UserEnt.UserID;
                    TM.UserName = UserEnt.Name;
                    TM.WorkNo   = UserEnt.WorkNo;

                    DateTime DTime = new DateTime();
                    if (DateTime.TryParse(UserEnt.Indutydate, out DTime))
                    {
                        TM.Indutydate = DTime;
                    }

                    if (!string.IsNullOrEmpty(Dt.Rows[i]["是否已用"] + ""))
                    {
                        string val = string.Empty;
                        val         = ((Dt.Rows[i]["是否已用"] + "") == "是" || (Dt.Rows[i]["是否已用"] + "") == "Y") ? "Y" : "N";
                        TM.HaveUsed = val;
                    }

                    if (Group != null)
                    {
                        TM.Corp     = Group.GroupID;
                        TM.CorpName = Group.Name;
                    }
                    if (DeptGroup != null)
                    {
                        TM.DeptId   = DeptGroup.GroupID;
                        TM.DeptName = DeptGroup.Name;
                    }

                    TM.CreateTime = DateTime.Now;
                    TM.UserId     = UserEnt.UserID;
                    TM.Create();
                }
                catch { }
            }
            this.PageState.Add("State", "1");
        }