private void map(CustomerCommendInfo oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.CustomerSysNo = Util.TrimIntNull(tempdr["CustomerSysNo"]); oParam.FriendName = Util.TrimNull(tempdr["FriendName"]); oParam.CommendEmail = Util.TrimNull(tempdr["CommendEmail"]); oParam.CommendTime = Util.TrimDateNull(tempdr["CommendTime"]); oParam.CommendStatus = Util.TrimIntNull(tempdr["CommendStatus"]); }
public CustomerCommendInfo LoadCustomerCommend(string CommendEmail) { string sql = "select * from customer_commend where commendemail=" + Util.ToSqlString(CommendEmail); DataSet ds = SqlHelper.ExecuteDataSet(sql); if (!Util.HasMoreRow(ds)) { return(null); } CustomerCommendInfo oInfo = new CustomerCommendInfo(); map(oInfo, ds.Tables[0].Rows[0]); return(oInfo); }
public void CommendCustomerEmailVerified(int CustomerSysNo, string CommendEmail) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { CustomerCommendInfo oInfo = LoadCustomerCommend(CommendEmail); if (oInfo == null) { throw new BizException(""); } decimal increment = 5; //推荐的好友通过Email验证赠送5¥运费 int rowsAffected = new FreeShipFeeDac().SetFreeShipFee(CustomerSysNo, increment); if (rowsAffected != 1) { throw new BizException("客户运费余额更新失败,可能因为运费余额不足。"); } UpdateCustomerCommendStatus(CommendEmail, (int)AppEnum.CommendStatus.Registered); //更新推荐状态 if (increment != 0) { int freeShipFeeLogType = (int)AppEnum.FreeShipFeeLogType.CustomerRegister; string freeShipFeeLogMemo = "推荐客户注册送运费 - " + CommendEmail; CustomerFreeShipFeeLogInfo oLog = new CustomerFreeShipFeeLogInfo(CustomerSysNo, freeShipFeeLogType, increment, freeShipFeeLogMemo); oLog.LogCheck = oLog.CalcLogCheck(); if (1 != new FreeShipFeeDac().Insert(oLog)) { throw new BizException("增加运费余额失败"); } } scope.Complete(); } }
public int Insert(CustomerCommendInfo oParam) { string sql = @"INSERT INTO Customer_Commend ( CustomerSysNo, FriendName, CommendEmail, CommendTime, CommendStatus ) VALUES ( @CustomerSysNo, @FriendName, @CommendEmail, @CommendTime, @CommendStatus );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 paramFriendName = new SqlParameter("@FriendName", SqlDbType.NVarChar, 200); SqlParameter paramCommendEmail = new SqlParameter("@CommendEmail", SqlDbType.NVarChar, 200); SqlParameter paramCommendTime = new SqlParameter("@CommendTime", SqlDbType.DateTime); SqlParameter paramCommendStatus = new SqlParameter("@CommendStatus", SqlDbType.Int, 4); paramSysNo.Direction = ParameterDirection.Output; if (oParam.CustomerSysNo != AppConst.IntNull) { paramCustomerSysNo.Value = oParam.CustomerSysNo; } else { paramCustomerSysNo.Value = System.DBNull.Value; } if (oParam.FriendName != AppConst.StringNull) { paramFriendName.Value = oParam.FriendName; } else { paramFriendName.Value = System.DBNull.Value; } if (oParam.CommendEmail != AppConst.StringNull) { paramCommendEmail.Value = oParam.CommendEmail; } else { paramCommendEmail.Value = System.DBNull.Value; } if (oParam.CommendTime != AppConst.DateTimeNull) { paramCommendTime.Value = oParam.CommendTime; } else { paramCommendTime.Value = System.DBNull.Value; } if (oParam.CommendStatus != AppConst.IntNull) { paramCommendStatus.Value = oParam.CommendStatus; } else { paramCommendStatus.Value = System.DBNull.Value; } cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramCustomerSysNo); cmd.Parameters.Add(paramFriendName); cmd.Parameters.Add(paramCommendEmail); cmd.Parameters.Add(paramCommendTime); cmd.Parameters.Add(paramCommendStatus); return(SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo)); }
public int Update(CustomerCommendInfo oParam) { string sql = @"UPDATE Customer_Commend SET CustomerSysNo=@CustomerSysNo, FriendName=@FriendName, CommendEmail=@CommendEmail, CommendTime=@CommendTime, CommendStatus=@CommendStatus WHERE SysNo=@SysNo"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramCustomerSysNo = new SqlParameter("@CustomerSysNo", SqlDbType.Int, 4); SqlParameter paramFriendName = new SqlParameter("@FriendName", SqlDbType.NVarChar, 200); SqlParameter paramCommendEmail = new SqlParameter("@CommendEmail", SqlDbType.NVarChar, 200); SqlParameter paramCommendTime = new SqlParameter("@CommendTime", SqlDbType.DateTime); SqlParameter paramCommendStatus = new SqlParameter("@CommendStatus", SqlDbType.Int, 4); if (oParam.SysNo != AppConst.IntNull) { paramSysNo.Value = oParam.SysNo; } else { paramSysNo.Value = System.DBNull.Value; } if (oParam.CustomerSysNo != AppConst.IntNull) { paramCustomerSysNo.Value = oParam.CustomerSysNo; } else { paramCustomerSysNo.Value = System.DBNull.Value; } if (oParam.FriendName != AppConst.StringNull) { paramFriendName.Value = oParam.FriendName; } else { paramFriendName.Value = System.DBNull.Value; } if (oParam.CommendEmail != AppConst.StringNull) { paramCommendEmail.Value = oParam.CommendEmail; } else { paramCommendEmail.Value = System.DBNull.Value; } if (oParam.CommendTime != AppConst.DateTimeNull) { paramCommendTime.Value = oParam.CommendTime; } else { paramCommendTime.Value = System.DBNull.Value; } if (oParam.CommendStatus != AppConst.IntNull) { paramCommendStatus.Value = oParam.CommendStatus; } else { paramCommendStatus.Value = System.DBNull.Value; } cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramCustomerSysNo); cmd.Parameters.Add(paramFriendName); cmd.Parameters.Add(paramCommendEmail); cmd.Parameters.Add(paramCommendTime); cmd.Parameters.Add(paramCommendStatus); return(SqlHelper.ExecuteNonQuery(cmd)); }
public int InsertCustomerCommend(CustomerCommendInfo oParam) { return(new FreeShipFeeDac().Insert(oParam)); }