Exemplo n.º 1
0
        public void CountdownJob()
        {
            try
            {
                string sql = "select * from sale_countdown where status in ( " + (int)AppEnum.CountdownStatus.Ready + "," + (int)AppEnum.CountdownStatus.Running + ")";
                DataSet ds = SqlHelper.ExecuteDataSet(sql);
                if (!Util.HasMoreRow(ds))
                    return;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    CountdownInfo oCountdown = new CountdownInfo();
                    map(oCountdown, dr);
                    if (oCountdown.Status == (int)AppEnum.CountdownStatus.Ready && (oCountdown.StartTime < DateTime.Now && oCountdown.EndTime >= DateTime.Now))
                    {
                        if (!this.SetRunning(oCountdown.SysNo))
                            this.SetAbandon(oCountdown.SysNo);
                    }
                    if (oCountdown.Status == (int)AppEnum.CountdownStatus.Running && (oCountdown.EndTime < DateTime.Now))
                    {
                        if (oCountdown.Type == (int)AppEnum.CountdownType.OneTime)
                        {
                            this.SetFinish(oCountdown.SysNo);
                        }
                        else if (oCountdown.Type == (int)AppEnum.CountdownType.EveryDay)
                        {
                            this.SetFinish(oCountdown.SysNo);
                            oCountdown.StartTime = oCountdown.StartTime.AddDays(1);
                            oCountdown.EndTime = oCountdown.EndTime.AddDays(1);
                            oCountdown.Status = (int)AppEnum.CountdownStatus.Ready;
                            this.Update(oCountdown);
                        }
                    }
                }
            }
            catch
            {

            }
        }
Exemplo n.º 2
0
 private void map(CountdownInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.CreateUserSysNo = Util.TrimIntNull(tempdr["CreateUserSysNo"]);
     oParam.CreateTime = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.ProductSysNo = Util.TrimIntNull(tempdr["ProductSysNo"]);
     oParam.StartTime = Util.TrimDateNull(tempdr["StartTime"]);
     oParam.EndTime = Util.TrimDateNull(tempdr["EndTime"]);
     oParam.CountDownCurrentPrice = Util.TrimDecimalNull(tempdr["CountDownCurrentPrice"]);
     oParam.CountDownCashRebate = Util.TrimDecimalNull(tempdr["CountDownCashRebate"]);
     oParam.CountDownPoint = Util.TrimIntNull(tempdr["CountDownPoint"]);
     oParam.CountDownQty = Util.TrimIntNull(tempdr["CountDownQty"]);
     oParam.SnapShotCurrentPrice = Util.TrimDecimalNull(tempdr["SnapShotCurrentPrice"]);
     oParam.SnapShotCashRebate = Util.TrimDecimalNull(tempdr["SnapShotCashRebate"]);
     oParam.SnapShotPoint = Util.TrimIntNull(tempdr["SnapShotPoint"]);
     oParam.AffectedVirtualQty = Util.TrimIntNull(tempdr["AffectedVirtualQty"]);
     oParam.Status = Util.TrimIntNull(tempdr["Status"]);
     oParam.Type = Util.TrimIntNull(tempdr["Type"]);
 }
Exemplo n.º 3
0
 public void Update(CountdownInfo oParam)
 {
     new CountdownDac().Update(oParam);
 }
Exemplo n.º 4
0
 public CountdownInfo Load(int sysno)
 {
     string sql = "select * from sale_countdown where sysno = " + sysno;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if (!Util.HasMoreRow(ds))
         throw new BizException("no records use this sysno");
     CountdownInfo oInfo = new CountdownInfo();
     map(oInfo, ds.Tables[0].Rows[0]);
     return oInfo;
 }
Exemplo n.º 5
0
        public void Insert(CountdownInfo oParam)
        {
            //��Ч�ļ�¼����ͬ��Ʒ��ʱ�β����ظ�
            //����һά����A(x,y), B(a,b), ��֪x>y, a>b���ж�AB�Ƿ��غϡ�
            // AB���غϿ��������ж� (y<a || x>b), ������ϵ�ı��ʽ ( y>=a && x<=b).
            // x=sale_countdown.StartTime
            // y=sale_countdown.EndTime
            // a=oParam.StartTime
            // b=oParam.EndTime
            string sql = "select top 1 sysno from sale_countdown where "
                + " status in (" + (int)AppEnum.CountdownStatus.Ready + "," + (int)AppEnum.CountdownStatus.Running + ")"
                + " and productsysno = " + oParam.ProductSysNo
                + " and (EndTime>=" + Util.ToSqlString(oParam.StartTime.ToString(AppConst.DateFormatLong))
                + " and StartTime<=" + Util.ToSqlString(oParam.EndTime.ToString(AppConst.DateFormatLong)) + ")";

            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if (Util.HasMoreRow(ds))
                throw new BizException("��Ч�ļ�¼����ͬ��Ʒ��ʱ�β����ظ�");

            new CountdownDac().Insert(oParam);
        }
