您目前尚未登陆,请选择【登陆】或【注册
首页->电子商务->我的小书坊源码(三层实现)>>App-Code/BusinessLogicHelper/BookHelper.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:我的小书坊源码(三层实现)
当前文件:文件类型 MyBookShop/App_Code/BusinessLogicHelper/BookHelper.cs打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3 4using MyBookShop.BusinessLogicLayer; 5using MyBookShop.DataAccessHelper; 6 7namespace MyBookShop.BusinessLogicHelper 8{ 9 public class BookHelper 10 { 11 /// <summary> 12 /// Book类的接口帮助类,完成Add方法的数据检查 13 /// </summary> 14 /// <param name="bookInfo">Add方法的图书哈希表信息</param> 15 /// <param name="WarningMessageList">返回的警告信息</param> 16 /// <returns>如果数据检查正确:返回true;否则:返回false</returns> 17 public static bool Add(Hashtable bookInfo,ref ArrayList WarningMessageList) 18 { 19 bool result = true; 20 WarningMessageList.Clear(); 21 Hashtable quoetedBookInfo=new Hashtable(); //值带有单引号的图书信息哈希表 22 23 foreach(DictionaryEntry item in bookInfo) 24 { 25 switch(item.Key.ToString()) 26 { 27 case "BookName": //图书名称 28 { 29 if(item.Value.ToString()=="") 30 { 31 result=false; 32 WarningMessageList.Add("警告:图书名称不能为空!"); 33 } 34 else if(!ValidateUtility.IsString(item.Value)) //检查是否为字符串类型 35 { 36 result=false; 37 WarningMessageList.Add("警告:图书名称数据类型错误!"); 38 } 39 else 40 quoetedBookInfo.Add("BookName",SqlStringConstructor.GetQuotedString(item.Value.ToString())); 41 break; 42 } 43 case "CategoryId": //图书类别ID 44 { 45 if(item.Value.ToString()=="") 46 { 47 result=false; 48 WarningMessageList.Add("警告:图书类别ID不能为空!"); 49 } 50 else if(!ValidateUtility.IsDouble(item.Value)) //检查是否为浮点数类型 51 { 52 result=false; 53 WarningMessageList.Add("警告:图书类别ID类型错误!"); 54 } 55 else 56 quoetedBookInfo.Add("CategoryId",item.Value.ToString()); 57 break; 58 } 59 case "Price": //图书价格 60 { 61 if(item.Value.ToString()=="") 62 { 63 result=false; 64 WarningMessageList.Add("警告:图书价格数不能为空!"); 65 } 66 else if(!ValidateUtility.IsDouble(item.Value)) //检查是否为浮点数类型 67 { 68 result=false; 69 WarningMessageList.Add("警告:图书价格数据类型错误!"); 70 } 71 else 72 quoetedBookInfo.Add("Price",item.Value.ToString()); 73 break; 74 } 75 case "Publisher": //出版社 76 { 77 if(item.Value.ToString()=="") 78 { 79 result=false; 80 WarningMessageList.Add("警告:出版社不能为空!"); 81 } 82 else if(!ValidateUtility.IsString(item.Value)) //检查是否为字符串类型 83 { 84 result=false; 85 WarningMessageList.Add("警告:出版社数据类型错误!"); 86 } 87 else 88 quoetedBookInfo.Add("Publisher",SqlStringConstructor.GetQuotedString(item.Value.ToString())); 89 break; 90 } 91 case "PublishDate": //出版日期 92 { 93 if(!ValidateUtility.IsDateTime(item.Value)) //检查是否为日期类型 94 { 95 result=false; 96 WarningMessageList.Add("警告:图书出版日期数据类型错误!"); 97 } 98 else 99 quoetedBookInfo.Add("PublishDate",SqlStringConstructor.GetQuotedString(item.Value.ToString())); 100 101 break; 102 } 103 case "Author": //作者 104 { 105 if(item.Value.ToString()=="") 106 { 107 result=false; 108 WarningMessageList.Add("警告:作者不能为空!"); 109 } 110 else if(!ValidateUtility.IsString(item.Value)) //检查是否为字符串类型 111 { 112 result=false; 113 WarningMessageList.Add("警告:图书名称数据类型错误!"); 114 } 115 else 116 quoetedBookInfo.Add("Author",SqlStringConstructor.GetQuotedString(item.Value.ToString())); 117 break; 118 } 119 case "PageNum": 120 { 121 if(!ValidateUtility.IsInt(item.Value)) //检查是否为整数类型 122 { 123 result=false; 124 WarningMessageList.Add("警告:图书页数数据类型错误!"); 125 } 126 else 127 quoetedBookInfo.Add("PageNum",item.Value.ToString()); 128 break; 129 } 130 case "PictureUrl": 131 { 132 if(!ValidateUtility.IsString(item.Value)) //检查是否为字符串类型 133 { 134 result=false; 135 WarningMessageList.Add("警告:图片路径数据类型错误!"); 136 } 137 else 138 quoetedBookInfo.Add("PictureUrl",SqlStringConstructor.GetQuotedString(item.Value.ToString())); 139 break; 140 } 141 case "Description": 142 { 143 if(!ValidateUtility.IsString(item.Value)) //检查是否为字符串类型 144 { 145 result=false; 146 WarningMessageList.Add("警告:图书页数数据类型错误!"); 147 } 148 else if(item.Value.ToString().Length>1000) 149 { 150 result=false; 151 WarningMessageList.Add("警告:请把图书简介字符在1000字之内!"); 152 } 153 else 154 quoetedBookInfo.Add("Description",SqlStringConstructor.GetQuotedString(item.Value.ToString())); 155 break; 156 } 157 case "SaleCount": 158 { 159 if(!ValidateUtility.IsString(item.Value)) //检查是否为整数类型 160 { 161 result=false; 162 WarningMessageList.Add("警告:销售量数据类型错误!"); 163 } 164 else 165 quoetedBookInfo.Add("SaleCount",item.Value.ToString()); 166 break; 167 } 168 }//switch 169 }//while 170 171 if (result) 172 { 173 Book book=new Book(); 174 book.Add(quoetedBookInfo); 175 } 176 return result; 177 } 178 } 179}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:我的小书坊源码(三层实现)
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号