private void ShowInfo(string FId) { Maticsoft.BLL.Catalogue bll=new Maticsoft.BLL.Catalogue(); Maticsoft.Model.Catalogue model=bll.GetModel(FId); this.lblFId.Text=model.FId; this.txthref.Text=model.href; this.txttitle.Text=model.title; this.txtLocalTagID.Text=model.LocalTagID.ToString(); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtFId.Text.Trim().Length==0) { strErr+="FId不能为空!\\n"; } if(this.txthref.Text.Trim().Length==0) { strErr+="href不能为空!\\n"; } if(this.txttitle.Text.Trim().Length==0) { strErr+="title不能为空!\\n"; } if(!PageValidate.IsNumber(txtLocalTagID.Text)) { strErr+="LocalTagID格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } string FId=this.txtFId.Text; string href=this.txthref.Text; string title=this.txttitle.Text; int LocalTagID=int.Parse(this.txtLocalTagID.Text); Maticsoft.Model.Catalogue model=new Maticsoft.Model.Catalogue(); model.FId=FId; model.href=href; model.title=title; model.LocalTagID=LocalTagID; Maticsoft.BLL.Catalogue bll=new Maticsoft.BLL.Catalogue(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
/// <summary> /// 商店详细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DishesTyep_Click(object sender, EventArgs e) { var catalogueBll = new Catalogue(); var catalogueList = catalogueBll.GetModelList(string.Empty); foreach (var catalogue in catalogueList) { var pagePath = string.Format("{0}shop/{1}/", _pageUrl, catalogue.FId); //todo 修改路径测试 pagePath = @"http://www.xiaomishu.com/shop/AESH10017472/"; var htmlWeb = new HtmlWeb(); var htmlDoc = htmlWeb.Load(pagePath); var nodeDetail = htmlDoc.DocumentNode.SelectSingleNode( ".//div[@class='constr']/div[@class='constr_in pt15 pb30']/div[@class='l res_detail_con']"); if (nodeDetail == null) { return; } var nodeAddress = nodeDetail.SelectSingleNode(".//div[@class='res_hm_find']/div[@class='res_hm_find_in z']/div[@class='fix pb10']/div[@class='cell pl20']/div[@class='dash pb15 mr5']/div[@class='lh22']/div[@class='cell pl5']"); var addressName = string.Empty; if (nodeAddress != null) { var addressText = nodeAddress.FirstChild; if (addressText == null) { return; } addressName = addressText.InnerText.Replace("/r/n", string.Empty).Trim(); if (string.IsNullOrEmpty(addressName)) { return; } } var nodePhone = nodeDetail.SelectNodes(".//p[@class='cell pl15']"); if (nodePhone == null) { return; } var phoneNum = nodePhone[1].FirstChild.InnerText.ToString().Replace(@"021-57575777 我吃,我吃,我吃吃吃", string.Empty).Trim(); var workTime = nodePhone[2].FirstChild.InnerText.ToString(); var facilitieslist = nodePhone[3].SelectNodes(".//span[@class='dib mr5 ml5']"); var facilities = string.Empty; if (facilitieslist != null) { foreach (var nodeInfo in facilitieslist) { facilities += nodeInfo.InnerText + '、'; } } facilities = facilities.Trim('、'); var cardListNode = nodePhone[3].SelectSingleNode(".//a[@class='dib mr5 g3']"); bool payCar = cardListNode != null; //简介 var basicIntroduction = nodePhone[4].InnerText.ToString(); var subway = string.Empty; var carPark = string.Empty; var bus = string.Empty; if (nodePhone.Count > 8) { subway = nodePhone[5].FirstChild.InnerText.ToString().Replace("/r/n", string.Empty).Trim(); if (nodePhone.Count > 6) { bus = nodePhone[6].FirstChild.InnerText.ToString().Replace("/r/n", string.Empty).Trim(); } if (nodePhone.Count > 7) { carPark = nodePhone[7].FirstChild.InnerText.ToString().Replace("/r/n", string.Empty).Trim(); } } else { bus = nodePhone[5].FirstChild.InnerText.ToString().Replace("/r/n", string.Empty).Trim(); if (nodePhone.Count > 6) { carPark = nodePhone[6].FirstChild.InnerText.ToString().Replace("/r/n", string.Empty).Trim(); } } var box = nodeDetail.SelectSingleNode(".//a[@class='res_seat selSchSeat']") != null; var storeInfoBll = new StoreInfo(); var storeInfo = new Maticsoft.Model.StoreInfo(); storeInfo.Fid = catalogue.FId; storeInfo.storeId = Guid.NewGuid().ToString(); storeInfo.Facilities = facilities; storeInfo.payCar = payCar; storeInfo.BasicIntroduction = basicIntroduction; storeInfo.subway = subway; storeInfo.bus = bus; storeInfo.box = box; storeInfo.StorePhone = phoneNum; storeInfo.StoreHours = workTime; storeInfo.StoreName = catalogue.title; storeInfo.StoreAddress = addressName; storeInfo.carPark = carPark; storeInfoBll.Add(storeInfo); } }