Пример #1
0
        public void UpdateCustomerPointRequest(Hashtable paramHash)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (paramHash.ContainsKey("Status"))
                {
                    int sysno     = Int32.Parse(paramHash["SysNo"].ToString());
                    int newStatus = Int32.Parse(paramHash["Status"].ToString());
                    CustomerPointRequestInfo oInfo = LoadCustomerPointRequest(sysno);

                    int curStatus = oInfo.Status;
                    if (curStatus == (int)AppEnum.PointRequestStatus.Origin)
                    {
                        if (newStatus != (int)AppEnum.PointRequestStatus.Audited && newStatus != (int)AppEnum.PointRequestStatus.Abandon)
                        {
                            throw new BizException("非orign状态,无法进行该操作");
                        }
                    }
                    else if (curStatus == (int)AppEnum.PointRequestStatus.Audited)
                    {
                        if (newStatus != (int)AppEnum.PointRequestStatus.Added && newStatus != (int)AppEnum.PointRequestStatus.Origin)
                        {
                            throw new BizException("非audited状态,无法进行该操作");
                        }
                    }
                    else
                    {
                        throw new BizException("无法进行该操作");
                    }

                    new PointDac().UpdateCustomerPointRequest(paramHash);
                    if (newStatus == (int)AppEnum.PointRequestStatus.Added) //增加积分
                    {
                        this.SetScore(oInfo.CustomerSysNo, oInfo.PointAmount, oInfo.PointLogType, oInfo.SysNo + "_" + oInfo.Memo);
                    }
                }
                else
                {
                    new PointDac().UpdateCustomerPointRequest(paramHash);
                }
                scope.Complete();
            }
        }
