/// <summary> /// 得到一个对象实体 /// </summary> private static PeopleTicket DataRowToModel(SQLiteDataReader row) { PeopleTicket model = new PeopleTicket(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.Id = int.Parse(row["id"].ToString()); } if (row["user_id"] != null && row["user_id"].ToString() != "") { model.UserId = int.Parse(row["user_id"].ToString()); model.People = PeopleDAL.GetPeopleByUserId(model.UserId); model.Wechat = WechatDAL.GetWechatByUserId(model.UserId); model.Member = MemberDAL.GetMemberByUserId(model.UserId); } if (row["order_id"] != null && row["order_id"].ToString() != "") { model.OrderId = int.Parse(row["order_id"].ToString()); } if (row["date"] != null && row["date"].ToString() != "") { model.Date = model.ConvertIntDateTime(int.Parse(row["date"].ToString())); } if (row["num"] != null && row["num"].ToString() != "") { model.Num = int.Parse(row["num"].ToString()); } if (row["status"] != null && row["status"].ToString() != "") { model.Status = row["status"].ToString(); } if (row["created_at"] != null && row["created_at"].ToString() != "") { model.CreatedAt = model.ConvertIntDateTime(int.Parse(row["created_at"].ToString())); } if (row["updated_at"] != null && row["updated_at"].ToString() != "") { model.UpdatedAt = model.ConvertIntDateTime(int.Parse(row["updated_at"].ToString())); } } return(model); }
/// <summary> /// 根据关键字获取会员信息 /// </summary> /// <param name="no">会员手机号、会员卡号、会员身份证号</param> /// <returns>符合条件的数据集</returns> public static Member GetMember(String no) { log.Debug("GetMember:" + no); Member member = new Member(); String sql = String.Format("SELECT * FROM members WHERE no = '{0}'", no); log.Debug("SQL:" + sql); using (SQLiteDataReader reader = SQLiteHelper.ExecuteReader(SQLiteHelper.ConnectionStringLocalTransaction, System.Data.CommandType.Text, sql)) { if (reader.Read()) { member = DataRowToModel(reader); member.People = PeopleDAL.GetPeopleByUserId(member.UserId); } } return(member); }