public List <GBreInfo> GetDataByCategoryId(int gb_id) { List <GBreInfo> infos = new List <GBreInfo>(); IDataReader reader = db.GetDataByCategoryId(gb_id).CreateDataReader(); while (reader.Read()) { infos.Add(GBreInfo.Populate(reader)); } return(infos); }
public static GBreInfo Populate(IDataReader reader) { GBreInfo info = new GBreInfo(); for (int i = 0; i < reader.FieldCount; i++) { PropertyInfo property = info.GetType().GetProperty(reader.GetName(i)); Type propType = property.PropertyType; TypeConverters.ITypeConverter typeConverter = TypeConverters.TypeConverterFactory.GetConvertType(propType); property.SetValue(info, Convert.ChangeType(typeConverter.Convert(reader.GetValue(i)), propType), null); } return(info); }
protected void Button1_Click(object sender, EventArgs e) { if (string.Compare(Request.Cookies["CheckCode"].Value, this.TextBox1.Text, true) == 0) { GBreInfo info = new GBreInfo(); info.g_name = txtName.Text; info.g_mail = txtMail.Text; info.g_show_mail = bool.Parse(chkReportMail.Checked.ToString()); info.g_ip = Tools.GetIpAddress(); info.g_content = txtContent.Text; info.gb_id = id; info.g_adddate = DateTime.Now; info.g_url = txtUrl.Text; if (gBLL.Insert(info) > 0) { Response.Redirect("List.aspx?header=" + Getmessage("30009")); } } else { ShowMessage("驗證碼輸入失敗"); } Response.Cookies.Remove("CheckCode"); }
public int Insert(GBreInfo info) { return(db.Insert(info.g_name, info.g_mail, info.g_show_mail, info.g_ip, info.g_level, info.g_content, info.gb_id, info.g_adddate, info.g_url)); }