Exemplo n.º 6
0
        public CountdownInfo GetCountdownRunningByProductSysNo(int productSysNo)
        {
            string sql = "select * from sale_countdown where productsysno = " + productSysNo + " and status=" + (int)AppEnum.CountdownStatus.Running;
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if (!Util.HasMoreRow(ds))
                return null;

            if (ds.Tables[0].Rows.Count != 1)
                throw new BizException("��ʱ���������ظ�!");

            CountdownInfo oCountdown = new CountdownInfo();
            map(oCountdown, ds.Tables[0].Rows[0]);
            return oCountdown;
        }
Exemplo n.º 7
0
        public int Insert(CountdownInfo oParam)
        {
            string sql = @"INSERT INTO Sale_Countdown
                            (
                            CreateUserSysNo, CreateTime, ProductSysNo,
                            StartTime, EndTime, CountDownCurrentPrice, CountDownCashRebate,
                            CountDownPoint, CountDownQty, SnapShotCurrentPrice, SnapShotCashRebate,
                            SnapShotPoint, AffectedVirtualQty, Status, Type
                            )
                            VALUES (
                            @CreateUserSysNo, @CreateTime, @ProductSysNo,
                            @StartTime, @EndTime, @CountDownCurrentPrice, @CountDownCashRebate,
                            @CountDownPoint, @CountDownQty, @SnapShotCurrentPrice, @SnapShotCashRebate,
                            @SnapShotPoint, @AffectedVirtualQty, @Status, @Type
                            );set @SysNo = SCOPE_IDENTITY();";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int, 4);
            SqlParameter paramStartTime = new SqlParameter("@StartTime", SqlDbType.DateTime);
            SqlParameter paramEndTime = new SqlParameter("@EndTime", SqlDbType.DateTime);
            SqlParameter paramCountDownCurrentPrice = new SqlParameter("@CountDownCurrentPrice", SqlDbType.Decimal, 9);
            SqlParameter paramCountDownCashRebate = new SqlParameter("@CountDownCashRebate", SqlDbType.Decimal, 9);
            SqlParameter paramCountDownPoint = new SqlParameter("@CountDownPoint", SqlDbType.Int, 4);
            SqlParameter paramCountDownQty = new SqlParameter("@CountDownQty", SqlDbType.Int, 4);
            SqlParameter paramSnapShotCurrentPrice = new SqlParameter("@SnapShotCurrentPrice", SqlDbType.Decimal, 9);
            SqlParameter paramSnapShotCashRebate = new SqlParameter("@SnapShotCashRebate", SqlDbType.Decimal, 9);
            SqlParameter paramSnapShotPoint = new SqlParameter("@SnapShotPoint", SqlDbType.Int, 4);
            SqlParameter paramAffectedVirtualQty = new SqlParameter("@AffectedVirtualQty", SqlDbType.Int, 4);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4);
            SqlParameter paramType = new SqlParameter("@Type", SqlDbType.Int, 4);

            paramSysNo.Direction = ParameterDirection.Output;

            if (oParam.CreateUserSysNo != AppConst.IntNull)
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            else
                paramCreateUserSysNo.Value = System.DBNull.Value;
            if (oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;
            if (oParam.ProductSysNo != AppConst.IntNull)
                paramProductSysNo.Value = oParam.ProductSysNo;
            else
                paramProductSysNo.Value = System.DBNull.Value;
            if (oParam.StartTime != AppConst.DateTimeNull)
                paramStartTime.Value = oParam.StartTime;
            else
                paramStartTime.Value = System.DBNull.Value;
            if (oParam.EndTime != AppConst.DateTimeNull)
                paramEndTime.Value = oParam.EndTime;
            else
                paramEndTime.Value = System.DBNull.Value;
            if (oParam.CountDownCurrentPrice != AppConst.DecimalNull)
                paramCountDownCurrentPrice.Value = oParam.CountDownCurrentPrice;
            else
                paramCountDownCurrentPrice.Value = System.DBNull.Value;
            if (oParam.CountDownCashRebate != AppConst.DecimalNull)
                paramCountDownCashRebate.Value = oParam.CountDownCashRebate;
            else
                paramCountDownCashRebate.Value = System.DBNull.Value;
            if (oParam.CountDownPoint != AppConst.IntNull)
                paramCountDownPoint.Value = oParam.CountDownPoint;
            else
                paramCountDownPoint.Value = System.DBNull.Value;
            if (oParam.CountDownQty != AppConst.IntNull)
                paramCountDownQty.Value = oParam.CountDownQty;
            else
                paramCountDownQty.Value = System.DBNull.Value;
            if (oParam.SnapShotCurrentPrice != AppConst.DecimalNull)
                paramSnapShotCurrentPrice.Value = oParam.SnapShotCurrentPrice;
            else
                paramSnapShotCurrentPrice.Value = System.DBNull.Value;
            if (oParam.SnapShotCashRebate != AppConst.DecimalNull)
                paramSnapShotCashRebate.Value = oParam.SnapShotCashRebate;
            else
                paramSnapShotCashRebate.Value = System.DBNull.Value;
            if (oParam.SnapShotPoint != AppConst.IntNull)
                paramSnapShotPoint.Value = oParam.SnapShotPoint;
            else
                paramSnapShotPoint.Value = System.DBNull.Value;
            if (oParam.AffectedVirtualQty != AppConst.IntNull)
                paramAffectedVirtualQty.Value = oParam.AffectedVirtualQty;
            else
                paramAffectedVirtualQty.Value = System.DBNull.Value;
            if (oParam.Status != AppConst.IntNull)
                paramStatus.Value = oParam.Status;
            else
                paramStatus.Value = System.DBNull.Value;
            if (oParam.Type != AppConst.IntNull)
                paramType.Value = oParam.Type;
            else
                paramType.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramCreateUserSysNo);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramProductSysNo);
            cmd.Parameters.Add(paramStartTime);
            cmd.Parameters.Add(paramEndTime);
            cmd.Parameters.Add(paramCountDownCurrentPrice);
            cmd.Parameters.Add(paramCountDownCashRebate);
            cmd.Parameters.Add(paramCountDownPoint);
            cmd.Parameters.Add(paramCountDownQty);
            cmd.Parameters.Add(paramSnapShotCurrentPrice);
            cmd.Parameters.Add(paramSnapShotCashRebate);
            cmd.Parameters.Add(paramSnapShotPoint);
            cmd.Parameters.Add(paramAffectedVirtualQty);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramType);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