Пример #2
0
        public CustomerPointRequestInfo LoadCustomerPointRequest(int sysno)
        {
            string  sql = "select * from customer_pointrequest where sysno=" + sysno;
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                CustomerPointRequestInfo oInfo = new CustomerPointRequestInfo();
                map(oInfo, ds.Tables[0].Rows[0]);
                return(oInfo);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
 private void map(CustomerPointRequestInfo oParam, DataRow tempdr)
 {
     oParam.SysNo            = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.CustomerSysNo    = Util.TrimIntNull(tempdr["CustomerSysNo"]);
     oParam.PointSourceType  = Util.TrimIntNull(tempdr["PointSourceType"]);
     oParam.PointSourceSysNo = Util.TrimIntNull(tempdr["PointSourceSysNo"]);
     oParam.PointLogType     = Util.TrimIntNull(tempdr["PointLogType"]);
     oParam.PointAmount      = Util.TrimIntNull(tempdr["PointAmount"]);
     oParam.RequestUserType  = Util.TrimIntNull(tempdr["RequestUserType"]);
     oParam.RequestUserSysNo = Util.TrimIntNull(tempdr["RequestUserSysNo"]);
     oParam.RequestTime      = Util.TrimDateNull(tempdr["RequestTime"]);
     oParam.AuditUserSysNo   = Util.TrimIntNull(tempdr["AuditUserSysNo"]);
     oParam.AuditTime        = Util.TrimDateNull(tempdr["AuditTime"]);
     oParam.AddUserSysNo     = Util.TrimIntNull(tempdr["AddUserSysNo"]);
     oParam.AddTime          = Util.TrimDateNull(tempdr["AddTime"]);
     oParam.AbandonUserSysNo = Util.TrimIntNull(tempdr["AbandonUserSysNo"]);
     oParam.AbandonTime      = Util.TrimDateNull(tempdr["AbandonTime"]);
     oParam.Memo             = Util.TrimNull(tempdr["Memo"]);
     oParam.Status           = Util.TrimIntNull(tempdr["Status"]);
     oParam.PMUserSysNo      = Util.TrimIntNull(tempdr["PMUserSysNo"]);
 }
Пример #4
0
        //---------2006-07-27-------------
//		public int AddScore(int CustomerSysNo,int AddTotalScore,int AddValidScore)
//		{
//			string sql = @"UPDATE Customer SET TotalScore = TotalScore+@AddTotalScore,ValidScore=ValidScore+@AddValidScore WHERE SysNo=@CustomerSysNo";
//
//			SqlCommand cmd = new SqlCommand(sql);
//
//			SqlParameter paramCustomerSysNo = new SqlParameter("@CustomerSysNo", SqlDbType.Int,4);
//			SqlParameter paramAddTotalScore = new SqlParameter("@AddTotalScore", SqlDbType.Int,4);
//			SqlParameter paramAddValidScore = new SqlParameter("@AddValidScore", SqlDbType.Int,4);
//
//			if ( CustomerSysNo != AppConst.IntNull)
//				paramCustomerSysNo.Value = CustomerSysNo;
//			else
//				paramCustomerSysNo.Value = System.DBNull.Value;
//
//			if ( AddTotalScore != AppConst.IntNull)
//				paramAddTotalScore.Value = AddTotalScore;
//			else
//				paramAddTotalScore.Value = System.DBNull.Value;
//
//			if ( AddTotalScore != AppConst.IntNull)
//				paramAddValidScore.Value = AddValidScore;
//			else
//				paramAddValidScore.Value = System.DBNull.Value;
//
//			cmd.Parameters.Add(paramCustomerSysNo);
//			cmd.Parameters.Add(paramAddTotalScore);
//			cmd.Parameters.Add(paramAddValidScore);
//
//			return SqlHelper.ExecuteNonQuery(cmd);
//		}

        public int InsertCustomerPointRequest(CustomerPointRequestInfo oParam)
        {
            string     sql = @"INSERT INTO Customer_PointRequest
                            (
                            CustomerSysNo, PointSourceType, PointSourceSysNo, PointLogType, 
                            PointAmount, RequestUserType, RequestUserSysNo, RequestTime, 
                            AuditUserSysNo, AuditTime, AddUserSysNo, AddTime, 
                            AbandonUserSysNo, AbandonTime, Memo, Status,PMUserSysNo
                            )
                            VALUES (
                            @CustomerSysNo, @PointSourceType, @PointSourceSysNo, @PointLogType, 
                            @PointAmount, @RequestUserType, @RequestUserSysNo, @RequestTime, 
                            @AuditUserSysNo, @AuditTime, @AddUserSysNo, @AddTime, 
                            @AbandonUserSysNo, @AbandonTime, @Memo, @Status,@PMUserSysNo
                            );set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo            = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramCustomerSysNo    = new SqlParameter("@CustomerSysNo", SqlDbType.Int, 4);
            SqlParameter paramPointSourceType  = new SqlParameter("@PointSourceType", SqlDbType.Int, 4);
            SqlParameter paramPointSourceSysNo = new SqlParameter("@PointSourceSysNo", SqlDbType.Int, 4);
            SqlParameter paramPointLogType     = new SqlParameter("@PointLogType", SqlDbType.Int, 4);
            SqlParameter paramPointAmount      = new SqlParameter("@PointAmount", SqlDbType.Int, 4);
            SqlParameter paramRequestUserType  = new SqlParameter("@RequestUserType", SqlDbType.Int, 4);
            SqlParameter paramRequestUserSysNo = new SqlParameter("@RequestUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramRequestTime      = new SqlParameter("@RequestTime", SqlDbType.DateTime);
            SqlParameter paramAuditUserSysNo   = new SqlParameter("@AuditUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAuditTime        = new SqlParameter("@AuditTime", SqlDbType.DateTime);
            SqlParameter paramAddUserSysNo     = new SqlParameter("@AddUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAddTime          = new SqlParameter("@AddTime", SqlDbType.DateTime);
            SqlParameter paramAbandonUserSysNo = new SqlParameter("@AbandonUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAbandonTime      = new SqlParameter("@AbandonTime", SqlDbType.DateTime);
            SqlParameter paramMemo             = new SqlParameter("@Memo", SqlDbType.NVarChar, 200);
            SqlParameter paramStatus           = new SqlParameter("@Status", SqlDbType.Int, 4);
            SqlParameter paramPMUserSysNo      = new SqlParameter("@PMUserSysNo", SqlDbType.Int, 4);

            paramSysNo.Direction = ParameterDirection.Output;
            if (oParam.CustomerSysNo != AppConst.IntNull)
            {
                paramCustomerSysNo.Value = oParam.CustomerSysNo;
            }
            else
            {
                paramCustomerSysNo.Value = System.DBNull.Value;
            }
            if (oParam.PointSourceType != AppConst.IntNull)
            {
                paramPointSourceType.Value = oParam.PointSourceType;
            }
            else
            {
                paramPointSourceType.Value = System.DBNull.Value;
            }
            if (oParam.PointSourceSysNo != AppConst.IntNull)
            {
                paramPointSourceSysNo.Value = oParam.PointSourceSysNo;
            }
            else
            {
                paramPointSourceSysNo.Value = System.DBNull.Value;
            }
            if (oParam.PointLogType != AppConst.IntNull)
            {
                paramPointLogType.Value = oParam.PointLogType;
            }
            else
            {
                paramPointLogType.Value = System.DBNull.Value;
            }
            if (oParam.PointAmount != AppConst.IntNull)
            {
                paramPointAmount.Value = oParam.PointAmount;
            }
            else
            {
                paramPointAmount.Value = System.DBNull.Value;
            }
            if (oParam.RequestUserType != AppConst.IntNull)
            {
                paramRequestUserType.Value = oParam.RequestUserType;
            }
            else
            {
                paramRequestUserType.Value = System.DBNull.Value;
            }
            if (oParam.RequestUserSysNo != AppConst.IntNull)
            {
                paramRequestUserSysNo.Value = oParam.RequestUserSysNo;
            }
            else
            {
                paramRequestUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.RequestTime != AppConst.DateTimeNull)
            {
                paramRequestTime.Value = oParam.RequestTime;
            }
            else
            {
                paramRequestTime.Value = System.DBNull.Value;
            }
            if (oParam.AuditUserSysNo != AppConst.IntNull)
            {
                paramAuditUserSysNo.Value = oParam.AuditUserSysNo;
            }
            else
            {
                paramAuditUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.AuditTime != AppConst.DateTimeNull)
            {
                paramAuditTime.Value = oParam.AuditTime;
            }
            else
            {
                paramAuditTime.Value = System.DBNull.Value;
            }
            if (oParam.AddUserSysNo != AppConst.IntNull)
            {
                paramAddUserSysNo.Value = oParam.AddUserSysNo;
            }
            else
            {
                paramAddUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.AddTime != AppConst.DateTimeNull)
            {
                paramAddTime.Value = oParam.AddTime;
            }
            else
            {
                paramAddTime.Value = System.DBNull.Value;
            }
            if (oParam.AbandonUserSysNo != AppConst.IntNull)
            {
                paramAbandonUserSysNo.Value = oParam.AbandonUserSysNo;
            }
            else
            {
                paramAbandonUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.AbandonTime != AppConst.DateTimeNull)
            {
                paramAbandonTime.Value = oParam.AbandonTime;
            }
            else
            {
                paramAbandonTime.Value = System.DBNull.Value;
            }
            if (oParam.Memo != AppConst.StringNull)
            {
                paramMemo.Value = oParam.Memo;
            }
            else
            {
                paramMemo.Value = System.DBNull.Value;
            }
            if (oParam.Status != AppConst.IntNull)
            {
                paramStatus.Value = oParam.Status;
            }
            else
            {
                paramStatus.Value = System.DBNull.Value;
            }
            if (oParam.PMUserSysNo != AppConst.IntNull)
            {
                paramPMUserSysNo.Value = oParam.PMUserSysNo;
            }
            else
            {
                paramPMUserSysNo.Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramCustomerSysNo);
            cmd.Parameters.Add(paramPointSourceType);
            cmd.Parameters.Add(paramPointSourceSysNo);
            cmd.Parameters.Add(paramPointLogType);
            cmd.Parameters.Add(paramPointAmount);
            cmd.Parameters.Add(paramRequestUserType);
            cmd.Parameters.Add(paramRequestUserSysNo);
            cmd.Parameters.Add(paramRequestTime);
            cmd.Parameters.Add(paramAuditUserSysNo);
            cmd.Parameters.Add(paramAuditTime);
            cmd.Parameters.Add(paramAddUserSysNo);
            cmd.Parameters.Add(paramAddTime);
            cmd.Parameters.Add(paramAbandonUserSysNo);
            cmd.Parameters.Add(paramAbandonTime);
            cmd.Parameters.Add(paramMemo);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramPMUserSysNo);

            return(SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo));
        }
Пример #5
0
        public void Update(Hashtable paramHash)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (paramHash.ContainsKey("Status"))
                {
                    bool NeedAddPoint = false;

                    int             newStatus = Int32.Parse(paramHash["Status"].ToString());
                    int             SysNo     = Int32.Parse(paramHash["SysNo"].ToString());
                    PriceReportInfo oInfo     = Load(SysNo);

                    if (newStatus == (int)AppEnum.PriceReportStatus.Abandon)
                    {
                        if (oInfo.Status != (int)AppEnum.PriceReportStatus.Origin && oInfo.Status != (int)AppEnum.PriceReportStatus.AuditWaitingChangePrice)
                        {
                            throw new BizException("非初始状态,不能作废");
                        }
                    }
                    else if (newStatus == (int)AppEnum.PriceReportStatus.Origin)
                    {
                        if (oInfo.Status != (int)AppEnum.PriceReportStatus.Abandon)
                        {
                            throw new BizException("非作废状态,不能取消作废");
                        }
                    }
                    else if (newStatus == (int)AppEnum.PriceReportStatus.AuditedNotChangePrice)
                    {
                        NeedAddPoint = true;
                        if (oInfo.Status != (int)AppEnum.PriceReportStatus.Origin && oInfo.Status != (int)AppEnum.PriceReportStatus.AuditWaitingChangePrice)
                        {
                            throw new BizException("非初始状态,不能审核不修改价格");
                        }
                    }
                    else if (newStatus == (int)AppEnum.PriceReportStatus.AuditChangePrice)
                    {
                        NeedAddPoint = true;
                        if (oInfo.Status != (int)AppEnum.PriceReportStatus.Origin && oInfo.Status != (int)AppEnum.PriceReportStatus.AuditWaitingChangePrice)
                        {
                            throw new BizException("非初始状态,不能审核并修改价格");
                        }
                    }

                    new PriceReportDac().Update(paramHash);

                    if (NeedAddPoint)
                    {
                        oInfo = Load(SysNo);
                        CustomerPointRequestInfo cprInfo = new CustomerPointRequestInfo();
                        cprInfo.CustomerSysNo    = oInfo.CustomerSysNo;
                        cprInfo.PointSourceType  = (int)AppEnum.PointSourceType.PriceReport;
                        cprInfo.PointSourceSysNo = SysNo;
                        cprInfo.PointLogType     = (int)AppEnum.PointLogType.award;
                        cprInfo.PointAmount      = oInfo.Point;
                        cprInfo.Memo             = oInfo.AuditMemo;
                        cprInfo.RequestTime      = DateTime.Now;
                        cprInfo.RequestUserSysNo = oInfo.AuditUserSysNo;
                        cprInfo.RequestUserType  = (int)AppEnum.CreateUserType.Employee;
                        cprInfo.Status           = (int)AppEnum.PointRequestStatus.Origin;

                        PointManager.GetInstance().InsertCustomerPointRequest(cprInfo);
                    }
                }
                else
                {
                    new PriceReportDac().Update(paramHash);
                }

                scope.Complete();
            }
        }
Пример #6
0
 public int InsertCustomerPointRequest(CustomerPointRequestInfo oParam)
 {
     return(new PointDac().InsertCustomerPointRequest(oParam));
 }