| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- using SiteCore;
- using System;
- using System.Data;
- using System.Text;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using Utils;
- public partial class MasterPage_View : System.Web.UI.MasterPage
- {
- BasePage _bp = null;
- protected override void OnInit(EventArgs e)
- {
- _bp = this.Page as BasePage;
- if (!IsPostBack)
- {
- if (_bp._checkRight && !_bp.CheckRights()) return;
- if (!_bp._selfCheckPermission) if (!InitPermission()) return;
- if (!_bp._addVisible) btnAdd.Visible = false;
- //else btnAdd.Visible = true;
- //权限
- if (_bp._selfAddVisible == 1) btnAdd.Visible = true;
- }
- //时间
- //hUID.Value = _bp.CurrentUser.UserID.ToString();
- hRepTitle.Value = _bp._repTitle;
- _bp._b_sDate = _bp.GetString("sdt");
- _bp._searchDate = _bp.GetString("dt");
- if (_bp._searchDate == "") _bp._searchDate = _bp.GetString("edt");
- if (_bp._searchDate == "")
- {
- _bp._filterDate = DateTime.Now;
- _bp._searchDate = _bp._filterDate.ToString("yyyy-MM-dd");
- }
- else
- {
- if (_bp._searchDate.IndexOf("/") != -1)
- {
- _bp._searchDate = _bp._searchDate.Replace("/", "-");
- }
- else
- {
- if (_bp._searchDate.Split('-').Length == 1) _bp._searchDate += "-01-01";
- else if (_bp._searchDate.Split('-').Length == 2) _bp._searchDate += "-01";
- }
- _bp._filterDate = Convert.ToDateTime(_bp._searchDate);
- }
- _bp._b_eDate = _bp._searchDate;
- //显示刷新
- btnRefresh.Visible = _bp._refreshVisible;
- if (_bp._choiceVisible) btnChoice.Visible = true;
- string path = CommonHelper.GetPrePath();
- StringBuilder str = new StringBuilder();
- str.AppendFormat("<script src=\"{0}js/boot.js?v={1}\" type=\"text/javascript\"></script>", path, BasePage.SiteVer);
- str.AppendFormat("<script src=\"{0}js/view.js?v={1}\" type=\"text/javascript\"></script>", path, BasePage.SiteVer);
- str.AppendFormat("<script src=\"{0}js/view.ex.js?v={1}\" type=\"text/javascript\"></script>", path, BasePage.SiteVer);
- str.AppendFormat("<link href=\"{0}css/view.css?v={1}\" rel=\"stylesheet\" />", path, BasePage.SiteVer);
- Literal lt = new Literal();
- lt.Text = str.ToString();
- Page.Header.Controls.AddAt(1, lt);
- base.OnInit(e);
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- if (_bp._searchDateEnum == SearchDateEnum.Empty && _bp._searchFilter != "") _bp._searchDateEnum = SearchDateEnum.Default;
- if (_bp._searchDateEnum != SearchDateEnum.Empty) initSearch(_bp._searchFilter);
- keyPlace.Visible = _bp._keyFilterVisible;
- btnAdd.Visible = _bp._addVisible;
- btnRefresh.Visible = _bp._refreshVisible;
- //if (_bp._selfCheckPermission)
- //{
- // btnAdd.Visible = _bp._addVisible;
- // btnRefresh.Visible = _bp._refreshVisible;
- //}
- //else if (_bp._addVisible || (_bp._permissions.Contains("save") || _bp._permissions.Contains("add")))
- //{
- // btnAdd.Visible = true;
- //}
- //if (_bp.gcTag != "")
- //{
- // hGcTag.Value = _bp.gcTag + "_" + _bp.CurrentUser.UserID;
- // DataTable cDt = WebCache.GetGridColumns();
- // DataView cDv = new DataView(cDt);
- // cDv.RowFilter = "name='" + _bp.gcTag + "_" + _bp.CurrentUser.UserID + "'";
- // if (cDv.Count > 0)
- // {
- // _bp.AppendScript("colsData=" + cDv[0]["con"] + ";");
- // }
- //}
- //if (_bp._searchDateEnum == SearchDateEnum.DefaultTime)
- //{
- // _bp.GetSearchDateTime(ref _bp._b_sDate, ref _bp._b_eDate, _bp.onlyEndTime);
- //}
- if (!_bp._noneDefaultTime)
- {
- hSDate.Value = _bp._b_sDate;
- hDate.Value = _bp._b_eDate;
- }
- if (_bp._keyFilterVisible || _bp._searchDateEnum != SearchDateEnum.Empty)
- searchPlace.Visible = true;
- else
- searchPlace.Visible = false;
- if (_bp._script.Length > 0)
- litScript.Text = "<script type=\"text/javascript\">" + _bp._script.ToString() + "</script>";
- }
- }
- private void initSearch(string filter)
- {
- StringBuilder str = new StringBuilder();
- switch (_bp._searchDateEnum)
- {
- case SearchDateEnum.OneDay:
- {
- str.AppendLine("日期:<input id=\"txtEdate\" class=\"mini-datepicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM-dd\" />");
- break;
- }
- case SearchDateEnum.OneMonth:
- {
- str.AppendLine("日期:<input id=\"txtEdate\" class=\"mini-monthpicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy-M\"/>");
- break;
- }
- case SearchDateEnum.OneYear:
- {
- str.AppendLine("日期:<input id=\"txtEdate\" class=\"mini-datepicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy\"/>");
- break;
- }
- case SearchDateEnum.TwoMonth:
- {
- str.AppendLine("日期:<input id=\"txtSdate\" class=\"mini-monthpicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM\" />");
- str.AppendLine("- <input id=\"txtEdate\" class=\"mini-monthpicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM\" />");
- break;
- }
- case SearchDateEnum.DefaultTime:
- {
- str.AppendLine("日期:<input id=\"txtSdate\" class=\"mini-datepicker\" style=\"width:170px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM-dd HH:mm:ss\" showTime=\"true\" time=\"HH:mm:ss\" />");
- str.AppendLine("- <input id=\"txtEdate\" class=\"mini-datepicker\" style=\"width:170px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM-dd HH:mm:ss\" showTime=\"true\" time=\"HH:mm:ss\" />");
- break;
- }
- default:
- {
- str.AppendLine("日期:<input id=\"txtSdate\" class=\"mini-datepicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM-dd\" />");
- str.AppendLine("- <input id=\"txtEdate\" class=\"mini-datepicker\" style=\"width:110px;\" onvaluechanged=\"view_search\" format=\"yyyy-MM-dd\" />");
- break;
- }
- }
- if (filter != "")
- {
- string[] sArr = filter.Split(',');
- str.AppendLine("<span id=\"sp_date_filter\">");
- for (int i = 0; i < sArr.Length; i++)
- {
- str.AppendLine(" <a href=\"###\">" + sArr[i] + "</a>");
- }
- str.AppendLine("</span>");
- }
- litSearch.Text = str.ToString();
- }
- private bool InitPermission()
- {
- //自己检测权限
- if (_bp.PmTag == "")
- {
- _bp.ShowError("您当前没有权限查看该页面");
- return false;
- }
- DataTable dt = WebUser.GetPermission(_bp.PKey);
- System.Data.DataView dv = new System.Data.DataView(dt);
- dv.RowFilter = string.Format("tag='{0}' or tag like '{0}_%'", _bp.PmTag);
- if (dv.Count < 1)
- {
- _bp.ShowError("您当前没有权限查看该页面");
- return false;
- }
- string tag;
- StringBuilder str = new StringBuilder();
- int i = 0;
- foreach (DataRowView drv in dv)
- {
- tag = drv["Tag"].ToString();
- if (tag.IndexOf("_") == -1) continue;
- tag = tag.Replace(_bp.PmTag + "_", "");
- _bp._permissions.Add(tag);//加入权限
- if (tag == "view") continue;
- if (tag == "add" && _bp._addVisible) btnAdd.Visible = true;
- //else if (!_bp._addVisible) btnAdd.Visible = false;
- str.Append((i > 0 ? "|" : "") + tag + "," + drv["Name"]);
- i++;
- }
- if (str.Length > 0)
- _bp.AppendScript("actionData=\"" + str.ToString() + "\";");
- return true;
- }
- }
|