/** * QuoteDemandEdit.aspx.cs * * 功 能: 报价需求编辑页 * 类 名: QuoteDemandEdit * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── * V0.01 2013-4-12 9:23 吴崎均 初版 * V0.02 2013-4-17 吴崎均 修改Page_load方法为Target=GetDataById参数分配LoadModelById()方法 * V0.03 2013-5-3 10:24 吴崎均 修改关联字典表的字段存储值为MeanValue * * * * * * */ using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.BLL.Sys; using CY.BLL.EC; using CY.Infrastructure.Common; using CY.Model; using CY.WebForm.cs; using CY.Model.Inquiry; using CY.BLL; namespace CY.WebForm.Pages.business { /// /// 报价需求编辑页 /// public partial class QuoteDemandEdit : BasePage { private Sys_DictionaryBLL _sys_DictionaryBLL = null;//字典业务逻辑操作类对象 private SysInquiry_PrintingTypeBLL _sysInquiry_PrintingTypeBLL = null;//印刷业务类型业务逻辑操作类对象 private EC_QuoteDemandBLL _eC_QuoteDemandBLL = null;//报价需求逻辑操作对象 /// /// 返回模式是否为返回状态与数据代码 /// private bool _isReturnResultCode = false; /// /// 初始化 /// public QuoteDemandEdit() { _sys_DictionaryBLL = new Sys_DictionaryBLL(); _eC_QuoteDemandBLL = new EC_QuoteDemandBLL(); _sysInquiry_PrintingTypeBLL = new SysInquiry_PrintingTypeBLL(); } /// /// 界面加载事件 /// /// /// protected void Page_Load(object sender, EventArgs e) { try { switch (Request["Target"]) { case "SaveInfo": SaveQuoteDemandInfo(); return; case "GetDataById": LoadModelById(); break; default://一般情况不处理 Init(); return; } } catch (Exception ex) { PAGEHandleException(ex); if (!_isReturnResultCode) return; else ; Response.Clear(); Response.Write("-1"); } Response.End(); } private void Init() { InitPageData(); LoadModelById(); if (IsPostBack || IsCallback) return; else { } } /// /// 根据编号加载数据 /// /// private bool LoadModelById() { // DealMvc.Common.Net.DealString.ChangeSQL(Request["ParamName"]) int? id = MyConvert.ConvertToInt32(Request["id"]); _isReturnResultCode = !string.IsNullOrEmpty(Request["IsFrontRequest"]) && "frontTrue".Equals(Request["IsFrontRequest"]); EC_QuoteDemand eC_QuoteDemand = null; if (id.HasValue) { eC_QuoteDemand = _eC_QuoteDemandBLL.SelectModleById(id.Value); if (eC_QuoteDemand.State == 0) selState.DataBind();//重新绑定 else ; selState.Value = eC_QuoteDemand.State.ToString(); selPrintTypes.Value = eC_QuoteDemand.PrintTypeId.ToString(); selState.Disabled = true; } else { EC_MemberExtend eC_MemberExtend = new CY.BLL.EC_MemberBasicBLL().GetMemberExtendByMemberId(CurrentUser.MemberId); eC_QuoteDemand = new EC_QuoteDemand(); eC_QuoteDemand.ContactPhone = eC_MemberExtend.PhoneNum; eC_QuoteDemand.QQ = eC_MemberExtend.QQ; eC_QuoteDemand.State = -1; eC_QuoteDemand.CallTypeId = 1; eC_QuoteDemand.PrintTypeId = -1;//默认dm单 selState.Disabled = false; this.txtRemark.Value = string.Empty; } string jmodel = null == eC_QuoteDemand ? "" : JsonHelper.GetJsonStringByObject(eC_QuoteDemand); //InquiryCommonModel _inquiryCommonModel = null; //if (!string.IsNullOrEmpty(eC_QuoteDemand.PrintParameter().PrintParameter)) // _inquiryCommonModel = SerializationHelper.DeSerialize(typeof(InquiryCommonModel), eC_QuoteDemand.PrintParameter().PrintParameter) as InquiryCommonModel; //else ; //if (!_isReturnResultCode) //{ // rptInquiryCommon.DataSource = new List() { _inquiryCommonModel }; // rptInquiryCommon.DataBind(); //} //若是外部获取数据则输出jsonString if (_isReturnResultCode && id.HasValue) { Response.Write(jmodel); } else { int? stateId = eC_QuoteDemand.State; btnSave.Disabled = stateId.HasValue && stateId.Value == 0; selState.Disabled = !stateId.HasValue || btnSave.Disabled; Request.RequestContext.RouteData.DataTokens.Add("jmodel", jmodel); } return true; } /// /// 保存信息 /// private void SaveQuoteDemandInfo() { if ("0".Equals(Request["State"])) { JavaScript.MessageBox("已发布的信息不能被修改!", this); return; }//已发布的信息不能被修改 EC_QuoteDemand QuoteDemand = new EC_QuoteDemand(); QuoteDemand.Operator = CurrentUser.ShortName; QuoteDemand.MemberId = CurrentUser.MemberId; QuoteDemand.AskPriceNoteId = 1; if (selPrintTypes.Value != "-1") { /* 新增时获取印刷选项参数 */ if (string.IsNullOrEmpty(Request["txtKeyid"]) || true) { InquiryCommonModel _inquiryCommonModel = CY.WebForm.Pages.front.InquiryOnLine.GetInquiryCommonModel(); if (null == _inquiryCommonModel) return; _inquiryCommonModel.DeliveryMode = MyConvert.ConvertToInt32(deliveryMode.Value).Value; _inquiryCommonModel.BillMode = MyConvert.ConvertToInt32(billMode.Value).Value; _inquiryCommonModel.Remarks = MyConvert.ConvertToString(Request["remarks"]); QuoteDemand.PrintParameter().PrintParameter = SerializationHelper.Serialize(_inquiryCommonModel); } bool isEdit = (null == QuoteDemand.Keyid || !QuoteDemand.Keyid.HasValue || 0 == QuoteDemand.Keyid.Value) ? false : true; bool isWin = WebUtil.SaveData(_eC_QuoteDemandBLL.AddData, _eC_QuoteDemandBLL.UpdateData, QuoteDemand); Response.Clear();//不输出resultCode JavaScript.MessageBox(isWin ? "操作成功" : "操作失败", this); if (!isEdit)//有人发布需求则调用清除需求缓存方法 { //WebUtil.UpdateCacheByCoverWay(CacheDataFiles.QuoteDemand); if (_eC_QuoteDemandBLL.IsTodayHasValue(CurrentUser.MemberId)) { Pay_PaymentAccountBLL _pay_PaymentAccountBLL = new Pay_PaymentAccountBLL(); isWin = _pay_PaymentAccountBLL.SendPoOrMoToMember(CurrentUser.MemberId, 38, null); } } } else { //QuoteDemand.DemandName = txtPrintName.Value; //QuoteDemand.QuoteCount = Convert.ToInt32(txtPrintCount.Value); bool isEdit = !string.IsNullOrEmpty(Request["txtKeyid"]); bool isWin = WebUtil.SaveData(_eC_QuoteDemandBLL.AddData, _eC_QuoteDemandBLL.UpdateData, QuoteDemand); Response.Clear();//不输出resultCode JavaScript.MessageBox(isWin ? "操作成功" : "操作失败", this); this.txtPrintName.Value = ""; this.txtRemark.Value = ""; this.TextSpec.Value = ""; if (!isEdit)//有人发布需求则调用清除需求缓存方法 { WebUtil.UpdateCacheByCoverWay(CacheDataFiles.QuoteDemand); if (_eC_QuoteDemandBLL.IsTodayHasValue(CurrentUser.MemberId)) { Pay_PaymentAccountBLL _pay_PaymentAccountBLL = new Pay_PaymentAccountBLL(); isWin = _pay_PaymentAccountBLL.SendPoOrMoToMember(CurrentUser.MemberId, 38, null); } } } Init(); } /// /// 初始化页面数据 /// private void InitPageData() { selPrintTypes.DataSource = _sysInquiry_PrintingTypeBLL.SelectUsedModles(); selState.DataSource = _sys_DictionaryBLL.GetDataByType("用户需求状态"); selCallTypes.DataSource = _sys_DictionaryBLL.GetDataByType("通知类型"); deliveryMode.DataSource = _sys_DictionaryBLL.GetDataByType("收货方式"); billMode.DataSource = _sys_DictionaryBLL.GetDataByType("票据要求"); deliveryMode.DataBind(); billMode.DataBind(); selPrintTypes.DataBind(); selState.DataBind(); selCallTypes.DataBind(); selPrintTypes.Items.Add(new ListItem("其他需求", "-1")); selPrintTypes.Value = ""; selCallTypes.Value = "1";//默认为站内信息 selState.Value = "0"; selState.Items.Remove(selState.Items[selState.SelectedIndex]);//添加时没有有效这个状态 selState.Value = "-1";//默认为未发布 } } }