using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using LIMS.MessageBox;
|
using CY.Model;
|
using System.Web.UI.WebControls;
|
using System.Web.UI.HtmlControls;
|
using CY.Model.Inquiry;
|
using CY.Infrastructure.Common;
|
using CY.BLL;
|
using CY.Infrastructure.Logging;
|
using CY.Infrastructure.Configuration;
|
using CY.BLL.Inquiry;
|
using CY.BLL.Sys;
|
|
namespace CY.WebForm
|
{
|
/// <summary>
|
/// 基础页面类
|
/// </summary>
|
public class MainPage : Page
|
{
|
EC_MemberBasicBLL bll_EC_MemberBasicBLL = new EC_MemberBasicBLL();
|
Pay_PaymentAccountBLL bll_Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL();
|
|
#region 构造
|
|
/// <summary>
|
/// 构建一个新的Page
|
/// </summary>
|
public MainPage()
|
{
|
Load += new EventHandler(LimsPage_Load);
|
}
|
|
public void LimsPage_Load(object sender, EventArgs e)
|
{
|
base.OnPreLoad(e);
|
this.Response.Cache.SetNoStore();
|
try
|
{
|
this.Header.Title = this.Header.Title + " - 印刷行业在线交易平台";
|
}
|
catch
|
{
|
LoggingFactory.GetLogger().Log(this.Request.Url.AbsolutePath);
|
}
|
//SendToRealUrl();
|
HtmlMeta meta = new HtmlMeta();
|
meta.HttpEquiv = "X-UA-Compatible";
|
meta.Content = "IE=EmulateIE7";
|
|
string customerId = string.Empty;
|
//表示厂商设置
|
if (Request["SetFirm"] != null)
|
{
|
Utils.WriteCookie("SetCustomerId", string.Empty, -1);
|
}
|
//表示客户设置
|
if (Request["CustomerId"] != null)
|
{
|
customerId = Request["CustomerId"].ToString();
|
Utils.WriteCookie("SetCustomerId", customerId);
|
}
|
|
}
|
|
protected void SendToRealUrl()
|
{
|
//if (!CY.Config.WebInfo.Instance.WebStatus.ToBoolean2())
|
//{
|
// Server.Transfer("Http://" + CY.Config.WebInfo.Instance.WebDomain + "/Close.html");
|
|
//}
|
|
HttpContext httpCurrent = HttpContext.Current;
|
HttpRequest req = httpCurrent.Request;
|
string oUrl = req.Url.AbsoluteUri;
|
string oHome = req.Url.Host;
|
string endStr = string.Empty;
|
string realDomain = oHome.Replace(".cyin.cn", "");
|
int bid = bll_EC_MemberBasicBLL.GetBid(realDomain);
|
if (bid == -1 || bid == 0)
|
{
|
return;
|
}
|
else
|
{
|
string realHome = "Http://" + CY.Config.WebInfo.Instance.WebDomain + "/Pages/Templet/Default";
|
endStr = GetEndStr(oHome, oUrl);
|
if (string.IsNullOrEmpty(endStr))
|
{
|
endStr = "CompanyIndex.aspx";
|
}
|
realHome = realHome + "/" + endStr + "?i=" + bid;
|
Server.Transfer(realHome);
|
|
}
|
}
|
|
private string GetEndStr(string oHome, string oUrl)
|
{
|
string endStr = string.Empty;
|
int i = oUrl.IndexOf(oHome);
|
int k = oUrl.IndexOf('/', i);
|
if (k >= 0)
|
{
|
endStr = oUrl.Substring(k + 1, oUrl.Length - k - 1);
|
}
|
return endStr;
|
}
|
|
protected override void OnPreLoad(EventArgs e)
|
{
|
|
//try
|
//{
|
// this.Header.Controls.Add(meta);
|
//}
|
//catch(Exception ex)
|
//{
|
// LoggingFactory.GetLogger().Log(this.Request.Url.AbsolutePath);
|
//}
|
}
|
|
#endregion
|
|
#region 提供输出javascript到当前页面的方法
|
|
/// <summary>
|
/// 提供输出javascript到当前页面的方法
|
/// </summary>
|
public class JavaScript
|
{
|
#region 显示IE浏览器端的对话框
|
/// <summary>
|
/// 显示IE浏览器端的对话框
|
/// </summary>
|
/// <param name="Message">信息</param>
|
/// <param name="page">源页面</param>
|
/// <param name="IsClose">是否关闭窗口</param>
|
public static void MessageBox(string Message, System.Web.UI.Page page, bool IsClose)
|
{
|
Type cstype = page.GetType();
|
string guid = Guid.NewGuid().ToString();
|
try
|
{
|
LIMS.MessageBox.MessageBox tmp_box = new LIMS.MessageBox.MessageBox();
|
tmp_box.ID = "__LIMSBox_" + guid;
|
tmp_box.CssClass = "LIMSMessageBox";
|
tmp_box.Visible = false;
|
page.Form.Controls.Add(tmp_box);
|
}
|
catch
|
{
|
|
}
|
MessageBox box = (MessageBox)page.FindControl("__LIMSBox_" + guid);
|
if (box == null)
|
{
|
Message = Message.Replace("\r\n", "\\r\\n").Replace("'", "\"");
|
if (IsClose)
|
{
|
page.ClientScript.RegisterStartupScript(cstype, "MessageBox", string.Format("<script>alert('{0}');top.window.opener=null;top.window.close();</script>", Message));
|
}
|
else
|
{
|
page.ClientScript.RegisterStartupScript(cstype, "MessageBox", string.Format("<script>alert('{0}');</script>", Message));
|
}
|
}
|
else
|
{
|
Message = Message.Replace("\r\n", "\\r\\n").Replace("\\r\\n", "<br />").Replace("\\n", "<br />").Replace("\\\\", "\\").Replace("'", "\"");
|
box.Show("温馨提示", Message, page, IsClose);
|
}
|
}
|
#endregion
|
|
#region 显示IE浏览器端的对话框并且跳转页面
|
|
/// <summary>
|
/// 显示IE浏览器端的对话框并且跳转页面
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page">源页面</param>
|
public static void MessageBox(string Message, System.Web.UI.Page page)
|
{
|
string script = "alertMsg('" + Message + "')";
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
/// <summary>
|
/// 显示对话框
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
/// <param name="IsClose">是否关闭</param>
|
/// <param name="IsRefreshParent">是否刷新父窗口</param>
|
public static void MessageBox(string Message, System.Web.UI.Page page, bool IsClose, bool IsRefreshParent)
|
{
|
string jsfn = "";
|
if (IsClose && IsRefreshParent)
|
jsfn = "top.frmright.ReLoad();top.Dialog.close();";
|
else if (IsClose)
|
jsfn = "top.Dialog.close();";
|
else if (IsRefreshParent)
|
jsfn = "top.frmright.ReLoad();";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
|
|
/// <summary>
|
/// 显示对话框,给父页面控件赋值
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
/// <param name="IsClose">是否关闭</param>
|
/// <param name="IsRefreshParent">是否刷新父窗口</param>
|
public static void MessageBoxfuzhi(string Message, System.Web.UI.Page page, bool IsClose, string kongjian,string fileUrl)
|
{
|
string jsfn = "";
|
if (IsClose && !string.IsNullOrEmpty(kongjian))
|
jsfn = "top.frmright.document.getElementById('" + kongjian + "').src = '"+ fileUrl + "';top.frmright.document.getElementById('view" + kongjian + "').href = '" + fileUrl + "';top.frmright.document.getElementById('hide" + kongjian + "').value = '" + fileUrl + "';top.Dialog.close();";
|
else if (IsClose)
|
jsfn = "top.Dialog.close();";
|
else if (!string.IsNullOrEmpty(kongjian))
|
jsfn = "top.frmright.document.getElementById('" + kongjian + "').src = '" + fileUrl + "';top.frmright.document.getElementById('view" + kongjian + "').href = '" + fileUrl + "';top.frmright.document.getElementById('hide" + kongjian + "').value = '" + fileUrl + "';";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
|
/// <summary>
|
/// 显示对话框
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
/// <param name="IsClose">是否关闭</param>
|
/// <param name="IsRefreshParent">是否刷新父窗口</param>
|
public static void MessageBoxs(string Message, System.Web.UI.Page page, bool IsClose, bool IsRefreshParent)
|
{
|
string jsfn = "";
|
if (IsClose && IsRefreshParent)
|
jsfn = "parent.ReLoad();parent.Dialog.close();";
|
else if (IsClose)
|
jsfn = "parent.Dialog.close();";
|
else if (IsRefreshParent)
|
jsfn = "parent.ReLoad();";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
|
/// <summary>
|
/// 显示对话框,刷新第一个窗体和父窗体
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
public static void MessageBoxCloseAndRefreshparent(string Message, System.Web.UI.Page page)
|
{
|
string jsfn = "top.document.getElementById('_DialogFrame_0').contentWindow.ReWindowSelf();top.Dialog.close();";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
/// <summary>
|
/// 显示对话框,刷新第一个窗体和父窗体
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
public static void MessageBoxCloseAndRefreshFirst(string Message, System.Web.UI.Page page)
|
{
|
string jsfn = "top.document.getElementById('_DialogFrame_0').contentWindow.ReWindowSelf();top.frmright.ReLoad();top.Dialog.close();";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
|
/// <summary>
|
/// 显示对话框,刷新第一个窗体和父窗体
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
public static void MessageBoxCloseAndRefreshFirsts(string Message, System.Web.UI.Page page)
|
{
|
string jsfn = "top.document.getElementById('_DialogFrame_0').contentWindow.ReWindowSelf();top.Dialog.close();";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
/// <summary>
|
/// 显示对话框,刷新第一个窗体和父窗体(父窗体为切换框)
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page"></param>
|
public static void MessageBoxAndFirstRefresh(string Message, System.Web.UI.Page page, bool IsClose)
|
{
|
string jsfn = "";
|
if (IsClose)
|
jsfn = "top.frmright.frmrightChild.ReLoad();top.Dialog.close();";
|
else
|
jsfn = "top.document.getElementById('_DialogFrame_0').contentWindow.ReWindowSelf();top.frmright.frmrightChild.ReLoad();";
|
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
/// <summary>
|
/// 提示信息并附加后续操作
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page">源页面</param>
|
/// <param name="jsfn">后续操作</param>
|
public static void MessageBox(string Message, System.Web.UI.Page page, string jsfn)
|
{
|
string script = string.Format("alertMsg('{0}');{1}", Message, jsfn);
|
JavaScript.ExecuteClientScript("key", script, page);
|
}
|
/// <summary>
|
/// 提示信息并刷新
|
/// </summary>
|
/// <param name="Message">消息</param>
|
/// <param name="page">源页面</param>
|
/// <param name="isRefresh">是否刷新(默认刷新)</param>
|
public static void MessageBox(string Message, System.Web.UI.Page page, Int16 isRefresh = 1)
|
{
|
MessageBox(Message, page, 1 == isRefresh ? "global.delayrefresh();" : "");
|
}
|
#endregion
|
|
#region 执行IE浏览器端的脚本
|
/// <summary>
|
/// 执行IE浏览器端的脚本
|
/// </summary>
|
/// <param name="functionName">脚本功能函数名或函数</param>
|
/// <param name="script">脚本语句</param>
|
/// <param name="page">源页面</param>
|
public static void ExecuteClientScript(string key, string script, Page page)
|
{
|
Type cstype = page.GetType();
|
page.ClientScript.RegisterStartupScript(cstype, key, string.Format("<script>{0}</script>", script));
|
}
|
|
public static void RegisterStartupScript(string key, string script, Page page)
|
{
|
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), key))
|
page.ClientScript.RegisterStartupScript(page.GetType(), key, string.Format("<script>{0}</script>", script));
|
|
}
|
#endregion
|
|
#region 显示错误信息
|
/// <summary>
|
/// 显示错误信息
|
/// </summary>
|
/// <param name="page">当前页</param>
|
/// <param name="msg">弹出警告信息</param>
|
/// <param name="detail">错误页面信息</param>
|
public static void ShowError(Page page, string msg, string detail)
|
{
|
if (!string.IsNullOrEmpty(msg))
|
{
|
ResponseMsg(page, msg);
|
}
|
if (!string.IsNullOrEmpty(detail))
|
{
|
// page.Response.Write(string.Format("<script>top.window.location.href=\"{0}/error.aspx?msg={1}\"</script>", LimsConfiguration.LimsWebURL, detail));
|
page.Response.Write(string.Format("<script>var msgEncode='{1}';try {{msgEncode = encodeURIComponent(msgEncode);}} catch(ex) {{msgEncode = escape(msgEncode);}}top.window.location.href=\"/LIMS_WEB/error.aspx?msg=\"+msgEncode;</script>", WebSiteSetting.HomepageURL, detail));
|
}
|
}
|
#endregion
|
|
#region 超时//todo
|
/// <summary>
|
/// 超时
|
/// </summary>
|
public static void ShowTimeOut(Page page)
|
{
|
ResponseMsg(page, "连接超时,请重新登录!");
|
page.Response.Write("<script>window.location.href=\"http://www.cyin.cn\"</script>");
|
}
|
#endregion
|
|
#region 后退
|
/// <summary>
|
/// 后退
|
/// </summary>
|
public static void GoBack(Page page)
|
{
|
page.Response.Write("<script>window.history.go(-1);</script>");
|
}
|
#endregion
|
|
#region 刷新父窗口
|
/// <summary>
|
/// 刷新父窗口
|
/// </summary>
|
public static void RefreshParent(Page page)
|
{
|
RegisterStartupScript("key", "top.frmright.ReLoad();", page);
|
}
|
#endregion
|
|
#region 刷新弹出窗口
|
/// <summary>
|
/// 刷新弹出窗口
|
/// </summary>
|
public static void RefreshOpener(Page page)
|
{
|
page.Response.Write("<script>window.opener.location.reload();</script>");
|
}
|
#endregion
|
|
#region 关闭当前窗口并刷新父页面
|
/// <summary>
|
/// 关闭当前窗口并刷新父页面
|
/// </summary>
|
public static void RefreshDIVOpener(Page page)
|
{
|
|
//page.Response.Write("<script>top.frmright.window.location.href=top.frmright.window.location.href;top.Dialog.close();</script>");
|
//page.Response.Write("<script>top.frmright.RefreshDIVOpener();</script>");
|
//ExecuteClientScript("key", "RefreshDIVOpener()", page);
|
//ExecuteClientScript("key", "RefreshDIVOpener();", page);
|
RegisterStartupScript("clientScript", "top.frmright.ReLoad();top.Dialog.close();", page);
|
}
|
|
/// <summary>
|
/// 关闭当前弹出窗口
|
/// </summary>
|
public static void CloseDIVOpener(Page page)
|
{
|
//page.Response.Write("<script>top.frmright.window.location.href=top.frmright.window.location.href;top.Dialog.close();</script>");
|
page.Response.Write("<script>top.Dialog.close();</script>");
|
//ExecuteClientScript("key", "RefreshDIVOpener()", page);
|
}
|
|
public void RefreshOpener(Page page, string location)
|
{
|
page.Response.Write(string.Format("<script>window.opener.location = '{0}';</script>", location));
|
}
|
#endregion
|
|
#region 刷新窗口
|
/// <summary>
|
/// 刷新窗口
|
/// </summary>
|
public static void RefreshSelf(Page page)
|
{
|
page.Response.Write("<script>self.location.reload();</script>");
|
}
|
#endregion
|
|
#region 刷新本页面
|
/// <summary>
|
/// 刷新窗口
|
/// </summary>
|
public static void RefreshThis(Page page)
|
{
|
page.Response.Write("<script>window.location.reload();</script>");
|
}
|
#endregion
|
|
#region 关闭窗口
|
/// <summary>
|
/// 关闭窗口
|
/// </summary>
|
public static void CloseWindow(Page page)
|
{
|
page.Response.Write("<script>window.close();</script>");
|
}
|
#endregion
|
|
#region 信息格式化
|
/// <summary>
|
/// 信息格式化
|
/// </summary>
|
/// <param name="alertMessage">信息</param>
|
public static void ResponseMsg(Page page, string alertMessage)
|
{
|
if (alertMessage.IndexOf("\'") != -1)
|
{
|
alertMessage = alertMessage.Replace("\'", "\\'");
|
}
|
if (alertMessage.IndexOf("\n") != -1)
|
{
|
alertMessage = alertMessage.Replace("\n", "\\n");
|
}
|
if (alertMessage.IndexOf("\r") != -1)
|
{
|
alertMessage = alertMessage.Replace("\r", "\\r");
|
}
|
if (alertMessage.IndexOf("\t") != -1)
|
{
|
alertMessage = alertMessage.Replace("\t", "\\t");
|
}
|
page.Response.Write("<script>alert(\"" + alertMessage + "\");</script>");
|
}
|
#endregion
|
}
|
|
#endregion
|
|
#region 当前登录用户
|
|
/// <summary>
|
/// 当前登录用户
|
/// </summary>
|
public EC_MemberBasic CurrentUser
|
{
|
get
|
{
|
|
EC_MemberBasic m_EC_MemberBasic = Session["nowMemberLogin"] as EC_MemberBasic; //登录帐号
|
//EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByLogin("15012345678", "123456+");//厂商测试帐号
|
//EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByLogin("a1a45s1d4a", "123456+");//个人网店帐号
|
//EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByLogin("buyer", "123456+"); //管理员帐号
|
//EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByLogin("admin", "123456+"); //管理员帐号
|
|
return m_EC_MemberBasic;
|
}
|
set
|
{
|
Session["nowMemberLogin"] = value;
|
}
|
}
|
|
/// <summary>
|
/// 判断用户是否登录
|
/// </summary>
|
public string IsLogin
|
{
|
get
|
{
|
if (CurrentUser != null)
|
return "true";
|
else
|
return "false";
|
}
|
}
|
|
/// <summary>
|
/// 当前登录用户的账户
|
/// </summary>
|
public Pay_PaymentAccount CurrentPayAccount
|
{
|
get
|
{
|
if (CurrentUser == null)
|
{
|
return new Pay_PaymentAccount();
|
}
|
else
|
{
|
Pay_PaymentAccount m_Pay_PaymentAccount = bll_Pay_PaymentAccountBLL.GetModel(CurrentUser.MemberId);
|
return m_Pay_PaymentAccount;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 当前登录用户的资料表
|
/// </summary>
|
public EC_MemberExtend CurrentMemberExtend
|
{
|
get
|
{
|
if (CurrentUser == null)
|
{
|
return new EC_MemberExtend();
|
}
|
else
|
{
|
EC_MemberExtend m_EC_MemberExtend = bll_EC_MemberBasicBLL.GetMemberExtendByMemberId(CurrentUser.MemberId);
|
return m_EC_MemberExtend;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 管理员的账户
|
/// </summary>
|
public Pay_PaymentAccount AdminAccount
|
{
|
get
|
{
|
Pay_PaymentAccount m_Pay_PaymentAccount = bll_Pay_PaymentAccountBLL.GetModel(Guid.Parse("11111111-1111-1111-1111-111111111111"));
|
return m_Pay_PaymentAccount;
|
}
|
}
|
|
#endregion
|
|
#region 权限判断
|
#endregion
|
|
#region 错误处理
|
|
protected void Page_Error(object sender, EventArgs e)
|
{
|
var ex = Server.GetLastError();
|
HandleException(ex);
|
Server.ClearError();
|
}
|
|
protected void HandleException(Exception ex)
|
{
|
bool rethrow = false;
|
//var exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
|
//rethrow = exManager.HandleException(ex, policy);
|
//if (rethrow)
|
//{
|
// this.RedirectPermanent("~/error.aspx");
|
//}
|
|
LoggingFactory.InitializeLogFactory(new Log4NetAdapter());
|
CY.Infrastructure.Logging.ILogger logger = LoggingFactory.GetLogger();
|
logger.Log(ex);
|
this.RedirectPermanent("/error.html");
|
}
|
|
|
protected void PAGEHandleException(Exception ex)
|
{
|
bool rethrow = false;
|
LoggingFactory.InitializeLogFactory(new Log4NetAdapter());
|
CY.Infrastructure.Logging.ILogger logger = LoggingFactory.GetLogger();
|
logger.Log(ex);
|
}
|
|
#endregion
|
|
#region 重定向
|
|
/// <summary>
|
/// 永久重定向
|
/// </summary>
|
/// <param name="url"></param>
|
protected void RedirectPermanent(string url)
|
{
|
// JavaScript.ExecuteClientScript("key", "hideWaitDiv();window.location.href=" + url, this);
|
Response.Redirect(url);
|
}
|
|
#endregion
|
|
#region 方法
|
|
/// <summary>
|
/// 设置控件为只读
|
/// </summary>
|
/// <param name="_Control">Web控件</param>
|
protected void SetControlReadOnly(Control _Control)
|
{
|
if (_Control is WebControl)
|
{
|
WebControl __Control = (WebControl)_Control;
|
__Control.Attributes.Add("readonly", "readonly");
|
__Control.CssClass = "readonly";
|
}
|
else if (_Control is HtmlControl)
|
{
|
HtmlControl __Control = (HtmlControl)_Control;
|
__Control.Attributes.Add("readonly", "readonly");
|
__Control.Attributes.Add("class", "readonly");
|
}
|
}
|
|
/// <summary>
|
/// 批量操作,让控件只读:GOFI XIAO 2007-08-09
|
/// </summary>
|
/// <param name="arr"></param>
|
protected void SetControlReadOnly(params Control[] arr)
|
{
|
foreach (Control c in arr)
|
{
|
SetControlReadOnly(c);
|
}
|
}
|
|
/// <summary>
|
/// 获取URL传入参数并赋值给对应控件
|
/// </summary>
|
/// <param name="control">控件</param>
|
/// <param name="QueryStringName">URL参数名</param>
|
/// <returns>是否成功</returns>
|
protected bool SetURLParameter(Control control, string QueryStringName)
|
{
|
if (!string.IsNullOrEmpty(Request.QueryString[QueryStringName]))
|
{
|
string QueryStringValue = Request.QueryString[QueryStringName].ToString().Trim();
|
if (control is TextBox)
|
{
|
((TextBox)control).Text = QueryStringValue;
|
return true;
|
}
|
else if (control is HiddenField)
|
{
|
((HiddenField)control).Value = QueryStringValue;
|
return true;
|
}
|
else if (control is DropDownList)
|
{
|
((DropDownList)control).SelectedValue = QueryStringValue;
|
return true;
|
}
|
return false;
|
}
|
return true;
|
}
|
|
#endregion
|
|
#region 询价及其设置使用的公共参数
|
|
/// <summary>
|
/// 获取询价公共条件类实例
|
/// </summary>
|
public InquiryCondition InquiryConditionObj
|
{
|
get
|
{
|
InquiryCondition obj = new InquiryCondition();
|
if (CurrentUser.MemberType == "印刷厂商" || CurrentUser.MemberType == "个人网店")
|
{
|
obj.FirmId = CurrentUser.MemberId;
|
}
|
else
|
{
|
obj.FirmId = Guid.Parse(UtilConst.AdminFirmId);
|
}
|
if (SetCustomerId != Guid.Empty)
|
{
|
obj.CustomerId = SetCustomerId;
|
obj.ActualFirmId = obj.CustomerId;
|
}
|
else
|
{
|
obj.CustomerId = Guid.Empty;
|
obj.ActualFirmId = obj.FirmId;
|
}
|
if (obj.CustomerId == Guid.Empty)
|
{
|
if (CurrentUser.MemberType == "印刷厂商" || CurrentUser.MemberType == "个人网店")
|
{
|
EC_MemberBasicBLL memberBasic = new EC_MemberBasicBLL();
|
obj.InquiryId = memberBasic.GetMemberByMemberId(CurrentUser.MemberId).InquiryId;
|
}
|
else
|
{
|
obj.InquiryId = Guid.Parse(UtilConst.AdminFirmId);
|
}
|
|
}
|
else
|
{
|
OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
|
obj.InquiryId = _oA_CorporateClientsBLL.GetModel(obj.CustomerId).InquiryId;
|
}
|
return obj;
|
}
|
}
|
|
/// <summary>
|
/// 要设置询价参数的客户编号
|
/// </summary>
|
public Guid SetCustomerId
|
{
|
get
|
{
|
string customerId = string.Empty;
|
customerId = Utils.GetCookie("SetCustomerId");
|
if (!string.IsNullOrEmpty(customerId))
|
{
|
return Guid.Parse(customerId);
|
}
|
else
|
{
|
return Guid.Empty;
|
}
|
}
|
|
}
|
|
/// <summary>
|
/// 印刷类型
|
/// </summary>
|
public int PrintingTypeId
|
{
|
get
|
{
|
if (Session["Operate"] != null)
|
{
|
if (Request["Operate"] != null)
|
{
|
if (Session["Operate"].ToString() == Request["Operate"].ToString())
|
{
|
if (Request["PrintingTypeId"] != null)
|
{
|
Session["PrintingTypeId"] = Request["PrintingTypeId"].ToString();
|
}
|
}
|
else
|
{
|
Session["PrintingTypeId"] = null;
|
Session["Operate"] = Request["Operate"].ToString();
|
}
|
}
|
}
|
else
|
{
|
if (Request["Operate"] != null)
|
{
|
Session["Operate"] = Request["Operate"].ToString();
|
Session["PrintingTypeId"] = null;
|
}
|
}
|
if (Session["PrintingTypeId"] != null)
|
{
|
return int.Parse(Session["PrintingTypeId"].ToString());
|
}
|
else
|
{
|
return -1;
|
}
|
|
}
|
}
|
|
/// <summary>
|
/// 根据印刷类型获取快速设价提示信息
|
/// </summary>
|
/// <param name="printTypeId"></param>
|
/// <returns></returns>
|
public string GetFastSetMsg(int printTypeId)
|
{
|
string fastSetMsg = string.Empty;
|
///只有用户没有自己保存过询价价格时快速设价才起作用(管理员除外)
|
if (InquiryConditionObj.FirmId != Guid.Parse(UtilConst.AdminFirmId))
|
{
|
if (InquiryConditionObj.InquiryId == Guid.Parse(UtilConst.AdminFirmId))
|
{
|
FastSetByFirmBLL fastSetByFirmBLL = new FastSetByFirmBLL();
|
if (fastSetByFirmBLL.IsExits(InquiryConditionObj.FirmId, InquiryConditionObj.CustomerId, printTypeId))
|
{
|
Inquiry_FastSetByFirm model = fastSetByFirmBLL.GetModel(InquiryConditionObj.FirmId, InquiryConditionObj.CustomerId, printTypeId);
|
|
if (model != null)
|
{
|
if (model.FastValue != 100)
|
{
|
SysInquiry_PrintingTypeBLL _printingTypeBLL = new SysInquiry_PrintingTypeBLL();
|
SysInquiry_PrintingType printTypeModel = _printingTypeBLL.GetModelById(printTypeId);
|
fastSetMsg = printTypeModel.PrintName + "已设置快速价格为系统初始价格的" + model.FastValue + "%,以下价格都是系统初始价格";
|
}
|
}
|
}
|
}
|
}
|
return fastSetMsg;
|
}
|
|
/// <summary>
|
/// 返回Decimal样式
|
/// </summary>
|
/// <param name="num"></param>
|
/// <returns></returns>
|
public string GetDecimalStr(object obj)
|
{
|
if (obj == null)
|
{
|
return "0";
|
}
|
decimal num = (decimal)obj;
|
string str = num.ToString();
|
int index = str.IndexOf('.');
|
if (index == -1)
|
{
|
return str;
|
}
|
else
|
{
|
string str1 = str.Substring(0, index);
|
string str2 = str.Substring(index + 1, str.Length - index - 1);
|
str2 = str2.TrimEnd('0');
|
if (string.IsNullOrEmpty(str2))
|
{
|
return str1;
|
}
|
else
|
{
|
return str1 + "." + str2;
|
}
|
}
|
}
|
|
#endregion
|
}
|
}
|