/// <summary> /// 根据shopid获取商家 /// </summary> /// <param name="id"></param> /// <returns></returns> public TShop GetShopByID(int id) { NameValueCollection nvc = new NameValueCollection(); TShop ts = new TShop(); nvc.Add("@ShopID", id.ToString()); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, SelectShop + " and ShopID=@ShopID", nvc)) { if (dr.HasRows) { dr.Read(); ts.ShopID = id; ts.ShopTitle = dr["ShopTitle"].ToString(); ts.ShopETitle = dr["ShopETitle"].ToString(); ts.ShopPic = dr["ShopPic"].ToString(); ts.ShopMemo = dr["ShopMemo"].ToString(); ts.ShopProvince = dr["ShopProvince"].ToString(); ts.ShopCity = dr["ShopCity"].ToString(); ts.ShopArea = dr["ShopArea"].ToString(); ts.ShopLongitude = dr["ShopLongitude"].ToString(); ts.ShopLatitude = dr["ShopLatitude"].ToString(); ts.ShopRoute = dr["ShopRoute"].ToString(); ts.ShopOpenTime = dr["ShopOpenTime"].ToString(); ts.ShopTemplate = dr["ShopTemplate"].ToString(); DateTime Addtime; DateTime.TryParse(dr["ShopAddtime"].ToString(), out Addtime); ts.ShopAddtime = Addtime; ts.ShopAdder = dr["ShopAdder"].ToString(); int SortID = 0; Int32.TryParse(dr["SortID"].ToString(), out SortID); ts.SortID = SortID; bool IsRecom; bool.TryParse(dr["IsRecom"].ToString(), out IsRecom); ts.IsRecom = IsRecom; bool IsHtml; bool.TryParse(dr["IsHtml"].ToString(), out IsHtml); ts.IsHtml = IsHtml; ts.HtmlPath = dr["HtmlPath"].ToString(); bool IsRemote; bool.TryParse(dr["IsRemote"].ToString(), out IsRemote); ts.IsRemote = IsRemote; } } dh.Close(); return(ts); }
public TBrand GetBrandByID(int id) { NameValueCollection nvc = new NameValueCollection(); nvc.Add("@BrandID", id.ToString()); TBrand tb = new TBrand(); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, SelectBrand + " and BrandID=@BrandID", nvc)) { if (dr.HasRows) { dr.Read(); tb.BrandID = id; tb.BrandName = dr["BrandName"].ToString(); bool IsRecom; bool.TryParse(dr["IsRecom"].ToString(), out IsRecom); tb.IsRecom = IsRecom; tb.BrandMemo = dr["BrandMemo"].ToString().Trim(); tb.BrandPic = dr["BrandPic"].ToString().Trim(); tb.BrandTemplate = dr["BrandTemplate"].ToString().Trim(); bool IsHtml; bool.TryParse(dr["IsHtml"].ToString(), out IsHtml); tb.IsHtml = IsHtml; tb.BrandHtmlPath = dr["BrandHtmlPath"].ToString().Trim(); bool IsRemote; bool.TryParse(dr["IsRemote"].ToString(), out IsRemote); tb.IsRemote = IsRemote; DateTime BrandAddtime; DateTime.TryParse(dr["BrandAddtime"].ToString(), out BrandAddtime); tb.BrandAddtime = BrandAddtime; int BrandAdder = 0; Int32.TryParse(dr["BrandAdder"].ToString(), out BrandAdder); tb.BrandAdder = BrandAdder; int SortID = 0; Int32.TryParse(dr["SortID"].ToString(), out SortID); tb.SortID = SortID; } } dh.Close(); return(tb); }
/// <summary> /// 获取指定ID的节点 /// </summary> /// <param name="id"></param> /// <returns></returns> public TNode GetNode(int id) { TNode Node = new TNode(); NameValueCollection nvc = new NameValueCollection(); nvc.Add("@NodeID", id.ToString()); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, SelectNodes + WhereStringByNodeID, nvc)) { if (dr.HasRows) { dr.Read(); int nodeid = 0; int sortid = 0; int pid = 0; Int32.TryParse(dr[0].ToString().Trim(), out nodeid); Int32.TryParse(dr[3].ToString().Trim(), out pid); Int32.TryParse(dr[7].ToString().Trim(), out sortid); bool IsRecom; bool IsHtml; bool.TryParse(dr[8].ToString().Trim(), out IsRecom); bool.TryParse(dr[9].ToString().Trim(), out IsHtml); // Node.NodeID = nodeid; Node.NodeName = dr[1].ToString().Trim(); Node.NodeIdentifier = dr[2].ToString().Trim(); Node.ParentID = pid; Node.NodePath = dr[4].ToString(); Node.NodeMemo = dr[5].ToString().Trim(); Node.NodePic = dr[6].ToString().Trim(); Node.SortID = sortid; Node.IsRecom = IsRecom; Node.IsHtml = IsHtml; Node.HtmlPath = dr[10].ToString().Trim(); Node.NodeTemplate = dr[11].ToString(); Node.Meta_Description = dr[12].ToString().Trim(); Node.Meta_KeyWords = dr[13].ToString().Trim(); } } dh.Close(); return(Node); }
public TAdmin GetAdmin(int id) { TAdmin ta = new TAdmin(); string cmdtxt = "select Admin_ID,Admin_UID,Admin_PWD,Admin_Stat,Admin_RealName,Admin_RegTime,Admin_LogTimes,Admin_Flag,SortID from T_Admin where Admin_ID=@Admin_ID and IsDelete=0"; NameValueCollection nvc = new NameValueCollection(); nvc.Add("@Admin_ID", id.ToString()); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, cmdtxt, nvc)) { if (dr.HasRows) { dr.Read(); int Admin_id = 0; Int32.TryParse(dr["Admin_ID"].ToString().Trim(), out Admin_id); ta.Admin_ID = Admin_id; ta.Admin_UID = dr["Admin_UID"].ToString(); ta.Admin_PWD = dr["Admin_PWD"].ToString(); bool stat = false; bool.TryParse(dr["Admin_Stat"].ToString().Trim(), out stat); ta.Admin_Stat = stat; ta.Admin_RealName = dr["Admin_RealName"].ToString().Trim(); DateTime Addtime; DateTime.TryParse(dr["Admin_RegTime"].ToString().Trim(), out Addtime); ta.Admin_RegTime = Addtime; ta.Admin_LogTimes = Convert.ToInt32(dr["Admin_LogTimes"].ToString()); ta.Admin_Flag = dr["Admin_Flag"].ToString(); int sortid = 0; Int32.TryParse(dr["SortID"].ToString(), out sortid); ta.SortID = sortid; } } dh.Close(); return(ta); }
/// <summary> /// 通过指定ID获取省份 /// </summary> /// <param name="id"></param> /// <returns></returns> public TProvince GetProvinceByID(int id) { TProvince tp = new TProvince(); NameValueCollection nvc = new NameValueCollection(); nvc.Add("@ID", id.ToString()); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, "Select ID,code,name from province where ID=@ID", nvc)) { if (dr.HasRows) { dr.Read(); int provinceid = 0; Int32.TryParse(dr[0].ToString().Trim(), out provinceid); tp.ID = provinceid; tp.code = dr[1].ToString().Trim(); tp.name = dr[2].ToString(); } } dh.Close(); return(tp); }
/// <summary> /// 通过指定id获取信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public TInformation GetInfo(int id) { TInformation tinfo = new TInformation(); string cmdtxt = "Select InfoTitle,InfoSubMemo,InfoMemo,BrandID,InfoPic,InfoType,ShopID,InfoStartTime,InfoEndTime,InfoFrom,InfoAddTime,InfoAdder,InfoClicks,IsRecom,SortID,IsHtml,HtmlPath,IsRemote,IsCheck,InfoCateID,InfoETitle,InfoTag from T_InfoList where InfoID=@InfoID"; NameValueCollection nvc = new NameValueCollection(); nvc.Add("@InfoID", id.ToString()); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, cmdtxt, nvc)) { if (dr.HasRows) { dr.Read(); #region 变量赋值 tinfo.InfoID = id; tinfo.InfoTitle = dr["InfoTitle"].ToString(); tinfo.InfoSubMemo = dr["InfoSubMemo"].ToString(); tinfo.InfoMemo = dr["InfoMemo"].ToString(); int BrandID = 0; Int32.TryParse(dr["BrandID"].ToString(), out BrandID); tinfo.BrandID = BrandID; tinfo.InfoPic = dr["InfoPic"].ToString().Trim(); int infotype = 0; Int32.TryParse(dr["InfoType"].ToString(), out infotype); tinfo.InfoType = infotype; int ShopID = 0; Int32.TryParse(dr["ShopID"].ToString(), out ShopID); tinfo.ShopID = ShopID; tinfo.InfoStartTime = dr["InfoStartTime"].ToString(); tinfo.InfoEndTime = dr["InfoEndTime"].ToString(); tinfo.InfoFrom = dr["InfoFrom"].ToString(); DateTime addtime; DateTime.TryParse(dr["InfoAddTime"].ToString(), out addtime); tinfo.InfoAddTime = addtime; tinfo.InfoAdder = dr["InfoAdder"].ToString(); int InfoClicks = 0; Int32.TryParse(dr["InfoClicks"].ToString(), out InfoClicks); bool IsRecom = false; bool.TryParse(dr["IsRecom"].ToString(), out IsRecom); tinfo.IsRecom = IsRecom; int SortID = 0; Int32.TryParse(dr["SortID"].ToString(), out SortID); tinfo.SortID = SortID; bool IsHtml = false; bool.TryParse(dr["IsHtml"].ToString(), out IsHtml); tinfo.IsHtml = IsHtml; tinfo.HtmlPath = dr["HtmlPath"].ToString(); bool IsRemote = false; bool.TryParse(dr["IsRemote"].ToString(), out IsRemote); tinfo.IsRemote = IsRemote; bool IsCheck = false; bool.TryParse(dr["IsCheck"].ToString(), out IsCheck); tinfo.IsCheck = IsCheck; int InfoCateID = 0; Int32.TryParse(dr["InfoCateID"].ToString(), out InfoCateID); tinfo.InfoCateID = InfoCateID; tinfo.InfoETitle = dr["InfoETitle"].ToString(); tinfo.InfoTag = dr["InfoTag"].ToString(); #endregion } } dh.Close(); return(tinfo); }