Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int AddPeriodTotal(PeriodTotalInfo info)
        {
            string strSql = "insert into PeriodTotal(PeriodDay,PeriodBool) values (@PeriodDay,@PeriodBool)";

            return(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteNonQuery(strSql, new DbParameter[] {
                new SQLiteParameter()
                {
                    Value = info.PeriodDay, ParameterName = "@PeriodDay"
                },
                new SQLiteParameter()
                {
                    Value = info.PeriodBool, ParameterName = "@PeriodBool"
                }
            }));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info">根据ID修改信息</param>
        /// <returns></returns>
        public int UpdatePeriodTotal(PeriodTotalInfo info)
        {
            string strSql = "update PeriodTotal set PeriodDay=@PeriodDay,PeriodBool=@PeriodBool where PeriodTotalId=@PeriodTotalId";

            return(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteNonQuery(strSql, new DbParameter[] {
                new SQLiteParameter()
                {
                    Value = info.PeriodTotalId, ParameterName = "@PeriodTotalId"
                },
                new SQLiteParameter()
                {
                    Value = info.PeriodBool, ParameterName = "@PeriodBool"
                },
                new SQLiteParameter()
                {
                    Value = info.PeriodDay, ParameterName = "@PeriodDay"
                }
            }));
        }
Пример #3
0
        public bool IsPeriod(string szHardNumber)
        {
            //return false;
            //UpdatePeriodTotal(new PeriodTotalInfo() { PeriodTotalId = 2, PeriodDay = 1, PeriodBool = true });
            DateTime   CurrentDateTime = DateTime.Now;
            PeriodInfo info            = PeriodBll.GetPeriod(szHardNumber);

            PeriodTotalInfo tinfo = GetPeriodTotal();

            if (tinfo == null)
            {
                //默认试用30天
                AddPeriodTotal(new PeriodTotalInfo()
                {
                    PeriodBool = false,
                    PeriodDay  = 30
                });



                if (info == null)
                {
                    PeriodBll.AddPeriod(new PeriodInfo()
                    {
                        PeriodAlias   = "",
                        PeriodDay     = 30,
                        PeriodNumber  = szHardNumber,
                        StartDateTime = CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss")
                    });
                }

                return(false);
            }
            else
            {
                if (tinfo.PeriodBool)
                {
                    //试用版本
                    if (info == null)
                    {
                        PeriodBll.AddPeriod(new PeriodInfo()
                        {
                            PeriodAlias   = "",
                            PeriodDay     = 30,
                            PeriodNumber  = GetHardDiskNumber(),
                            StartDateTime = CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                        return(false);
                    }
                    else
                    {
                        DateTime dt;
                        bool     result = DateTime.TryParse(info.StartDateTime, out dt);
                        if (result)
                        {
                            if (dt.AddDays(tinfo.PeriodDay) < CurrentDateTime)
                            {
                                //到期
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            //时间类型转换失败,直接试用时间到期
                            return(true);
                        }
                    }
                }
                else
                {
                    //未开启试用版本
                    return(false);
                }
            }
        }