public static void AddNewTopic(TopicInfo topic) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { int topicSysNo = TopicDac.InsertTopic(topic); // ����������ۣ� // ͬʱ���� Product ��� RemarkCount / RemarkScore �ֶΡ� TopicDac.UpdateProductRemarkCountAndScore(topic.ReferenceSysNo); if (topic.ImageList != null && topic.ImageList.Count > 0) foreach (TopicImageInfo info in topic.ImageList) { info.TopicSysNo = topicSysNo; TopicImageDac.InsertTopicImage(info); } scope.Complete(); } }
protected static TopicInfo Map(DataRow row) { TopicInfo info = new TopicInfo(); info.SysNo = Convert.ToInt32(row["SysNo"]); info.TopicType = (AppEnum.TopicType)Convert.ToInt32(row["TopicType"]); info.Title = row["Title"].ToString(); info.TopicContent = row["TopicContent"].ToString(); info.IsTop = Convert.ToInt32(row["IsTop"]) == 1; info.IsDigest = Convert.ToInt32(row["IsDigest"]) == 1; info.ReferenceType = Convert.ToInt32(row["ReferenceType"]); info.ReferenceSysNo = Convert.ToInt32(row["ReferenceSysNo"]); info.TotalRemarkCount = Convert.ToInt32(row["TotalRemarkCount"]); info.TotalUsefulRemarkCount = Convert.ToInt32(row["TotalUsefulRemarkCount"]); info.Score = Convert.ToInt32(row["Score"]); info.TotalComplainCount = Convert.ToInt32(row["TotalComplainCount"]); info.Status = (AppEnum.TopicStatus)Convert.ToInt32(row["Status"]); info.CreateCustomerSysNo = Convert.ToInt32(row["CreateCustomerSysNo"]); info.CreateDate = Convert.ToDateTime(row["CreateDate"]); info.LastEditDate = Convert.ToDateTime(row["LastEditDate"]); info.CustomerRank = Convert.ToInt32(row["CustomerRank"]); if (row["CustomerName"] != DBNull.Value) info.CreateUsername = row["CustomerName"].ToString(); if (row["LastEditUserSysNo"] != DBNull.Value) info.LastEditUserSysNo = Convert.ToInt32(row["LastEditUserSysNo"]); else info.LastEditUserSysNo = 0; if (row["CustomerId"] != DBNull.Value) info.CustomerID = row["CustomerId"].ToString(); if (row["CustomerName"] != DBNull.Value) info.CustomerName = row["CustomerName"].ToString(); info.ReferenceName = row["ReferenceName"].ToString(); return info; }
public static void UpdateTopic(TopicInfo info) { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@SysNo", SqlDbType.Int), new SqlParameter("@TopicType", SqlDbType.Int), new SqlParameter("@Title", SqlDbType.NVarChar), new SqlParameter("@TopicContent", SqlDbType.NText), new SqlParameter("@IsTop", SqlDbType.Int), new SqlParameter("@IsDigest", SqlDbType.Int), new SqlParameter("@ReferenceType", SqlDbType.Int), new SqlParameter("@ReferenceSysNo", SqlDbType.Int), new SqlParameter("@TotalRemarkCount", SqlDbType.Int), new SqlParameter("@TotalUsefulRemarkCount", SqlDbType.Int), new SqlParameter("@Score", SqlDbType.Int), new SqlParameter("@TotalComplainCount", SqlDbType.Int), new SqlParameter("@Status", SqlDbType.Int), new SqlParameter("@CreateCustomerSysNo", SqlDbType.Int), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@LastEditUserSysNo", SqlDbType.Int), new SqlParameter("@LastEditDate", SqlDbType.DateTime) }; parms[0].Value = info.SysNo; parms[1].Value = info.TopicType; parms[2].Value = info.Title; parms[3].Value = info.TopicContent; parms[4].Value = info.IsTop; parms[5].Value = info.IsDigest; parms[6].Value = info.ReferenceType; parms[7].Value = info.ReferenceSysNo; parms[8].Value = info.TotalRemarkCount; parms[9].Value = info.TotalUsefulRemarkCount; parms[10].Value = info.Score; parms[11].Value = info.TotalComplainCount; parms[12].Value = info.Status; parms[13].Value = info.CreateCustomerSysNo; parms[14].Value = info.CreateDate; parms[15].Value = info.LastEditUserSysNo; parms[16].Value = info.LastEditDate; SqlCommand cmd = new SqlCommand(SQL_UPDATE_TOPIC); cmd.Parameters.AddRange(parms); cmd.CommandTimeout = 180; SqlHelper.ExecuteNonQuery(cmd); }
public static int InsertTopic(TopicInfo info) { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@TopicType", SqlDbType.Int), new SqlParameter("@Title", SqlDbType.NVarChar), new SqlParameter("@TopicContent", SqlDbType.NText), new SqlParameter("@ReferenceType", SqlDbType.Int), new SqlParameter("@ReferenceSysNo", SqlDbType.Int), new SqlParameter("@Score", SqlDbType.Int), new SqlParameter("@Status", SqlDbType.Int), new SqlParameter("@CreateCustomerSysNo", SqlDbType.Int), }; parms[0].Value = (int)info.TopicType; parms[1].Value = info.Title; parms[2].Value = info.TopicContent; parms[3].Value = info.ReferenceType; parms[4].Value = info.ReferenceSysNo; parms[5].Value = info.Score; parms[6].Value = (int)info.Status; parms[7].Value = info.CreateCustomerSysNo; SqlCommand cmd = new SqlCommand(SQL_INSERT_TOPIC); cmd.Parameters.AddRange(parms); cmd.CommandTimeout = 180; object obj = SqlHelper.ExecuteScalar(cmd); return Convert.ToInt32(obj); }