Exemplo n.º 8
0
        public int Update(CountdownInfo oParam)
        {
            string sql = @"UPDATE Sale_CountDown SET
                            CreateUserSysNo=@CreateUserSysNo,
                            CreateTime=@CreateTime, ProductSysNo=@ProductSysNo,
                            StartTime=@StartTime, EndTime=@EndTime,
                            CountDownCurrentPrice=@CountDownCurrentPrice, CountDownCashRebate=@CountDownCashRebate,
                            CountDownPoint=@CountDownPoint, CountDownQty=@CountDownQty,
                            SnapShotCurrentPrice=@SnapShotCurrentPrice, SnapShotCashRebate=@SnapShotCashRebate,
                            SnapShotPoint=@SnapShotPoint, AffectedVirtualQty=@AffectedVirtualQty,
                            Status=@Status, Type=@Type
                            WHERE SysNo=@SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int, 4);
            SqlParameter paramStartTime = new SqlParameter("@StartTime", SqlDbType.DateTime);
            SqlParameter paramEndTime = new SqlParameter("@EndTime", SqlDbType.DateTime);
            SqlParameter paramCountDownCurrentPrice = new SqlParameter("@CountDownCurrentPrice", SqlDbType.Decimal, 9);
            SqlParameter paramCountDownCashRebate = new SqlParameter("@CountDownCashRebate", SqlDbType.Decimal, 9);
            SqlParameter paramCountDownPoint = new SqlParameter("@CountDownPoint", SqlDbType.Int, 4);
            SqlParameter paramCountDownQty = new SqlParameter("@CountDownQty", SqlDbType.Int, 4);
            SqlParameter paramSnapShotCurrentPrice = new SqlParameter("@SnapShotCurrentPrice", SqlDbType.Decimal, 9);
            SqlParameter paramSnapShotCashRebate = new SqlParameter("@SnapShotCashRebate", SqlDbType.Decimal, 9);
            SqlParameter paramSnapShotPoint = new SqlParameter("@SnapShotPoint", SqlDbType.Int, 4);
            SqlParameter paramAffectedVirtualQty = new SqlParameter("@AffectedVirtualQty", SqlDbType.Int, 4);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4);
            SqlParameter paramType = new SqlParameter("@Type", SqlDbType.Int, 4);

            if (oParam.SysNo != AppConst.IntNull)
                paramSysNo.Value = oParam.SysNo;
            else
                paramSysNo.Value = System.DBNull.Value;
            if (oParam.CreateUserSysNo != AppConst.IntNull)
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            else
                paramCreateUserSysNo.Value = System.DBNull.Value;
            if (oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;
            if (oParam.ProductSysNo != AppConst.IntNull)
                paramProductSysNo.Value = oParam.ProductSysNo;
            else
                paramProductSysNo.Value = System.DBNull.Value;
            if (oParam.StartTime != AppConst.DateTimeNull)
                paramStartTime.Value = oParam.StartTime;
            else
                paramStartTime.Value = System.DBNull.Value;
            if (oParam.EndTime != AppConst.DateTimeNull)
                paramEndTime.Value = oParam.EndTime;
            else
                paramEndTime.Value = System.DBNull.Value;
            if (oParam.CountDownCurrentPrice != AppConst.DecimalNull)
                paramCountDownCurrentPrice.Value = oParam.CountDownCurrentPrice;
            else
                paramCountDownCurrentPrice.Value = System.DBNull.Value;
            if (oParam.CountDownCashRebate != AppConst.DecimalNull)
                paramCountDownCashRebate.Value = oParam.CountDownCashRebate;
            else
                paramCountDownCashRebate.Value = System.DBNull.Value;
            if (oParam.CountDownPoint != AppConst.IntNull)
                paramCountDownPoint.Value = oParam.CountDownPoint;
            else
                paramCountDownPoint.Value = System.DBNull.Value;
            if (oParam.CountDownQty != AppConst.IntNull)
                paramCountDownQty.Value = oParam.CountDownQty;
            else
                paramCountDownQty.Value = System.DBNull.Value;
            if (oParam.SnapShotCurrentPrice != AppConst.DecimalNull)
                paramSnapShotCurrentPrice.Value = oParam.SnapShotCurrentPrice;
            else
                paramSnapShotCurrentPrice.Value = System.DBNull.Value;
            if (oParam.SnapShotCashRebate != AppConst.DecimalNull)
                paramSnapShotCashRebate.Value = oParam.SnapShotCashRebate;
            else
                paramSnapShotCashRebate.Value = System.DBNull.Value;
            if (oParam.SnapShotPoint != AppConst.IntNull)
                paramSnapShotPoint.Value = oParam.SnapShotPoint;
            else
                paramSnapShotPoint.Value = System.DBNull.Value;
            if (oParam.AffectedVirtualQty != AppConst.IntNull)
                paramAffectedVirtualQty.Value = oParam.AffectedVirtualQty;
            else
                paramAffectedVirtualQty.Value = System.DBNull.Value;
            if (oParam.Status != AppConst.IntNull)
                paramStatus.Value = oParam.Status;
            else
                paramStatus.Value = System.DBNull.Value;
            if (oParam.Type != AppConst.IntNull)
                paramType.Value = oParam.Type;
            else
                paramType.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramCreateUserSysNo);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramProductSysNo);
            cmd.Parameters.Add(paramStartTime);
            cmd.Parameters.Add(paramEndTime);
            cmd.Parameters.Add(paramCountDownCurrentPrice);
            cmd.Parameters.Add(paramCountDownCashRebate);
            cmd.Parameters.Add(paramCountDownPoint);
            cmd.Parameters.Add(paramCountDownQty);
            cmd.Parameters.Add(paramSnapShotCurrentPrice);
            cmd.Parameters.Add(paramSnapShotCashRebate);
            cmd.Parameters.Add(paramSnapShotPoint);
            cmd.Parameters.Add(paramAffectedVirtualQty);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramType);

            return SqlHelper.ExecuteNonQuery(cmd);
        }