コード例 #1
0
ファイル: ProductLine.cs プロジェクト: huaminglee/myyyyshop
 public List<Maticsoft.Model.Shop.Products.ProductLine> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.ProductLine> list = new List<Maticsoft.Model.Shop.Products.ProductLine>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.ProductLine item = new Maticsoft.Model.Shop.Products.ProductLine();
             if ((dt.Rows[i]["LineId"] != null) && (dt.Rows[i]["LineId"].ToString() != ""))
             {
                 item.LineId = int.Parse(dt.Rows[i]["LineId"].ToString());
             }
             if ((dt.Rows[i]["LineName"] != null) && (dt.Rows[i]["LineName"].ToString() != ""))
             {
                 item.LineName = dt.Rows[i]["LineName"].ToString();
             }
             list.Add(item);
         }
     }
     return list;
 }
コード例 #2
0
ファイル: ProductLine.cs プロジェクト: huaminglee/myyyyshop
 public Maticsoft.Model.Shop.Products.ProductLine GetModel(int LineId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("SELECT  TOP 1 LineId,LineName FROM Shop_ProductLines ");
     builder.Append(" WHERE LineId=@LineId");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@LineId", SqlDbType.Int, 4) };
     cmdParms[0].Value = LineId;
     Maticsoft.Model.Shop.Products.ProductLine line = new Maticsoft.Model.Shop.Products.ProductLine();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["LineId"] != null) && (set.Tables[0].Rows[0]["LineId"].ToString() != ""))
     {
         line.LineId = int.Parse(set.Tables[0].Rows[0]["LineId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["LineName"] != null) && (set.Tables[0].Rows[0]["LineName"].ToString() != ""))
     {
         line.LineName = set.Tables[0].Rows[0]["LineName"].ToString();
     }
     return line;
 }