protected void lbtnSave_Click(object sender, EventArgs e) { string tourCode = Utils.InputText(this.txtTourCode.Value.Trim()); //团号 #region 判断团号是否重复 by 田想兵 2011.8.30 //将团号加入数组 string[] tourCodes = new string[] { tourCode }; //获得重复的数据集合 IList <string> count = new EyouSoft.BLL.TourStructure.Tour().ExistsTourCodes(SiteUserInfo.CompanyID, EditId, tourCodes); if (count != null && count.Count > 0) { //如果该团号存在返回false Response.Write("<script>alert('该团号已存在!');location.href=location.href;</script>"); return; } #endregion #region 成员变量 decimal totalOutlay = 0.0M; decimal totalIncome = 0.0M; #endregion #region 获取参数 int VisitorNum = Convert.ToInt32(Utils.InputText(txtPersonNum.Value.Trim().ToString())); string CustomerCompany = Utils.InputText(txtCustomerCompany.Value.Trim()); //客户单位 string CustomerCompanyId = Utils.InputText(hfSelectCustId.Value.Trim()); //客户单位编号 string OrderNo = Utils.InputText(txtOrderNo.Value.Trim()); //订单号 string SalsId = Utils.InputText(this.hfSaler.Value.Trim()); //销售员Id string ContactTel = Utils.InputText(txtTel.Value.Trim()); //联系电话 string VisitorAttachment = ""; //游客附件 string ContactName = Utils.InputText(this.txtContactName.Value.Trim()); //联系人 string StartTime = Utils.InputText(this.TxtStartTime.Value.Trim()); //委托出团日期 if (Utils.GetFormValue(txtTotalOutlay.ClientID).Trim() != "") { totalOutlay = Utils.GetDecimal(Utils.GetFormValue(txtTotalOutlay.ClientID).Trim()); } if (txtTotalIncome.Value.Trim().ToString() != "") { totalIncome = Utils.GetDecimal(txtTotalIncome.Value.Trim().ToString()); } decimal GrossProfit = Utils.GetDecimal(txtGrossProfit.Value.Trim().ToString());//毛利 #endregion #region 附件 //确定是否有附件 if (fuiLoadAttachment.PostedFile.ContentLength > 0) { string FileName = DateTime.Now.ToString("yyyy_MM_dd HH_mm_ss_") + Guid.NewGuid().ToString() + Path.GetExtension(fuiLoadAttachment.PostedFile.FileName); if (!Directory.Exists(Server.MapPath("/uploadFiles/SingleServe"))) { Directory.CreateDirectory(Server.MapPath("/uploadFiles/SingleServe")); } VisitorAttachment = "/uploadFiles/SingleServe/" + FileName; fuiLoadAttachment.PostedFile.SaveAs(Server.MapPath(VisitorAttachment)); } else { VisitorAttachment = hFileInfo.Value; } #endregion #region 客户要求 string[] CustomerItemArr = Request.Form.GetValues("ddlGuestList"); //服务类别 string[] CustomerServeDetailArr = Request.Form.GetValues("txtGuestRequest"); //具体要求 string[] CustomerPriceItemArr = Request.Form.GetValues("txtGPrice"); //价格 string[] CusRemarks = Request.Form.GetValues("txtGuestRemark"); //备注 IList <TourSingleServiceInfo> CustomerServeList = null; //客户要求集合 if (CustomerItemArr != null) { CustomerServeList = new List <TourSingleServiceInfo>(); for (int i = 0; i < CustomerItemArr.Length; i++) { if (!string.IsNullOrEmpty(CustomerItemArr[i].Trim()) || !string.IsNullOrEmpty(CustomerServeDetailArr[i].Trim()) || !string.IsNullOrEmpty(CustomerPriceItemArr[i].Trim()) || !string.IsNullOrEmpty(CusRemarks[i].Trim())) { TourSingleServiceInfo cModel = new TourSingleServiceInfo(); if (!string.IsNullOrEmpty(CustomerItemArr[i])) { cModel.ServiceType = (EyouSoft.Model.EnumType.TourStructure.ServiceType) int.Parse(CustomerItemArr[i].Trim()); } if (!string.IsNullOrEmpty(CusRemarks[i])) { cModel.Remark = Utils.InputText(CusRemarks[i].Trim(), 450); } if (!string.IsNullOrEmpty(CustomerServeDetailArr[i])) { cModel.Requirement = Utils.InputText(CustomerServeDetailArr[i].Trim(), 450); } if (!string.IsNullOrEmpty(CustomerPriceItemArr[i])) { cModel.SelfPrice = Utils.GetDecimal(CustomerPriceItemArr[i].Trim(), 0); } CustomerServeList.Add(cModel); } } } #endregion #region 供应商安排 string[] SupplierItemArr = Request.Form.GetValues("ddlSupperlierList"); //服务类别 string[] SupplierServeDetailArr = Request.Form.GetValues("txtSupplierRequest"); //具体安排 string[] SupplierPriceItemArr = Request.Form.GetValues("txtAccountCost"); //结算费用 string[] SupName = Request.Form.GetValues("txtSupperName"); //供应商名称 string[] SupRemark = Request.Form.GetValues("txtSupRemark"); //备注 string[] SupPlanIdArr = Request.Form.GetValues("hPlanID"); //供应商安排主键编号 string[] SupperIdArr = Request.Form.GetValues("hSupperID"); //供应商编号 IList <PlanSingleInfo> SupperList = null; //供应商集合 if (SupplierItemArr != null) { SupperList = new List <PlanSingleInfo>(); for (int i = 0; i < SupplierItemArr.Length; i++) { if (!string.IsNullOrEmpty(SupplierItemArr[i].Trim()) || !string.IsNullOrEmpty(SupplierServeDetailArr[i].Trim()) || !string.IsNullOrEmpty(SupplierPriceItemArr[i].Trim()) || !string.IsNullOrEmpty(SupRemark[i].Trim())) { PlanSingleInfo pModel = new PlanSingleInfo(); if (SupPlanIdArr[i] != "0") { pModel.PlanId = SupPlanIdArr[i]; } if (SupperIdArr[i] != "0") { pModel.SupplierId = int.Parse(SupperIdArr[i]); } if (!string.IsNullOrEmpty(SupplierItemArr[i])) { pModel.ServiceType = (EyouSoft.Model.EnumType.TourStructure.ServiceType) int.Parse(SupplierItemArr[i].Trim()); } if (!string.IsNullOrEmpty(SupRemark[i])) { pModel.Remark = Utils.InputText(SupRemark[i].Trim(), 450); } if (!string.IsNullOrEmpty(SupplierServeDetailArr[i])) { pModel.Arrange = Utils.InputText(SupplierServeDetailArr[i].Trim(), 450); } if (!string.IsNullOrEmpty(SupName[i])) { pModel.SupplierName = Utils.InputText(SupName[i].Trim(), 100); } if (!string.IsNullOrEmpty(SupplierPriceItemArr[i])) { pModel.Amount = Utils.GetDecimal(SupplierPriceItemArr[i].Trim(), 0);//结算费用 } pModel.CreateTime = DateTime.Now; SupperList.Add(pModel); } } } #endregion #region 游客信息 string[] VisitorNameArr = Request.Form.GetValues("txtVisitorName"); //游客姓名 string[] VisitorTypeArr = Request.Form.GetValues("ddlVisitorType"); //旅客类型 string[] CardTypeArr = Request.Form.GetValues("ddlCardType"); //证件类型 string[] CardNoArr = Request.Form.GetValues("txtCardNo"); //证件号 string[] ContactTelArr = Request.Form.GetValues("txtContactTel"); //联系电话 string[] SexArr = Request.Form.GetValues("ddlSex"); //性别 string[] ServeItemsArr = Request.Form.GetValues("tefu"); //特服 string[] VisitorIDArr = Request.Form.GetValues("hidVisitorID"); //游客主键 IList <EyouSoft.Model.TourStructure.TourOrderCustomer> VisitorList = new List <EyouSoft.Model.TourStructure.TourOrderCustomer>(); //游客信息集合 if (VisitorNameArr != null) { for (int j = 0; j < VisitorNameArr.Length; j++) { TourOrderCustomer tModel = new TourOrderCustomer(); if (EditId != "")//修改 { if (string.IsNullOrEmpty(VisitorNameArr[j])) { continue; } tModel.IsDelete = false;//修改时 如果姓名为空 就忽略这条信息 } else { //新增 if (!string.IsNullOrEmpty(VisitorNameArr[j])) //游客姓名不为空 { tModel.IsDelete = false; } else { tModel.IsDelete = true;//新增 如果游客姓名为空,就不存入数据库 } } #region 游客基本信息 if (!string.IsNullOrEmpty(VisitorIDArr[j])) { tModel.ID = VisitorIDArr[j]; } else { tModel.ID = Guid.NewGuid().ToString(); } //tModel.TicketStatus = EyouSoft.Model.EnumType.TourStructure.CustomerTicketStatus.正常; tModel.CompanyID = SiteUserInfo.CompanyID; if (!string.IsNullOrEmpty(VisitorNameArr[j])) { tModel.VisitorName = Utils.InputText(VisitorNameArr[j], 50); } if (!string.IsNullOrEmpty(ContactTelArr[j])) { tModel.ContactTel = Utils.InputText(ContactTelArr[j].Trim(), 12); } if (!string.IsNullOrEmpty(CardNoArr[j])) { tModel.CradNumber = Utils.InputText(CardNoArr[j].Trim(), 30); } tModel.CompanyID = this.SiteUserInfo.CompanyID; if (!string.IsNullOrEmpty(CardTypeArr[j])) { tModel.CradType = (EyouSoft.Model.EnumType.TourStructure.CradType) int.Parse(CardTypeArr[j].Trim()); } tModel.IssueTime = DateTime.Now; if (!string.IsNullOrEmpty(SexArr[j])) { tModel.Sex = (EyouSoft.Model.EnumType.CompanyStructure.Sex) int.Parse(SexArr[j].Trim()); } if (!string.IsNullOrEmpty(VisitorTypeArr[j])) { tModel.VisitorType = (EyouSoft.Model.EnumType.TourStructure.VisitorType) int.Parse(VisitorTypeArr[j].Trim()); } #endregion #region 游客特服信息 if (ServeItemsArr != null && !string.IsNullOrEmpty(ServeItemsArr[j])) { CustomerSpecialService SpecialServiceInfo = new CustomerSpecialService(); string[] ServiceItem = ServeItemsArr[j].Split('$'); SpecialServiceInfo.CustormerId = tModel.ID; SpecialServiceInfo.IssueTime = DateTime.Now; int index = 0; foreach (var item in ServiceItem) { if (!string.IsNullOrEmpty(item)) { switch (index) { case 0: SpecialServiceInfo.ProjectName = Utils.InputText(item, 450); break; case 1: SpecialServiceInfo.ServiceDetail = Utils.InputText(item, 450); break; case 2: SpecialServiceInfo.Fee = Utils.GetDecimal(item); break; case 3: SpecialServiceInfo.IsAdd = item == "0" ? true : false; break; } } index++; } tModel.SpecialServiceInfo = SpecialServiceInfo; } #endregion VisitorList.Add(tModel); tModel = null; } } #endregion #region 成员变量 EyouSoft.Model.TourStructure.TourSingleInfo model = new EyouSoft.Model.TourStructure.TourSingleInfo(); EyouSoft.BLL.TourStructure.Tour tourBll = new EyouSoft.BLL.TourStructure.Tour(this.SiteUserInfo); #endregion //实体赋值 if (model != null) { model.CreateTime = DateTime.Now; //发布时间 model.BuyerCName = CustomerCompany; //客户单位名称 model.TourCode = tourCode; //团号 model.LDate = DateTime.Parse(StartTime); //出团日期 model.BuyerCId = int.Parse(CustomerCompanyId); //客户单位编号 model.CompanyId = this.SiteUserInfo.CompanyID; //公司ID model.Plans = SupperList; //供应商安排集合 model.Services = CustomerServeList; //客户要求集合 model.Customers = VisitorList; //游客信息集合 model.TotalAmount = totalIncome; //收入 model.TotalOutAmount = totalOutlay; //支出 model.TourType = EyouSoft.Model.EnumType.TourStructure.TourType.单项服务; //团队类型 model.VirtualPeopleNumber = 0; //虚拟实收 model.ContacterMobile = this.SiteUserInfo.ContactInfo.ContactMobile; model.ContacterTelephone = this.SiteUserInfo.ContactInfo.ContactTel; if (!string.IsNullOrEmpty(VisitorAttachment)) { model.CustomerDisplayType = EyouSoft.Model.EnumType.TourStructure.CustomerDisplayType.附件方式; } else { model.CustomerDisplayType = EyouSoft.Model.EnumType.TourStructure.CustomerDisplayType.输入方式; } if (!string.IsNullOrEmpty(SalsId)) { if (SalsId.Split(',').Length > 0) { model.SellerId = Utils.GetInt(SalsId.Split(',')[0]); model.SellerName = this.selectOperator1.OperName.Split(',')[0]; } else { model.SellerId = Utils.GetInt(SalsId); model.SellerName = this.selectOperator1.OperName; } } model.PlanPeopleNumber = VisitorNum; //游客人数 model.GrossProfit = GrossProfit; //毛利 model.CustomerFilePath = VisitorAttachment; //游客信息附件 model.ContacterTelephone = ContactTel; //联系电话 model.ContacterName = ContactName; //联系人 model.TourDays = 0; model.OrderCode = OrderNo; //订单号 //model.LDate = DateTime.Now; model.OperatorId = this.SiteUserInfo.ID; //操作员 if (EditId != "") { //修改操作 model.TourId = EditId; //团队编号 model.OBuyerCId = int.Parse(hfOBuyerId.Value.ToString()); //客户单位编号 if (tourBll.UpdateSingleTourInfo(model) > 0) { EyouSoft.Common.Function.MessageBox.ResponseScript(this, string.Format("alert('修改成功!');window.parent.Boxy.getIframeDialog('{0}').hide();window.parent.location='/SingleServe/SingleServeList.aspx';", Request.QueryString["iframeId"])); } else { EyouSoft.Common.Function.MessageBox.ResponseScript(this, string.Format("alert('修改失败!');window.parent.Boxy.getIframeDialog('{0}').hide();window.parent.location='/SingleServe/SingleServeList.aspx';", Request.QueryString["iframeId"])); } } else {//新增操作 if (tourBll.InsertSingleTourInfo(model) > 0) { EyouSoft.Common.Function.MessageBox.ResponseScript(this, string.Format("alert('新增成功!');window.parent.Boxy.getIframeDialog('{0}').hide();window.parent.location='/SingleServe/SingleServeList.aspx';", Request.QueryString["iframeId"])); } else { EyouSoft.Common.Function.MessageBox.ResponseScript(this, string.Format("alert('修改失败!');window.parent.Boxy.getIframeDialog('{0}').hide();window.parent.location='/SingleServe/SingleServeList.aspx';", Request.QueryString["iframeId"])); } } } //释放资源 model = null; tourBll = null; }
private void Save() { EyouSoft.BLL.TourStructure.LineInquireQuoteInfo tsBLL = new EyouSoft.BLL.TourStructure.LineInquireQuoteInfo(); tsModel = new LineInquireQuoteInfo(); //初始化model tid = Utils.GetInt(Utils.GetFormValue("tid")); //获取表操作值 bool res; if (tid > 0) { tsModel = tsBLL.GetQuoteModel(tid, 0, SiteUserInfo.TourCompany.TourCompanyId, true); xcModel = tsModel.XingCheng; } /////////////////////////////////////普通数据 tsModel.CustomerName = SiteUserInfo.TourCompany.CompanyName; //询价单位=当前单位名称??编号?? tsModel.ContactName = SiteUserInfo.ContactInfo.ContactName; //联系人姓名 tsModel.CustomerId = SiteUserInfo.TourCompany.TourCompanyId; //询价单位编号 tsModel.CompanyId = SiteUserInfo.CompanyID; //专线公司编号 tsModel.ContactTel = Utils.GetFormValue("vontactTel").ToString(); //联系人电话 tsModel.RouteName = xianluWindow1.Name; //线路名称 tsModel.RouteId = Utils.GetInt(xianluWindow1.Id); //线路ID tsModel.LeaveDate = Convert.ToDateTime(this.txtLDate.Text); //预计出团日期 tsModel.PeopleNum = Utils.GetInt(Utils.GetFormValue("number")); //人数??总人数??成人数??儿童数?? /////////////////////////////////////行程要求////////上传验证 if (string.IsNullOrEmpty(xcModel.PlanAccessory)) { string[] allowExtensions = new string[] { ".jpeg", ".jpg", ".bmp", ".gif", ".pdf", ".xls", ".xlsx", ".doc", ".docx" }; string msg = string.Empty; bool nameForm = EyouSoft.Common.Function.UploadFile.CheckFileType(Request.Files, "workAgree", allowExtensions, null, out msg); if (!nameForm) { lstMsg.Text = msg; } } ////////////////////////////////////行程要求////////上传文件 if (Request.Files.Count > 0)//上传 { string filepath = string.Empty; string oldfilename = string.Empty; bool result = EyouSoft.Common.Function.UploadFile.FileUpLoad(Request.Files["workAgree"], "SupplierControlFile", out filepath, out oldfilename); if (result) { xcModel.PlanAccessoryName = oldfilename;//协议名 xcModel.PlanAccessory = filepath; } } /////////////////////////////////////////行程要求////文本输入 xcModel.QuotePlan = Utils.EditInputText(txt_xinchen.Text); tsModel.XingCheng = xcModel; //行程要求=输入框+附件 tsModel.Requirements = ConProjectControl1.GetDataList(); //客人要求 tsModel.SpecialClaim = Utils.GetFormValue("quotePlan");; //特殊要求说明 ///////////////////////////////////////游客信息 int cusLength = Utils.GetFormValues("cusName").Length; tsModel.Traveller = new TourEverydayApplyTravellerInfo(); tsModel.Traveller.Travellers = new List <EyouSoft.Model.TourStructure.TourOrderCustomer>(); for (int i = 0; i < cusLength; i++) { //游客id string cusID = Utils.GetFormValues("cusID")[i]; EyouSoft.Model.TourStructure.TourOrderCustomer toc = new TourOrderCustomer(); toc.VisitorName = Utils.GetFormValues("cusName")[i]; toc.VisitorType = (EyouSoft.Model.EnumType.TourStructure.VisitorType)(Utils.GetInt(Utils.GetFormValues("cusType")[i])); toc.CradType = (EyouSoft.Model.EnumType.TourStructure.CradType)(Utils.GetInt(Utils.GetFormValues("cusCardType")[i])); toc.CradNumber = Utils.GetFormValues("cusCardNo")[i]; //游客性别 int cusSex = Utils.GetInt(Utils.GetFormValues("cusSex")[i]); toc.Sex = (EyouSoft.Model.EnumType.CompanyStructure.Sex)cusSex; #region 性别 //if (cusSex == 1) //{ // toc.Sex = EyouSoft.Model.EnumType.CompanyStructure.Sex.男; //} //else if (cusSex == 2) //{ // toc.Sex = EyouSoft.Model.EnumType.CompanyStructure.Sex.女; //} //else //{ // toc.Sex = EyouSoft.Model.EnumType.CompanyStructure.Sex.未知; //} #endregion toc.ContactTel = Utils.GetFormValues("cusPhone")[i]; toc.IssueTime = DateTime.Now; EyouSoft.Model.TourStructure.CustomerSpecialService specModel = new EyouSoft.Model.TourStructure.CustomerSpecialService(); if (string.IsNullOrEmpty(cusID)) { toc.ID = System.Guid.NewGuid().ToString(); } else { toc.ID = cusID; } if (Utils.GetFormValues("cusState")[i] == "DEL") { toc.IsDelete = true; } else { toc.IsDelete = false; } //特服 string specive = Utils.GetFormValues("specive")[i]; if (!string.IsNullOrEmpty(specive)) { if (specive.LastIndexOf(',') + 1 == specive.Length) { specive = specive.Substring(0, specive.Length - 1); } specModel.CustormerId = toc.ID; specModel.ProjectName = Server.UrlDecode(Utils.GetFromQueryStringByKey(specive, "txtItem")); specModel.ServiceDetail = Server.UrlDecode(Utils.GetFromQueryStringByKey(specive, "txtServiceContent")); specModel.IsAdd = Utils.GetFromQueryStringByKey(specive, "ddlOperate") == "0" ? true : false; specModel.Fee = Utils.GetDecimal(Utils.GetFromQueryStringByKey(specive, "txtCost")); specModel.IssueTime = DateTime.Now; //特服项目名不能为空,否则不添加该条特服信息 if (!string.IsNullOrEmpty(specModel.ProjectName)) { toc.SpecialServiceInfo = specModel; } } tsModel.Traveller.Travellers.Add(toc); } /// if (tid > 0 && lstMsg.Text == "") { tsModel.Id = tid; res = tsBLL.UpdateInquire(tsModel); } else { res = tsBLL.AddInquire(tsModel); } if (res) { EyouSoft.Common.Function.MessageBox.ResponseScript(this, ";alert('保存成功!');location.href='SelectMoney.aspx';</script>"); } else { EyouSoft.Common.Function.MessageBox.ResponseScript(this, ";alert('保存失败!');"); } }