コード例 #1
0
        public override bool Equals(object obj)
        {
            bool result = false;

            if (obj.GetType() == typeof(Award_Public))
            {
                Award_Public _obj = obj as Award_Public;
                if (_obj.Id == this.Id)
                {
                    result = true;
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: Admin_Award.ashx.cs プロジェクト: qaz734913414/TLC
        public static JsonModel AddAward_Helper(string CreateUID, int Year, int Name,
                                                string PrizeContent, DateTime StartTime, DateTime EndTime, DateTime CloseTime)
        {
            JsonModel jsm = null;

            try
            {
                List <Award_Public> Award_Public_List = Constant.Award_Public_List;
                int prize_lastCode = Award_Public_List.Count > 0 ? Award_Public_List.Max(p => (int)p.Code) : 1;


                Award_Public award_Public = Award_Public_List.FirstOrDefault(p => p.Year == Year && p.Name == Name);
                if (award_Public == null)
                {
                    bool hasAcross = false;
                    foreach (Award_Public regu in Award_Public_List)
                    {
                        //if (StartTime <= regu.StartTime && EndTime >= regu.CloseTime)
                        //{
                        //    hasAcross = true;
                        //    break;
                        //}
                        if (StartTime >= regu.StartTime && StartTime <= regu.CloseTime)
                        {
                            hasAcross = true;
                            break;
                        }
                        //if (EndTime >= regu.StartTime && EndTime <= regu.CloseTime)
                        //{
                        //    hasAcross = true;
                        //    break;
                        //}
                    }
                    if (!hasAcross)
                    {
                        Award_Public award_Public_new = new TLC_Model.Award_Public()
                        {
                            CreateUID    = CreateUID,
                            Year         = Year,
                            Name         = Name,
                            PrizeContent = PrizeContent,
                            Code         = prize_lastCode + 1,
                            EndTime      = EndTime,
                            StartTime    = StartTime,
                            CloseTime    = CloseTime,
                            IsCompleate  = (int)IsCompleate.No,
                            CreateTime   = DateTime.Now,
                            IsEnable     = (int)IsEnable.Enable,
                            IsDelete     = 0,
                        };
                        jsm = Constant.Award_Public_S.Add(award_Public_new);
                        if (jsm.errNum == 0)
                        {
                            award_Public_new.Id = Convert.ToInt32(jsm.retData);
                            Constant.Award_Public_List.Add(award_Public_new);
                        }
                        else
                        {
                            jsm = JsonModel.GetJsonModel(300, "操作失败");
                        }
                    }
                    else
                    {
                        jsm = JsonModel.GetJsonModel(300, "和已知的奖项时间交叉");
                    }
                }
                else
                {
                    jsm = JsonModel.GetJsonModel(300, "该期已存在");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(jsm);
        }