private void loadXls() { string data = Utils.GetFormValue("dataxls"); string[] s = data.Split(';'); EyouSoft.BLL.SupplierStructure.SupplierHotel hotelbll = new EyouSoft.BLL.SupplierStructure.SupplierHotel(); IList <EyouSoft.Model.SupplierStructure.SupplierHotelInfo> hotelinfo = new List <EyouSoft.Model.SupplierStructure.SupplierHotelInfo>(); for (int i = 0; i < s.Length; i++) { string[] smodel = s[i].Split(','); if (smodel.Length == 18 && !string.IsNullOrEmpty(smodel[0]) && !string.IsNullOrEmpty(smodel[1]) && !string.IsNullOrEmpty(smodel[2])) { EyouSoft.Model.SupplierStructure.SupplierHotelInfo modelhotel = new EyouSoft.Model.SupplierStructure.SupplierHotelInfo(); modelhotel.ProvinceName = HttpUtility.UrlDecode(smodel[0]); modelhotel.CityName = HttpUtility.UrlDecode(smodel[1]); modelhotel.UnitName = HttpUtility.UrlDecode(smodel[2]); modelhotel.Star = Utils.GetEnumValue <EyouSoft.Model.EnumType.SupplierStructure.HotelStar>(HttpUtility.UrlDecode(smodel[3]), EyouSoft.Model.EnumType.SupplierStructure.HotelStar.挂3); modelhotel.UnitAddress = HttpUtility.UrlDecode(smodel[4]); modelhotel.Introduce = HttpUtility.UrlDecode(smodel[5]); modelhotel.TourGuide = HttpUtility.UrlDecode(smodel[6]); modelhotel.SupplierContact = new List <EyouSoft.Model.CompanyStructure.SupplierContact>(); EyouSoft.Model.CompanyStructure.SupplierContact scmodel = new EyouSoft.Model.CompanyStructure.SupplierContact(); scmodel.ContactName = HttpUtility.UrlDecode(smodel[7]); scmodel.JobTitle = HttpUtility.UrlDecode(smodel[8]); scmodel.ContactTel = HttpUtility.UrlDecode(smodel[9]); scmodel.ContactMobile = HttpUtility.UrlDecode(smodel[10]); scmodel.QQ = HttpUtility.UrlDecode(smodel[11]); scmodel.Email = HttpUtility.UrlDecode(smodel[12]); scmodel.CompanyId = SiteUserInfo.CompanyID; modelhotel.SupplierContact.Add(scmodel); modelhotel.OperatorId = SiteUserInfo.ID; modelhotel.IssueTime = System.DateTime.Now; modelhotel.CompanyId = SiteUserInfo.CompanyID; modelhotel.TradeNum = 0; modelhotel.SupplierType = EyouSoft.Model.EnumType.CompanyStructure.SupplierType.酒店; modelhotel.SupplierPic = null; modelhotel.RoomTypes = new List <EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo>(); EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo roomtype = new EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo(); roomtype.Name = HttpUtility.UrlDecode(smodel[13]); roomtype.SellingPrice = Utils.GetDecimal(HttpUtility.UrlDecode(smodel[14])); roomtype.AccountingPrice = Utils.GetDecimal(HttpUtility.UrlDecode(smodel[15])); roomtype.IsBreakfast = HttpUtility.UrlDecode(smodel[16]) == "是" ? true : false; modelhotel.RoomTypes.Add(roomtype); modelhotel.Remark = HttpUtility.UrlDecode(smodel[17]); hotelinfo.Add(modelhotel); } } int res = 0; res = hotelbll.InsertHotels(hotelinfo); Response.Clear(); Response.Write(string.Format("{{\"res\":{0}}}", res > 0 ? 1 : -1)); Response.End(); }
protected void LinkButton1_Click(object sender, EventArgs e) { //接受参数 tid = Utils.GetInt(Utils.GetQueryStringValue("tid")); if (tid > 0) { Hotelinfo = HotelBll.GetHotelInfo(tid); Hotelinfo.Id = tid; } else { Hotelinfo.SupplierType = EyouSoft.Model.EnumType.CompanyStructure.SupplierType.酒店; } //省份编号 Hotelinfo.ProvinceId = this.ucProvince1.ProvinceId; EyouSoft.Model.CompanyStructure.Province Provincemodel = new EyouSoft.BLL.CompanyStructure.Province().GetModel(this.ucProvince1.ProvinceId); if (Provincemodel != null) { Hotelinfo.ProvinceName = Provincemodel.ProvinceName; } //城市编号 Hotelinfo.CityId = this.ucCity1.CityId; EyouSoft.Model.CompanyStructure.City citymodel = new EyouSoft.BLL.CompanyStructure.City().GetModel(this.ucCity1.CityId); if (citymodel != null) { Hotelinfo.CityName = citymodel.CityName; } //单位名称 string unionname = Utils.GetFormValue("unionname"); //酒店星级 int HotelStart = Utils.GetInt(Utils.GetFormValue(this.HotelStart.UniqueID)); //酒店地址 string TxtHotelAddress = Utils.GetFormValue("TxtHotelAddress"); //酒店简介 string HotelIntroduction = Utils.GetFormValue("HotelIntroduction"); #region 酒店图片 if (Request.Files.Count > 0) { string msg = ""; if (!EyouSoft.Common.Function.UploadFile.CheckFileType(Request.Files, "file_landspace", new[] { ".gif", ".jpg", ".jpeg", ".png" }, null, out msg)) { MessageBox.ResponseScript(this, ";alert('" + msg + "');"); BindHotelStart(); return; } Hotelinfo.SupplierPic = new List <EyouSoft.Model.SupplierStructure.SupplierPic>(); EyouSoft.Model.SupplierStructure.SupplierPic SupplierPic = new EyouSoft.Model.SupplierStructure.SupplierPic(); string filepath = string.Empty; string oldfilename = string.Empty; //if (EyouSoft.Common.Function.UploadFile.FileUpLoad(Request.Files["HotelImage"], "SupplierControlFile", out filepath, out oldfilename)) //{ // if (filepath.Trim() != "" && oldfilename.Trim() != "") // { // SupplierPic.PicPath = filepath; // SupplierPic.PicName = oldfilename; // Hotelinfo.SupplierPic.Add(SupplierPic); // } //} //遍历files取出file. for (int i = 0; i < Request.Files.Count; i++) { bool result_landspace = EyouSoft.Common.Function.UploadFile.FileUpLoad(Request.Files[i], "SightImg", out filepath, out oldfilename); if (result_landspace) { Hotelinfo.SupplierPic = DisonseImg_Sight_Add(filepath, oldfilename, Hotelinfo.SupplierPic); } } } //判断是新增还是修改,修改调用下马的方法 if (tid > 0) { //取出页面上未修改的图片 Hotelinfo.SupplierPic = GetImg_Photo(this.hidImgPhoto.Value, Hotelinfo.SupplierPic); } #endregion //导游词 string TourGuids = Utils.GetFormValue("TourGuids"); //当前公司编号 Hotelinfo.CompanyId = this.SiteUserInfo.CompanyID; //当前操作人编号 Hotelinfo.OperatorId = this.SiteUserInfo.ID; #region 联系人信息 Hotelinfo.SupplierContact = new List <EyouSoft.Model.CompanyStructure.SupplierContact>(); string[] UserName = Utils.GetFormValues("inname"); string[] Userdate = Utils.GetFormValues("indate"); string[] Userphone = Utils.GetFormValues("inphone"); string[] Usermobile = Utils.GetFormValues("inmobile"); string[] Userqq = Utils.GetFormValues("inqq"); string[] Usermail = Utils.GetFormValues("inemail"); string[] Userfax = Utils.GetFormValues("inefax"); for (int i = 0; i < UserName.Length; i++) { EyouSoft.Model.CompanyStructure.SupplierContact scmodel = new EyouSoft.Model.CompanyStructure.SupplierContact(); scmodel.CompanyId = SiteUserInfo.CompanyID; scmodel.ContactName = UserName[i]; scmodel.JobTitle = Userdate[i]; scmodel.ContactTel = Userphone[i]; scmodel.ContactMobile = Usermobile[i]; scmodel.QQ = Userqq[i]; scmodel.Email = Usermail[i]; scmodel.ContactFax = Userfax[i]; scmodel.SupplierType = EyouSoft.Model.EnumType.CompanyStructure.SupplierType.酒店; Hotelinfo.SupplierContact.Add(scmodel); } #endregion #region 价格信息 Hotelinfo.RoomTypes = new List <EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo>(); string[] Chamber = Utils.GetFormValues("Chamber"); string[] SalaesPrices = Utils.GetFormValues("SalaesPrices"); string[] SettlementPrice = Utils.GetFormValues("SettlementPrice"); string[] radiobtnValue = Utils.GetFormValues("hd_rbtn"); for (int j = 0; j < Chamber.Length; j++) { EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo roomtype = new EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo(); roomtype.AccountingPrice = Utils.GetDecimal(SettlementPrice[j]); if (radiobtnValue[j] == "1") { roomtype.IsBreakfast = true; } else { roomtype.IsBreakfast = false; } roomtype.Name = Chamber[j]; roomtype.SellingPrice = Utils.GetDecimal(SalaesPrices[j]); Hotelinfo.RoomTypes.Add(roomtype); } #endregion //备注 string HotelRemarks = Utils.GetFormValue("HotelRemarks"); Hotelinfo.UnitName = unionname; Hotelinfo.UnitAddress = TxtHotelAddress; Hotelinfo.Star = (EyouSoft.Model.EnumType.SupplierStructure.HotelStar)Enum.Parse(typeof(EyouSoft.Model.EnumType.SupplierStructure.HotelStar), HotelStart.ToString()); Hotelinfo.Introduce = HotelIntroduction; Hotelinfo.TourGuide = TourGuids; Hotelinfo.Remark = HotelRemarks; Hotelinfo.IssueTime = System.DateTime.Now; int res = 0; if (tid > 0) { //修改酒店信息 res = HotelBll.UpdateHotelInfo(Hotelinfo); } else { //添加酒店信息 res = HotelBll.InsertHotelInfo(Hotelinfo); } if (res > 0) { MessageBox.ResponseScript(this, string.Format(";alert('{0}');window.parent.Boxy.getIframeDialog('{1}').hide(); {2}", "保存成功!", Utils.GetQueryStringValue("iframeId"), tid > 0 ? "window.parent.location.reload();" : "window.parent.location.href='/SupplierControl/Hotels/HotelList.aspx';")); } else { MessageBox.ResponseScript(this, ";alert('保存失败!');"); } }
/// <summary> /// 获取酒店供应商信息集合(供应商基本信息,图片信息,房型信息。同行登录口适用) /// </summary> /// <param name="companyId">公司(专线)编号</param> /// <param name="pageSize">每页记录数</param> /// <param name="pageIndex">页索引</param> /// <param name="recordCount">总记录数</param> /// <param name="info">查询信息</param> /// <returns></returns> public IList <EyouSoft.Model.SupplierStructure.SupplierHotelInfo> GetSiteHotels(int companyId, int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.SupplierStructure.SupplierHotelSearchInfo info) { IList <EyouSoft.Model.SupplierStructure.SupplierHotelInfo> items = new List <EyouSoft.Model.SupplierStructure.SupplierHotelInfo>(); EyouSoft.Model.SupplierStructure.SupplierHotelInfo tmpModel = null; IEnumerable <XElement> xRows = null; XElement xRoot = null; StringBuilder cmdQuery = new StringBuilder(); string tableName = "tbl_CompanySupplier"; string primaryKey = "Id"; string orderByString = "Id DESC"; StringBuilder fields = new StringBuilder(); #region fields fields.Append(" Id,ProvinceId,ProvinceName,CityId,CityName,UnitName,TradeNum,UnitAddress "); fields.Append(" ,(select Id,SupplierId,PicName,PicPath from tbl_SupplierAccessory where tbl_SupplierAccessory.SupplierId = tbl_CompanySupplier.Id for xml raw,root('root')) as HotelPics "); fields.Append(" ,(select RoomTypeId,SupplierId,Name,SellingPrice,AccountingPrice,IsBreakfast from tbl_SupplierHotelRoomType where tbl_SupplierHotelRoomType.SupplierId = tbl_CompanySupplier.Id for xml raw,root('root')) as HotelRoomTypes "); fields.Append(",(SELECT Star,Introduce FROM tbl_SupplierHotel AS B WHERE B.SupplierId=tbl_CompanySupplier.Id for xml raw,root('root')) AS Star"); #endregion #region 拼接查询条件 cmdQuery.AppendFormat(" CompanyId={0} AND IsDelete='0' AND SupplierType={1} ", companyId, (int)EyouSoft.Model.EnumType.CompanyStructure.SupplierType.酒店); info = info ?? new EyouSoft.Model.SupplierStructure.SupplierHotelSearchInfo(); if (info.CityId.HasValue) { cmdQuery.AppendFormat(" AND CityId={0} ", info.CityId.Value); } if (!string.IsNullOrEmpty(info.Name)) { cmdQuery.AppendFormat(" AND UnitName LIKE '%{0}%' ", info.Name); } if (info.ProvinceId.HasValue) { cmdQuery.AppendFormat(" AND ProvinceId={0} ", info.ProvinceId.Value); } if (info.Star.HasValue) { cmdQuery.AppendFormat(" AND EXISTS(SELECT 1 FROM tbl_SupplierHotel AS A WHERE A.SupplierId=tbl_CompanySupplier.Id AND Star={0}) ", (int)info.Star.Value); } #endregion using (IDataReader rdr = DbHelper.ExecuteReader(this._db, pageSize, pageIndex, ref recordCount, tableName, primaryKey, fields.ToString(), cmdQuery.ToString(), orderByString)) { while (rdr.Read()) { tmpModel = new EyouSoft.Model.SupplierStructure.SupplierHotelInfo(); if (!rdr.IsDBNull(0)) { tmpModel.Id = rdr.GetInt32(0); } if (!rdr.IsDBNull(1)) { tmpModel.ProvinceId = rdr.GetInt32(1); } if (!rdr.IsDBNull(2)) { tmpModel.ProvinceName = rdr.GetString(2); } if (!rdr.IsDBNull(3)) { tmpModel.CityId = rdr.GetInt32(3); } if (!rdr.IsDBNull(4)) { tmpModel.CityName = rdr.GetString(4); } if (!rdr.IsDBNull(5)) { tmpModel.UnitName = rdr.GetString(5); } if (!rdr.IsDBNull(6)) { tmpModel.TradeNum = rdr.GetInt32(6); } if (!rdr.IsDBNull(7)) { tmpModel.UnitAddress = rdr.GetString(7); } if (!rdr.IsDBNull(8)) { tmpModel.SupplierPic = new List <EyouSoft.Model.SupplierStructure.SupplierPic>(); EyouSoft.Model.SupplierStructure.SupplierPic spModel = null; xRoot = XElement.Parse(rdr.GetString(8)); if (xRoot != null) { xRows = Utils.GetXElements(xRoot, "row"); if (xRows != null && xRows.Count() > 0) { foreach (var t in xRows) { spModel = new EyouSoft.Model.SupplierStructure.SupplierPic(); //Id,SupplierId,PicName,PicPath spModel.Id = Utils.GetInt(Utils.GetXAttributeValue(t, "Id")); spModel.SupplierId = Utils.GetInt(Utils.GetXAttributeValue(t, "SupplierId")); spModel.PicName = Utils.GetXAttributeValue(t, "PicName"); spModel.PicPath = Utils.GetXAttributeValue(t, "PicPath"); tmpModel.SupplierPic.Add(spModel); } } } } if (!rdr.IsDBNull(9)) { tmpModel.RoomTypes = new List <Model.SupplierStructure.SupplierHotelRoomTypeInfo>(); Model.SupplierStructure.SupplierHotelRoomTypeInfo shrtModel = null; xRoot = XElement.Parse(rdr.GetString(9)); if (xRoot != null) { xRows = Utils.GetXElements(xRoot, "row"); if (xRows != null && xRows.Count() > 0) { foreach (var t in xRows) { shrtModel = new EyouSoft.Model.SupplierStructure.SupplierHotelRoomTypeInfo(); //RoomTypeId,SupplierId,Name,SellingPrice,AccountingPrice,IsBreakfast shrtModel.RoomTypeId = Utils.GetInt(Utils.GetXAttributeValue(t, "RoomTypeId")); shrtModel.Name = Utils.GetXAttributeValue(t, "Name"); shrtModel.SellingPrice = Utils.GetDecimal(Utils.GetXAttributeValue(t, "SellingPrice")); shrtModel.AccountingPrice = Utils.GetDecimal(Utils.GetXAttributeValue(t, "AccountingPrice")); shrtModel.IsBreakfast = (Utils.GetXAttributeValue(t, "IsBreakfast") == "1" || Utils.GetXAttributeValue(t, "IsBreakfast").ToLower() == "true") ? true : false; tmpModel.RoomTypes.Add(shrtModel); } } } } if (!rdr.IsDBNull(10)) { xRoot = XElement.Parse(rdr.GetString(10)); if (xRoot != null) { xRows = Utils.GetXElements(xRoot, "row"); if (xRows != null && xRows.Count() > 0) { foreach (var t in xRows) { tmpModel.Star = (EyouSoft.Model.EnumType.SupplierStructure.HotelStar)Utils.GetInt(Utils.GetXAttributeValue(t, "Star")); tmpModel.Introduce = Utils.GetXAttributeValue(t, "Introduce"); break; } } } } items.Add(tmpModel); } } return(items); }