protected override void OnSaving()
        {
            if (string.IsNullOrEmpty(this.员工编号))
            {
                throw new Exception("员工编号不能为空");
            }
            if (this.期号 == 0)
            {
                throw new Exception("期号不能为空");
            }

            MonthlySalaryInput found = GetMonthlySalaryInput(this.员工编号, this.期号, this.是验证录入);

            if (found != null && found.标识 != this.标识)
            {
                throw new Exception("本期已存在该员工的月薪标准,不能创建。");
            }
            else
            {
                base.OnSaving();
            }

            contentDifferentFields = null;
            MONTHLY_SALARY_INPUT_CACHE.Set(CacheKey, this, TimeSpan.FromHours(1));
        }
        public static MonthlySalaryInput AddMonthlySalaryInput(string emplid, int period, bool isVerify, bool copyEffective)
        {
            MonthlySalaryInput item = GetMonthlySalaryInput(emplid, period, isVerify);

            if (item == null)
            {
                item = new MonthlySalaryInput();

                if (copyEffective)
                {
                    //将当前执行的标准带过来
                    MonthlySalary effectiveMonthlySalary = MonthlySalary.GetEffective(emplid, DateTime.Today);
                    if (effectiveMonthlySalary != null)
                    {
                        item.CopyEffective = copyEffective;
                        effectiveMonthlySalary.CopyWatchMember(item);
                    }
                }

                item.标识    = Guid.NewGuid();
                item.员工编号  = emplid;
                item.期号    = period;
                item.是验证录入 = isVerify;
                item.薪酬体系  = "";
                item.录入人   = "   ";
                item.录入时间  = DateTime.Now;

                item.Save();
            }
            return(item);
        }
        //更新到正式表
        public void UpdateToFormalTable()
        {
            MonthlySalary m = MonthlySalary.GetMonthlySalary(this.员工编号, this.开始执行日期);

            if (m == null)
            {
                m    = new MonthlySalary();
                m.标识 = Guid.NewGuid();
            }
            this.CopyWatchMember(m);
            m.序号   = this.序号;
            m.备注   = m.调整类型;
            m.截止日期 = DateTime.MinValue;
            m.Save();

            //历史记录失效
            List <MonthlySalary> list = MonthlySalary.GetMonthlySalarys(this.员工编号);
            MonthlySalary        prev = null;

            foreach (MonthlySalary item in list)
            {
                if (item.标识 == m.标识 || item.截止日期 != DateTime.MinValue || prev == null)
                {
                    prev = item;
                    continue;
                }
                item.截止日期 = prev.开始执行日期.AddDays(-1);
                item.Save();
                prev = item;
            }

            //更新生效标记
            if (!this.已生效)
            {
                this.生效时间 = DateTime.Now;
                this.Save();

                MonthlySalaryInput opposite = 另一人录入的记录;
                opposite.生效时间 = DateTime.Now;
                opposite.Save();
            }
        }
        public static MonthlySalaryInput GetMonthlySalaryInput(Guid id)
        {
            MonthlySalaryInput obj = (MonthlySalaryInput)Session.DefaultSession.GetObjectByKey(typeof(MonthlySalaryInput), id);

            return(obj);
        }