コード例 #1
0
ファイル: ProductQA.cs プロジェクト: huaminglee/myyyyshop
 public Maticsoft.Model.Shop.Products.ProductQA GetModel(int QAId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 QAId,ParentId,ProductId,UserId,UserName,Question,State,CreatedDate,ReplyContent,ReplyDate,ReplyUserId,ReplyUserName from Shop_ProductQA ");
     builder.Append(" where QAId=@QAId");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@QAId", SqlDbType.Int, 4) };
     cmdParms[0].Value = QAId;
     Maticsoft.Model.Shop.Products.ProductQA tqa = new Maticsoft.Model.Shop.Products.ProductQA();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["QAId"] != null) && (set.Tables[0].Rows[0]["QAId"].ToString() != ""))
     {
         tqa.QAId = int.Parse(set.Tables[0].Rows[0]["QAId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ParentId"] != null) && (set.Tables[0].Rows[0]["ParentId"].ToString() != ""))
     {
         tqa.ParentId = new int?(int.Parse(set.Tables[0].Rows[0]["ParentId"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["ProductId"] != null) && (set.Tables[0].Rows[0]["ProductId"].ToString() != ""))
     {
         tqa.ProductId = int.Parse(set.Tables[0].Rows[0]["ProductId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["UserId"] != null) && (set.Tables[0].Rows[0]["UserId"].ToString() != ""))
     {
         tqa.UserId = int.Parse(set.Tables[0].Rows[0]["UserId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["UserName"] != null) && (set.Tables[0].Rows[0]["UserName"].ToString() != ""))
     {
         tqa.UserName = set.Tables[0].Rows[0]["UserName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Question"] != null) && (set.Tables[0].Rows[0]["Question"].ToString() != ""))
     {
         tqa.Question = set.Tables[0].Rows[0]["Question"].ToString();
     }
     if ((set.Tables[0].Rows[0]["State"] != null) && (set.Tables[0].Rows[0]["State"].ToString() != ""))
     {
         tqa.State = int.Parse(set.Tables[0].Rows[0]["State"].ToString());
     }
     if ((set.Tables[0].Rows[0]["CreatedDate"] != null) && (set.Tables[0].Rows[0]["CreatedDate"].ToString() != ""))
     {
         tqa.CreatedDate = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["CreatedDate"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["ReplyContent"] != null) && (set.Tables[0].Rows[0]["ReplyContent"].ToString() != ""))
     {
         tqa.ReplyContent = set.Tables[0].Rows[0]["ReplyContent"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ReplyDate"] != null) && (set.Tables[0].Rows[0]["ReplyDate"].ToString() != ""))
     {
         tqa.ReplyDate = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["ReplyDate"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["ReplyUserId"] != null) && (set.Tables[0].Rows[0]["ReplyUserId"].ToString() != ""))
     {
         tqa.ReplyUserId = new int?(int.Parse(set.Tables[0].Rows[0]["ReplyUserId"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["ReplyUserName"] != null) && (set.Tables[0].Rows[0]["ReplyUserName"].ToString() != ""))
     {
         tqa.ReplyUserName = set.Tables[0].Rows[0]["ReplyUserName"].ToString();
     }
     return tqa;
 }
コード例 #2
0
ファイル: ProductQA.cs プロジェクト: huaminglee/myyyyshop
 public List<Maticsoft.Model.Shop.Products.ProductQA> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.ProductQA> list = new List<Maticsoft.Model.Shop.Products.ProductQA>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.ProductQA item = new Maticsoft.Model.Shop.Products.ProductQA();
             if ((dt.Rows[i]["QAId"] != null) && (dt.Rows[i]["QAId"].ToString() != ""))
             {
                 item.QAId = int.Parse(dt.Rows[i]["QAId"].ToString());
             }
             if ((dt.Rows[i]["ParentId"] != null) && (dt.Rows[i]["ParentId"].ToString() != ""))
             {
                 item.ParentId = new int?(int.Parse(dt.Rows[i]["ParentId"].ToString()));
             }
             if ((dt.Rows[i]["ProductId"] != null) && (dt.Rows[i]["ProductId"].ToString() != ""))
             {
                 item.ProductId = int.Parse(dt.Rows[i]["ProductId"].ToString());
             }
             if ((dt.Rows[i]["UserId"] != null) && (dt.Rows[i]["UserId"].ToString() != ""))
             {
                 item.UserId = int.Parse(dt.Rows[i]["UserId"].ToString());
             }
             if ((dt.Rows[i]["UserName"] != null) && (dt.Rows[i]["UserName"].ToString() != ""))
             {
                 item.UserName = dt.Rows[i]["UserName"].ToString();
             }
             if ((dt.Rows[i]["Question"] != null) && (dt.Rows[i]["Question"].ToString() != ""))
             {
                 item.Question = dt.Rows[i]["Question"].ToString();
             }
             if ((dt.Rows[i]["State"] != null) && (dt.Rows[i]["State"].ToString() != ""))
             {
                 item.State = int.Parse(dt.Rows[i]["State"].ToString());
             }
             if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != ""))
             {
                 item.CreatedDate = new DateTime?(DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString()));
             }
             if ((dt.Rows[i]["ReplyContent"] != null) && (dt.Rows[i]["ReplyContent"].ToString() != ""))
             {
                 item.ReplyContent = dt.Rows[i]["ReplyContent"].ToString();
             }
             if ((dt.Rows[i]["ReplyDate"] != null) && (dt.Rows[i]["ReplyDate"].ToString() != ""))
             {
                 item.ReplyDate = new DateTime?(DateTime.Parse(dt.Rows[i]["ReplyDate"].ToString()));
             }
             if ((dt.Rows[i]["ReplyUserId"] != null) && (dt.Rows[i]["ReplyUserId"].ToString() != ""))
             {
                 item.ReplyUserId = new int?(int.Parse(dt.Rows[i]["ReplyUserId"].ToString()));
             }
             if ((dt.Rows[i]["ReplyUserName"] != null) && (dt.Rows[i]["ReplyUserName"].ToString() != ""))
             {
                 item.ReplyUserName = dt.Rows[i]["ReplyUserName"].ToString();
             }
             list.Add(item);
         }
     }
     return list;
 }