Exemplo n.º 1
0
        public static PersonBorrowInput AddPersonBorrowInput(string number, string empNo, bool isVerify)
        {
            PersonBorrowInput item = Get(number, isVerify);

            if (item == null)
            {
                item        = new PersonBorrowInput();
                item.标识     = Guid.NewGuid();
                item.编号     = number;
                item.员工编号   = empNo;
                item.是验证录入  = isVerify;
                item.双人录入结果 = " ";
                item.录入人    = "   ";
                item.录入时间   = DateTime.Now;

                PersonBorrowInput otherItem = Get(number, !isVerify);
                if (otherItem != null)
                {
                    item.姓名   = otherItem.姓名;
                    item.项目   = otherItem.项目;
                    item.生效日期 = MyHelper.GetPrevMonth1Day();
                }

                item.Save();
            }
            return(item);
        }
Exemplo n.º 2
0
        /// <param name="id"></param>
        /// <returns></returns>
        public static PersonBorrowInput Get(Guid id)
        {
            PersonBorrowInput obj = (PersonBorrowInput)MyHelper.XpoSession.GetObjectByKey(typeof(PersonBorrowInput), id);

            return(obj);
        }
Exemplo n.º 3
0
        protected override void OnSaving()
        {
            if (string.IsNullOrEmpty(this.员工编号))
            {
                throw new Exception("员工编号不能为空。");
            }
            if (PsHelper.GetEmplName(this.员工编号) == "")
            {
                throw new Exception("找不到指定员工编号的员工。");
            }
            if (string.IsNullOrEmpty(this.项目))
            {
                throw new Exception("项目不能为空。");
            }

            if (string.IsNullOrEmpty(编号))
            {
                if (this.生效日期 == DateTime.MinValue)
                {
                    throw new Exception("生效日期不能为空。");
                }

                if (this.标识 == Guid.Empty)
                {
                    this.标识 = Guid.NewGuid();
                }

                PersonBorrowInput other = GetEditing(this.员工编号, this.项目, this.生效日期, !this.是验证录入);
                this.编号 = other == null?GetNewNumber() : other.编号;

                //如果是新编号,更新编号信息的当前序号
                this.NumberInfo.UpdateCurrentSN();

                PersonBorrowInput found = Get(this.编号, this.是验证录入);
                if (found != null && found.标识 != this.标识)
                {
                    throw new Exception(String.Format("同一编号【{0}】不能重复创建,请稍后重试。", this.编号));
                }

                found = GetEditing(this.员工编号, this.项目, this.生效日期, this.是验证录入);
                if (found != null && found.标识 != this.标识)
                {
                    throw new Exception(String.Format("该员工【{0}】已经有一条{1}借款正在录入,不能重复。", this.员工编号, this.项目));
                }
            }


            if (另一人录入的记录 != null)
            {
                TimeSpan ts = DateTime.Now - 另一人录入的记录.录入时间;
                if (ts.TotalMilliseconds > 10000 && 另一人录入的记录.录入人 == AccessController.CurrentUser.姓名)
                {
                    throw new Exception("两次录入不能是同一个人。");
                }
            }

            if (string.IsNullOrEmpty(this.录入人) || (DateTime.Now - this.录入时间).TotalMilliseconds > 10000)
            {
                this.录入人  = AccessController.CurrentUser.姓名;
                this.录入时间 = DateTime.Now;
            }

            if (this.双人录入结果 == null)
            {
                this.双人录入结果 = "";
            }

            if (this.每月扣还 == 0 && this.返还年限 > 0)
            {
                this.每月扣还 = this.金额 / (decimal)(this.返还年限 * 12);
            }

            base.OnSaving();
        }