Пример #1
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     if ((EnsureScriptManager()) && (!_scriptManager.IsClientScriptIncludeRegistered(_type, "flowplayer")))
     {
         _scriptManager.RegisterClientScriptInclude(_type, "flowplayer", _scriptManager.GetWebResourceUrl(_type, "Instinct.Resource_.FlowPlayer.flowplayer-3.1.4.min.js"));
     }
 }
        /// <summary>
        /// Registers the scripts.
        /// </summary>
        /// <param name="rules">The rules.</param>
        public void RegisterScripts(RuleCollection rules)
        {
            ClientScriptManager scriptManager = _page.ClientScript;

            string initScriptResourceUrl = scriptManager.GetWebResourceUrl(_registerType, ModelPropertyValidator.WebformValidateResourceName);

            scriptManager.RegisterClientScriptInclude(_registerType, "WebformValidate", initScriptResourceUrl);

            string validateInitScript = String.Format("$(document).ready(function(){{ $webformValidate.init('#{0}'); }});{1}", _page.Form.ClientID, Environment.NewLine);

            scriptManager.RegisterStartupScript(_registerType, "WebformValidateInit", validateInitScript, true);

            StringBuilder validationOptionsScript = new StringBuilder();

            validationOptionsScript.AppendFormat("$(document).ready(function(){{ $('#{0}').rules('add', ", _controlToValidateId);

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            serializer.RegisterConverters(new[] { new RulesJavaScriptConverter() });
            serializer.Serialize(rules, validationOptionsScript);

            validationOptionsScript.AppendLine("); });");

            scriptManager.RegisterStartupScript(
                _registerType, _controlToValidateId, validationOptionsScript.ToString(), true);
        }
Пример #3
0
        void DoRegisterScript()
        {
            ClientScriptManager sc = this.Page.Page.ClientScript;

            string scriptString = sc.GetWebResourceUrl(this.GetType(), "WebDropDownCheckBoxList.Resources.DropDownCheckBoxList.js");

            if (!sc.IsClientScriptIncludeRegistered("DropDownGridScriptKey"))
            {
                sc.RegisterClientScriptInclude(this.GetType(), "DropDownGridScriptKey", scriptString);
            }

            scriptString = Page.Form.Attributes["onclick"];
            if (string.IsNullOrEmpty(scriptString))
            {
                scriptString = string.Format("responseOnFormClick(event,'{0}');", this.ClientID);
            }
            else
            {
                scriptString = string.Format("{0} responseOnFormClick(event,'{1}');", scriptString, this.ClientID);
            }

            Page.Form.Attributes.Add("onclick", scriptString);

            this.Page.RegisterRequiresPostBack(this);
        }
Пример #4
0
        /// <summary>
        /// Обработчик события перед рендерингом страницы.
        /// </summary>
        /// <param name="e">Аргументы события.</param>
        protected override void OnPreRender(EventArgs e)
        {
            // При включенных StyleSheetThemes мета-тэг X-UA-Compatible не будет первым в "head" и может не быть обработан корректно:
            // http://connect.microsoft.com/VisualStudio/feedback/details/581278/setting-x-ua-compatible-meta-tag-in-asp-net-4-0-site-doesn-t-work-yes-it-s-at-the-top
            // http://stackoverflow.com/questions/6156639/x-ua-compatible-is-set-to-ie-edge-but-it-still-doesnt-stop-compatibility-mode
            // Другой вариант - передача HTTP-заголовка.
            var metatag = new HtmlMeta();

            metatag.Attributes.Add("http-equiv", "X-UA-Compatible");
            metatag.Attributes.Add("content", "IE=edge");
            Page.Header.Controls.AddAt(0, metatag);

            // Установка класса тэга "body" на основе текущего типа разметки.
            // Устанавливается в Code Behind для корректной работы PlaceholderPageContentConnector
            // при отсутствии плейсхолдеров "FlexberryScripts" и "FlexberryRawHtml" ("body"
            // должен быть отдельным контролом, а не входить в LiteralControl).
            // Если PlaceholderPageContentConnector не используется, то установку класса
            // можно перенести в разметку.
            body.AddCssClass(GetBodyClass());

            ClientScriptManager cs = Page.ClientScript;
            Type rsType            = this.GetType();

            var webRes = cs.GetWebResourceUrl(rsType, "SimpleControl.Help.htm");

            //HyperLink hlHelpFile = new HyperLink();
            //hlHelpFile.NavigateUrl = cs.GetWebResourceUrl(rsType, "SimpleControl.Help.htm");
            //hlHelpFile.Attributes.Add("onmouseover", "ChangeImage('image1','Red')");

            //this.Controls.Add(hlHelpFile);


            base.OnLoad(e);
        }
Пример #5
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb       = new StringBuilder();
            bool                login_fe = Security.IsAuthenticated();
            string              subAct   = Request["subAct"];
            ClientScriptManager cs       = this.Page.ClientScript;

            if (subAct != "dangky_home" && subAct != "Ho_tro_khach_hang")
            {
                sb.AppendFormat("jQuery.getScript('{0}',"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.hethong.DangNhap.JScript1.js"));
                sb.Append("function(){");
            }

            string Ma = Request["Ma"];

            if (!Security.IsAuthenticated())
            {
                switch (subAct)
                {
                case "lite":
                    #region thu nhỏ
                    if (login_fe)
                    {
                        sb.AppendFormat("DangNhap.setup('{0}');", Security.Username);
                    }
                    else
                    {
                        sb.AppendFormat("DangNhap.login_fe('{0}');", Ma);
                    }
                    break;

                    #endregion
                case "dangky_home":
                {
                    sb.Append("(" + JavaScriptConvert.SerializeObject(DanhMucDal.SelectByMa(Ma)) + ")");
                    break;
                }

                default:
                    if (login_fe && !Security.IsAuthenticated())
                    {
                        sb.AppendFormat("DangNhap.setup('{0}');", Security.Username);
                    }
                    else
                    {
                        sb.AppendFormat("DangNhap.login_fe('{0}');", Ma);
                    }
                    break;
                }
            }
            if (subAct != "dangky_home" && subAct != "Ho_tro_khach_hang")
            {
                sb.Append("});");
            }

            writer.Write(sb.ToString());
            base.Render(writer);
        }
 public override string GetLogoUrl(ClientScriptManager cs)
 {
     if (cs != null)
     {
         return(cs.GetWebResourceUrl(this.GetType(), "CommerceBuilder.Payments.Providers.InternetSecure.Logo.gif"));
     }
     return(string.Empty);
 }
Пример #7
0
 public override string GetLogoUrl(ClientScriptManager cs)
 {
     if (cs != null)
     {
         return(cs.GetWebResourceUrl(this.GetType(), "CommerceBuilder.Taxes.Providers.CCH.CertiTaxLogo.gif"));
     }
     return(string.Empty);
 }
Пример #8
0
        protected override void OnPreRender(EventArgs e)
        {
            ClientScriptManager clientScript = this.Page.ClientScript;
            string webResourceUrl            = clientScript.GetWebResourceUrl(base.GetType(), "EasyOne.Controls.ComboBox.ComboBox.js");

            clientScript.RegisterClientScriptInclude(base.GetType(), "EasyOne.Controls.ComboBox.ComboBox.js", webResourceUrl);
            base.OnPreRender(e);
        }
Пример #9
0
 public override string GetLogoUrl(ClientScriptManager cs)
 {
     if (cs != null)
     {
         return(cs.GetWebResourceUrl(this.GetType(), "CommerceBuilder.Shipping.Providers.AustraliaPost.Logo.gif"));
     }
     return(string.Empty);
 }
Пример #10
0
 public override string GetLogoUrl(ClientScriptManager cs)
 {
     if (cs != null)
     {
         return(cs.GetWebResourceUrl(this.GetType(), "CommerceBuilder.Shipping.Providers.DHLInternational.Logo.jpg"));
     }
     return(string.Empty);
 }
Пример #11
0
        private static void ExcludeJavaScript(ClientScriptManager manager, string key)
        {
            var type = typeof(RegisterResouce);
            var url  = manager.GetWebResourceUrl(type, "");

            manager.RegisterStartupScript(type, key, string.Empty);
            manager.RegisterClientScriptInclude(type, key, url);
        }
        private HtmlControl CreateCollapsableHeader(Control title, HtmlControl collapsableElement, bool expandedAsDefault)
        {
            ClientScriptManager clientScriptManager = this.Page.ClientScript;
            Type tokenVisualizerControlType         = this.GetType();

            string iconImageId = string.Format(CultureInfo.InvariantCulture, "{0}_image", collapsableElement.ID);

            string onClickJavascriptHandler = string.Format(
                CultureInfo.InvariantCulture,
                "toggleVisualizerVisibility('{0}','{1}','{2}','{3}')",
                collapsableElement.ID,
                iconImageId,
                clientScriptManager.GetWebResourceUrl(tokenVisualizerControlType, "Microsoft.Samples.DPE.Identity.Controls.Content.images.CollapseIcon.bmp"),
                clientScriptManager.GetWebResourceUrl(tokenVisualizerControlType, "Microsoft.Samples.DPE.Identity.Controls.Content.images.ExpandIcon.bmp"));

            HtmlImage iconImage = new HtmlImage()
            {
                ID = iconImageId,
            };

            if (expandedAsDefault)
            {
                iconImage.Src = clientScriptManager.GetWebResourceUrl(tokenVisualizerControlType, "Microsoft.Samples.DPE.Identity.Controls.Content.images.CollapseIcon.bmp");
                collapsableElement.Style["display"] = "block";
            }
            else
            {
                iconImage.Src = clientScriptManager.GetWebResourceUrl(tokenVisualizerControlType, "Microsoft.Samples.DPE.Identity.Controls.Content.images.ExpandIcon.bmp");
                collapsableElement.Style["display"] = "none";
            }

            iconImage.Attributes["class"] = "TokenVisualizerImage";

            HtmlGenericControl collapsableDiv = new HtmlGenericControl("div");

            collapsableDiv.Controls.Add(iconImage);
            collapsableDiv.Controls.Add(title);

            collapsableDiv.Attributes["onclick"] = onClickJavascriptHandler;
            collapsableDiv.Attributes["class"]   = "TokenVisualizerTitle";

            return(collapsableDiv);
        }
Пример #13
0
        public static void GetWebResourceUrlLoad(Page p)
        {
            ClientScriptManager cs = p.ClientScript;
            String cbReference     = cs.GetWebResourceUrl(typeof(MonoTests.System.Web.UI.ClientScriptManagerTest), "ClientScript.js");

            if (cbReference.IndexOf("/WebResource.axd?") < 0)
            {
                Assert.Fail("GetWebResourceUrlFail");
            }
        }
Пример #14
0
        protected override void Render(HtmlTextWriter writer)
        {
            ClientScriptManager cs = this.Page.ClientScript;
            Type   rsType          = this.GetType();
            string upUrl           = cs.GetWebResourceUrl(rsType, "XWT.Web.Controls.up.gif");
            string downUrl         = cs.GetWebResourceUrl(rsType, "XWT.Web.Controls.down.gif");
            string calUrl          = cs.GetWebResourceUrl(rsType, "XWT.Web.Controls.calendar.png");

            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("<input id=\"__{0}\" name=\"__{0}\" size=\"{1}\" type=\"text\" />", this.ClientID, Size);
            builder.Append("<a href=\"javascript: void(0);\"");
            builder.AppendFormat("onclick=\"g_Calendar.show('#__{0}','{3}','{4}',event,'{2}.__{0}', false, '{1}'); return false;\"", this.ClientID, DateFormat, this.Page.Form.ClientID, upUrl, downUrl);
            builder.Append("onmouseout=\"if (timeoutDelay) calendarTimeout();window.status='';\"");
            builder.Append("onmouseover=\"if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;\">");
            builder.AppendFormat("<img alt=\"\" border=\"0\" name=\"imgCalendar\" src=\"{0}\" /></a>", string.IsNullOrEmpty(ImageUrl)?calUrl:Page.ResolveClientUrl(ImageUrl));

            writer.Write(builder.ToString());
            base.Render(writer);
        }
Пример #15
0
        public override void KhoiTao(SqlConnection con)
        {
            bool login             = SecurityCangTin.IsAuthenticated();
            Page _Page             = new Page();
            ClientScriptManager cs = _Page.ClientScript;
            StringBuilder       sb = new StringBuilder();
            HttpContext         c  = HttpContext.Current;
            string _alias          = c.Request["pages"];

            sb.AppendFormat(@"
    <div class=""top"">
        <div class=""top-box"">
            <div class=""top-r"">");
            if (login)
            {
                sb.AppendFormat(@"
                <a href=""{0}"" class=""top-r-avatar avatar-50-box""><img src=""5f45c3ea-3a9d-4089-ba18-6bac8c70aec450x50.jpeg"" class=""avatar-50"" /></a>
                <a href=""javascript:;"" class=""top-r-item top-r-msg"">Tin nhắn</a><span class=""top-r-space"">|</span>
                <a href=""javascript:;"" class=""top-r-item top-r-thongBao"">Thông báo</a><a href=""{0}"" class=""top-r-item top-r-profile"">Tiểu ni</a>
            ", domain);
            }
            else
            {
                sb.AppendFormat(@"
                <a href=""javascript:;"" class=""top-r-item top-r-login"">Đăng nhập</a><a href=""javascript:;"" class=""top-r-item top-r-register"">Đăng ký</a>
            ");
            }

            sb.AppendFormat(@"                
            </div>
            <div class=""top-l"">
                <a href=""{0}"" class=""logo""></a>
                <a href=""{0}tim-ban/"" class=""top-l-item{2}"">Tìm bạn</a>
                <a href=""{0}su-kien/"" class=""top-l-item{3}"">Sự kiện</a>
                <a href=""{0}qua/"" class=""top-l-item{4}"">Quà</a>
            </div>
            <div class=""search-pnl"">
                <a href=""javascript:;"" class=""search-btn"">
                </a>
                <input class=""search-txt"" />
            </div>
        </div>
    </div>", domain
                            , _alias == "home" ? " top-l-item-active" : ""
                            , _alias == "tim-ban" ? " top-l-item-active" : ""
                            , _alias == "su-kien" ? " top-l-item-active" : ""
                            , _alias == "qua" ? " top-l-item-active" : "");
            sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                            , cs.GetWebResourceUrl(typeof(Banner), "appStore.authorityStore.content.html.Banner.js")
                            , "{bannerFn.setup();}");
            Html = sb.ToString();
            base.KhoiTao(con);
        }
Пример #16
0
        public string GetArrowResourceUrl(Menu owner)
        {
            Page page = owner.Page;
            ClientScriptManager csm = page != null ? page.ClientScript : null;

            if (csm != null)
            {
                return(csm.GetWebResourceUrl(typeof(Menu), "arrow_plus.gif"));
            }

            return(null);
        }
Пример #17
0
        private static string AddScripts(HtmlHelper htmlHelper, ClientScriptManager scriptManager, string targetElementId, string popupElementId)
        {
            var scriptsBuilder = new StringBuilder();

            if (htmlHelper.ViewData["TooltipJqueryBehaviorRegistered"] == null || !(bool)htmlHelper.ViewData["TooltipJqueryBehaviorRegistered"])
            {
                var tooltipJQueryBehaviorUrl = scriptManager.GetWebResourceUrl(typeof(TooltipExtension), "Samples.Web.UI.Controls.Mvc.Scripts.TooltipJQueryBehavior.js");
                scriptsBuilder.AppendFormat("<script type='text/javascript' src='{0}' ></script>", tooltipJQueryBehaviorUrl);
                htmlHelper.ViewData["TooltipJqueryBehaviorRegistered"] = true;
            }

            scriptsBuilder.AppendFormat(TooltipJQueryBehaviorInitialization, targetElementId, popupElementId);

            return(scriptsBuilder.ToString());
        }
Пример #18
0
        private static void IncludeJavaScript(ClientScriptManager manager, string resourceName, bool late)
        {
            var type = typeof(RegisterResouce);

            if (!manager.IsStartupScriptRegistered(type, resourceName))
            {
                if (late)
                {
                    var url         = manager.GetWebResourceUrl(type, resourceName);
                    var scriptBlock = string.Format(Base.TEMPLATE_SCRIPT, HttpUtility.HtmlEncode(url));
                    manager.RegisterStartupScript(type, resourceName, scriptBlock);
                }
                else
                {
                    manager.RegisterClientScriptResource(type, resourceName);
                    manager.RegisterStartupScript(type, resourceName, string.Empty);
                }
            }
        }
Пример #19
0
        public override void RenderBeginTag(HtmlTextWriter writer, string skipLinkText)
        {
            Menu owner = Owner;

            // <a href="#ID_SkipLink">
            writer.AddAttribute(HtmlTextWriterAttribute.Href, "#" + owner.ClientID + "_SkipLink");
            writer.RenderBeginTag(HtmlTextWriterTag.A);

            // <img alt="" height="0" width="0" src="" style="border-width:0px;"/>
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, skipLinkText);
            writer.AddAttribute(HtmlTextWriterAttribute.Height, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "0");

            Page page = owner.Page;
            ClientScriptManager csm = page != null ? page.ClientScript : new ClientScriptManager(null);

            writer.AddAttribute(HtmlTextWriterAttribute.Src, csm.GetWebResourceUrl(typeof(SiteMapPath), "transparent.gif"));
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();

            writer.RenderEndTag();              // </a>
        }
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (this.DesignMode)
            {
                return;
            }

            if (this.ProcessCertificateDownloadRequest())
            {
                return;
            }

            string divId = string.Format(CultureInfo.InvariantCulture, "{0}_div", this.ID);

            HtmlGenericControl container = new HtmlGenericControl("div")
            {
                ID = divId
            };

            ClientScriptManager clientScriptManager = this.Page.ClientScript;
            HtmlImage           controlImage        = new HtmlImage
            {
                ID  = string.Format(CultureInfo.CurrentUICulture, "STVC{0}", Guid.NewGuid()),
                Src = clientScriptManager.GetWebResourceUrl(typeof(SecurityTokenVisualizerControl), "Microsoft.Samples.DPE.Identity.Controls.Content.images.icon.png"),
                Alt = Resources.SecurityTokenVisualizer,
            };

            controlImage.Attributes["title"] = Resources.SecurityTokenVisualizer;

            HtmlControl tokenVisualizerHeader = this.CreateCollapsableHeader(controlImage, container, false /* Expanded as Default */);

            if (this.Font == null || string.IsNullOrEmpty(this.Font.Name))
            {
                container.Style["font-family"]             = "Arial, Consolas, Segoe UI";
                tokenVisualizerHeader.Style["font-family"] = "Arial, Consolas, Segoe UI";
            }
            if (this.Font == null || this.Font.Size.IsEmpty)
            {
                container.Style["font-size"]             = "small";
                tokenVisualizerHeader.Style["font-size"] = "small";
            }

            var containerRounded = this.AddContainerRounded(container);

            if (Thread.CurrentPrincipal.Identity.IsAuthenticated && Thread.CurrentPrincipal.Identity is IClaimsIdentity)
            {
                AddClaimsTable(containerRounded);
                containerRounded.Controls.Add(new HtmlGenericControl()
                {
                    InnerHtml = "&nbsp;"
                });
                this.AddSamlTokenTable(containerRounded);
            }
            else
            {
                AddNotAuthenticatedUserTable(containerRounded);
            }

            tokenVisualizerHeader.RenderControl(writer);

            container.RenderControl(writer);

            base.RenderContents(writer);
        }
Пример #21
0
		public override void RenderBeginTag (HtmlTextWriter writer)
		{
			string skipLinkText = SkipLinkText;
			
			if (!String.IsNullOrEmpty (skipLinkText)) {
				writer.AddAttribute (HtmlTextWriterAttribute.Href, "#" + ClientID + "_SkipLink");
				writer.RenderBeginTag (HtmlTextWriterTag.A);

				Image img = new Image ();
				ClientScriptManager csm = new ClientScriptManager (null);
				img.ImageUrl = csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif");
				img.Attributes.Add ("height", "0");
				img.Attributes.Add ("width", "0");
				img.AlternateText = skipLinkText;
				img.Render (writer);

				writer.RenderEndTag ();
			}
			base.RenderBeginTag (writer);
		}
Пример #22
0
        protected override void Render(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;

            #region Tham số
            string _ID     = Request["ID"];
            string _Ten    = Request["Ten"];
            string _Ma     = Request["Ma"];
            string _KyHieu = Request["KyHieu"];
            string _ThuTu  = Request["STT"];
            string _q      = Request["q"];
            #endregion
            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid
                if (string.IsNullOrEmpty(jgrsidx))
                {
                    jgrsidx = "ID";
                }
                if (string.IsNullOrEmpty(jgrsord))
                {
                    jgrsord = "asc";
                }

                var listRow = LoaiDanhMucDal.SelectAll().Select(ldm => new jgridRow(ldm.ID.ToString(), new string[]
                {
                    ldm.ID.ToString(), ldm.ThuTu.ToString(), ldm.Ma, ldm.KyHieu, ldm.Ten, string.Format("{0:dd/MM/yy}", ldm.NgayCapNhat), ldm.NguoiTao + "/" + ldm.NguoiSua
                })).ToList();
                var grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, "0", "0", listRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "getAll":
                #region lấy toàn bộ loai danh mục
                var listGetPid = LoaiDanhMucDal.SelectAll();
                listGetPid.Add(new LoaiDanhMuc()
                {
                    Ten = "Chọn"
                });
                sb.Append(JavaScriptConvert.SerializeObject(listGetPid));
                break;

                #endregion
            case "save":
                #region lưu
                var ItemSave = new LoaiDanhMuc();
                if (string.IsNullOrEmpty(_Ten))
                {
                    sb.Append("0");
                    break;
                }
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = LoaiDanhMucDal.SelectById(new Guid(_ID));
                }
                ItemSave.Ten         = _Ten;
                ItemSave.Ma          = _Ma;
                ItemSave.KyHieu      = _KyHieu;
                ItemSave.ThuTu       = Int32.Parse(_ThuTu);
                ItemSave.NgayCapNhat = DateTime.Now;
                ItemSave.NguoiTao    = Security.Username;
                ItemSave.NguoiSua    = Security.Username;
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = LoaiDanhMucDal.Update(ItemSave);
                }
                else
                {
                    ItemSave.NgayTao = DateTime.Now;
                    ItemSave.RowId   = Guid.NewGuid();
                    ItemSave.ID      = Guid.NewGuid();
                    ItemSave         = LoaiDanhMucDal.Insert(ItemSave);
                }
                sb.Append("1");
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.Append("(" + JavaScriptConvert.SerializeObject(LoaiDanhMucDal.SelectById(new Guid(_ID))) + ")");
                }
                break;

                #endregion
            case "del":
                #region xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    LoaiDanhMucDal.DeleteById(new Guid(_ID));
                }
                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.loaidanhmuc.JScript1.js"));
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "mdl.htm"));
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.loaidanhmuc.JScript1.js")
                                , "{loaidanhmuc.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #23
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            string _ID             = Request["ID"];
            string _CQ_ID          = Request["CQ_ID"];
            string _Ten            = Request["Ten"];
            string _q        = Request["q"];
            string _Loai_Ten = Request["Loai_Ten"];
            string _Loai_ID  = Request["Loai_ID"];
            var    _HomeUrl  = Request["HomeUrl"];

            switch (subAct)
            {
            case "get":
                #region Lấy danh sách
                if (string.IsNullOrEmpty(jgrsidx))
                {
                    jgrsidx = "ID";
                }
                if (string.IsNullOrEmpty(jgrsord))
                {
                    jgrsord = "asc";
                }
                RoleCollection  ListGet = RoleDal.TreeByUsername(Security.Username, _q, _CQ_ID, "ROLE_" + jgrsidx + " " + jgrsord);
                List <jgridRow> ListRow = new List <jgridRow>();
                foreach (Role item in ListGet)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString()
                                             , new string[] {
                        item.ID.ToString(),
                        item.Ten,
                        item.Loai_Ten,
                        item._CoQuan.Ten
                    }));
                }
                jgrid grid = new jgrid("1", "1", ListGet.Count.ToString(), ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "del":
                #region Xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    RoleDal.DeleteById(_ID);
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.Append("(" + JavaScriptConvert.SerializeObject(RoleDal.SelectById(Convert.ToInt32(_ID))) + ")");
                }
                break;

                #endregion
            case "save":
                #region Lưu
                var ItemSave = new Role();
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = RoleDal.SelectById(Convert.ToInt32(_ID));
                }
                ItemSave.Ten         = _Ten;
                ItemSave.HomeUrl     = _HomeUrl;
                ItemSave.CQ_ID       = Convert.ToInt32(_CQ_ID);
                ItemSave.NgayCapNhat = DateTime.Now;
                ItemSave.Active      = true;
                ItemSave.HeThong     = true;
                if (!string.IsNullOrEmpty(_Loai_ID))
                {
                    ItemSave.Loai_ID = new Guid(_Loai_ID);
                }
                ItemSave.Loai_Ten = _Loai_Ten;
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = RoleDal.Update(ItemSave);
                }
                else
                {
                    ItemSave.NgayTao  = DateTime.Now;
                    ItemSave.NguoiTao = Security.Username;
                    ItemSave.RowId    = Guid.NewGuid();
                    ItemSave          = RoleDal.Insert(ItemSave);
                }
                sb.Append("1");
                break;

                #endregion
            case "getFunction":
                #region Lấy function theo role
                if (!string.IsNullOrEmpty(_ID))
                {
                    FunctionCollection ListFnByRole = FunctionDal.SelectAllFunctionByRole(_ID);
                    if (ListFnByRole.Count > 0)
                    {
                        sb.Append(getTop(ListFnByRole));
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                break;

                #endregion
            case "updateFunction":
                #region Cập nhật thay đổi
                RoleFunctionDal.UpdateByRoleIdFunctionList(_ID, Request["UpdateList"], Security.Username);
                sb.Append("1");
                break;

                #endregion
            case "getUserByRole":
                #region Lấy thành viên trong nhóm
                if (!string.IsNullOrEmpty(_ID))
                {
                    MemberCollection ListUserByRole = MemberDal.SelectByRole(_ID);
                    if (ListUserByRole.Count > 0)
                    {
                        foreach (Member item in ListUserByRole)
                        {
                            sb.AppendFormat(@"<input type=""checkbox"" _username=""{0}"" {2} > <b>{0}</b> [ {1} ] <br/>"
                                            , item.Username, item.Ten, item.Khoa ? @"checked=""checked""" : "");
                        }
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                break;

                #endregion
            case "updateUsers":
                #region Lưu thay đổi thành viên trong nhóm
                if (!string.IsNullOrEmpty(_ID))
                {
                    MemberRoleDal.UpdateUserListRole(Request["UpdateList"], _ID, Security.Username);
                    sb.AppendFormat("1");
                }
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(@"<div class=""mdl-head"">
<span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-quanLyQuyen"" />
</span>
<a class=""mdl-head-btn mdl-head-add"" id=""quanLyQuyenMdl-addBtn"" href=""javascript:quanLyQuyen.add();"">Thêm</a>
<a class=""mdl-head-btn mdl-head-edit"" id=""quanLyQuyenMdl-editBtn"" href=""javascript:quanLyQuyen.edit();"">Sửa</a>
<a class=""mdl-head-btn mdl-head-del"" id=""quanLyQuyenMdl-delBtn"" href=""javascript:quanLyQuyen.del();"">Xóa</a>
<span class=""mdl-head-filterPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" _value="""" class=""mdl-head-filter mdl-head-filterQuanLyQuyenByCQID""/>
</span>
</div>
<table id=""quanLyQuyenMdl-List"" class=""mdl-list"">
</table>
<div id=""quanLyQuyenMdl-Pager""></div>

<div class=""sub-mdl quanLyQuyenMdl-subMdl"">
    <ul>
        <li>
            <a id=""quanLyQuyenMdl-functionmdl-subMdlBtn"" href=""#quanLyQuyenMdl-subMdl-mdl1"">Quyền</a>
        </li>
        <li>
            <a id=""quanLyQuyenMdl-usermdl-subMdlBtn"" href=""#quanLyQuyenMdl-subMdl-mdl2"">Người dùng thuộc nhóm</a>
        </li>
    </ul>
    <div id=""quanLyQuyenMdl-subMdl-mdl1"">
        <div id=""quanLyQuyenMdl-functionmdl-roleFnMdl"">
        </div>
    </div>
    <div id=""quanLyQuyenMdl-subMdl-mdl2"">
        <div id=""quanLyQuyenMdl-functionmdl-UserInRoleMdl"">
        </div>
    </div>
</div>

");
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.quanLyQuyen.JScript1.js")
                                , "{quanLyQuyen.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #24
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb       = new StringBuilder();
            bool                login    = Security.IsAuthenticated();
            ClientScriptManager cs       = this.Page.ClientScript;
            string              username = Security.Username;
            string              subAct   = Request["subAct"];
            string              pwd1     = Request["pwd1"];
            string              pwd2     = Request["pwd2"];

            if (!login)
            {
                renderText("un-authorized", "text/plain");
            }
            switch (subAct)
            {
            case "changePass":
                #region thu nhỏ
                if (!string.IsNullOrEmpty(pwd1))
                {
                    Member Item = new Member();
                    Item          = MemberDal.SelectByUsername(username);
                    Item.Username = username;
                    if (maHoa.DecryptString(Item.Password, username) == pwd1)
                    {
                        pwd2 = maHoa.EncryptString(pwd2, username);
                        MemberDal.changePassword(username, pwd2);
                        sb.Append("1");
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                else
                {
                    sb.Append("0");
                }
                break;

                #endregion
            default:
                sb.Append(@"
<div id=""userInfoDlg"">
<table width=""100%"">
    <tr>
        <td style=""width:160px; text-align:right;"" valign=""top"">
        Mật khẩu cũ:
        </td>
        <td valign=""top"">
        <input class=""admtxt oldPwd"" type=""password"" />
        </td>
    </tr>
    <tr>
        <td style=""width:160px; text-align:right;"" valign=""top"">
        Mật khẩu mới:
        </td>
        <td valign=""top"">
        <input class=""admtxt newPwd"" type=""password"" />
        </td>
    </tr>
    <tr>
        <td colspan=""2"">   
            <a class=""mdl-head-btn mdl-head-add"" id=""userInfoMdl-saveBtn"" onclick=""userInfoFn.save();"" href=""javascript:;"">Lưu</a>     
        </td>        
    </tr>
</table>
</div>
                    ");
                sb.AppendFormat("<script>$.getScript('{0}',"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.UserInfo.JScript1.js"));
                sb.Append("function(){");
                sb.Append(@"adm.styleButton('.mdl-head-btn');");
                sb.Append("});</script>");
                break;
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #25
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            string _ID             = Request["ID"];
            string _PID            = Request["PID"];
            string _Ten            = Request["Ten"];
            string _Mota           = Request["Mota"];
            string _Ma             = Request["Ma"];
            string _Url            = Request["Url"];
            string _GiaTriMacDinh  = Request["GiaTriMacDinh"];
            string _Loai           = Request["Loai"];
            string _ThuTu          = Request["ThuTu"];
            string _Publish        = Request["Publish"];
            string _Anh            = Request["Anh"];
            string _Desk           = Request["Desk"];
            string _DeskMacDinh    = Request["DeskMacDinh"];

            switch (subAct)
            {
            case "get":
                #region lấy danh sách
                List <Function> ListGet = getTree(FunctionDal.SelectTree(Request["q"]));
                List <jgridRow> ListRow = new List <jgridRow>();
                foreach (Function item in ListGet)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                        item.ID.ToString()
                        , item.Ten
                        , item.Loai != 3 ? string.Format("<img class=\"adm-fn-icon\" src=\"../up/i/{0}\" />", string.IsNullOrEmpty(item.Anh) ? "fn-icon.jpg" :item.Anh) : ""
                        , item.Ma
                        , item.Url
                        , item.ThuTu.ToString()
                        , item.Loai.ToString()
                        , item.Publish.ToString()
                        , item.GiaTriMacDinh.ToString()
                        , item.Level.ToString(), item.PID.ToString(), "true", "false"
                    }));
                }
                jgrid grid = new jgrid("1", "1", ListGet.Count.ToString(), ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "getPid":
                #region danh sách chọn sẵn
                FunctionCollection ListGetPid = FunctionDal.SelectTree(Request["q"]);
                sb.Append(JavaScriptConvert.SerializeObject(ListGetPid));
                break;

                #endregion
            case "del":
                #region Xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    FunctionDal.DeleteById(Convert.ToInt32(_ID));
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(FunctionDal.SelectById(Convert.ToInt32(_ID))));
                }
                break;

                #endregion
            case "save":
                #region lưu dữ liệu
                Function ItemSave = new Function();
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = FunctionDal.SelectById(Convert.ToInt32(_ID));
                }
                ItemSave.NgayCapNhat = DateTime.Now;
                ItemSave.Ten         = _Ten;
                ItemSave.MoTa        = _Mota;
                ItemSave.Loai        = Convert.ToInt16(_Loai);
                ItemSave.Ma          = _Ma;
                ItemSave.Anh         = string.Empty;
                int ThuTu = 0;
                if (!string.IsNullOrEmpty(_ThuTu))
                {
                    ThuTu = Convert.ToInt32(_ThuTu);
                }
                ItemSave.Publish       = Convert.ToBoolean(_Publish);
                ItemSave.PID           = string.IsNullOrEmpty(_PID) ? 0 : Convert.ToInt32(_PID);
                ItemSave.ThuTu         = ThuTu;
                ItemSave.Url           = _Url;
                ItemSave.NguoiTao      = Security.Username;
                ItemSave.GiaTriMacDinh = Convert.ToBoolean(_GiaTriMacDinh);
                ItemSave.Anh           = _Anh;
                ItemSave.Desk          = Convert.ToBoolean(_Desk);
                ItemSave.DeskMacDinh   = Convert.ToBoolean(_DeskMacDinh);
                if (ItemSave.Desk)
                {
                    try
                    {
                        //ItemSave.Doc = ;
                        XmlDocument doc  = new XmlDocument();
                        XmlNode     node = doc.ImportNode(PlugHelper.RenderXml(ItemSave.Url), true);
                        doc.AppendChild(node);
                        string _DocValue = linh.common.Lib.GetXmlString(doc);
                        ItemSave.Doc = _DocValue;
                    }
                    catch (Exception ex)
                    {
                        ItemSave.Doc  = string.Empty;
                        ItemSave.Desk = false;
                        sb.Append("Loi + " + ex.Message);
                    }
                }
                else
                {
                    ItemSave.Doc = string.Empty;
                }
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = FunctionDal.Update(ItemSave);
                }
                else
                {
                    ItemSave.NgayTao = DateTime.Now;
                    ItemSave.Level   = 0;
                    ItemSave.PIDList = string.Empty;
                    ItemSave.RowId   = Guid.NewGuid();
                    ItemSave         = FunctionDal.Insert(ItemSave);
                }
                sb.Append("1");
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                //<input type=""text"" class=""mdl-head-txt mdl-head-search"" />
                sb.Append(@"<div class=""mdl-head"">
<span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-functions"" />
</span>
<a class=""mdl-head-btn mdl-head-add"" id=""functionsmdl-addBtn"" href=""javascript:functions.add();"">Thêm</a>
<a class=""mdl-head-btn mdl-head-edit"" id=""functionsmdl-editBtn"" href=""javascript:functions.edit();"">Sửa</a>
<a class=""mdl-head-btn mdl-head-del"" id=""functionsmdl-delBtn"" href=""javascript:functions.del();"">Xóa</a>
</div>
<table id=""functionsmdl-List"" class=""mdl-list"">
</table>
<div id=""functionsmdl-Pager""></div>");
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.functions.JScript1.js")
                                , "{functions.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #26
0
        /// <summary>
        /// Adds the jQuery, jCrop, webcropimage.js and jCrop CSS references as specified in the matching properties.
        /// </summary>
        protected void AddFileReferences()
        {
            ClientScriptManager cs = Page.ClientScript;

            string jQueryVer = "1.8.2";
            string ext       = (DebugMode ? ".min.js" : ".js");

            if (string.IsNullOrEmpty(this.ScriptPath))
            {
                this.ScriptPath = "~/scripts/";
            }


            string jQueryGoogle   = "<script src=\"//ajax.googleapis.com/ajax/libs/jquery/" + jQueryVer + "/jquery" + ext + "\" type=\"text/javascript\"></script>\n";
            string jQueryFolder   = "<script src=\"" + ResolveClientUrl(this.ScriptPath.TrimEnd('/') + "/jquery-" + jQueryVer + ext) + "\" type=\"text/javascript\"></script>\n";
            string jQueryResource = "<script src=\"" + cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.jquery-" + jQueryVer + ext) + "\" type=\"text/javascript\"></script>\n";

            string jQueryFallbackResource = "\n<script>!window.jQuery && document.write(unescape('%3Cscript src=\"" +
                                            cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.jquery-" + jQueryVer + ext) +
                                            "\"%3E%3C/script%3E'))</script>\n";

            string jCropFolder   = "<script src=\"" + ResolveClientUrl(this.ScriptPath.TrimEnd('/') + "/jquery.Jcrop" + ext) + "\" type=\"text/javascript\"></script>\n";
            string jCropResource = "<script src=\"" + cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.jquery.Jcrop" + ext) + "\" type=\"text/javascript\"></script>\n";

            string jCropFallbackResource = "\n<script>!$.Jcrop && document.write(unescape('%3Cscript src=\"" +
                                           cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.jquery.Jcrop" + ext) +
                                           "\"%3E%3C/script%3E'))</script>\n";

            string webCropFolder   = "<script src=\"" + ResolveClientUrl(this.ScriptPath.TrimEnd('/') + "/webcropimage.js") + "\" type=\"text/javascript\"></script>\n";
            string webCropResource = "<script src=\"" + cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.webcropimage.js") + "\" type=\"text/javascript\"></script>\n";

            string webCropFallbackResource = "\n<script>!window.webcropimage && document.write(unescape('%3Cscript src=\"" +
                                             cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.webcropimage.js") +
                                             "\"%3E%3C/script%3E'))</script>\n";

            string jCropCssResource = cs.GetWebResourceUrl(this.GetType(), "Imazen.Crop.jquery.Jcrop.css");
            string jCropCssFolder   = ResolveClientUrl(this.ScriptPath.TrimEnd('/') + "/jquery.Jcrop.css");

            string jQueryBlock = null;

            if (JQueryInclude == JQueryIncludeMode.Embedded)
            {
                jQueryBlock = jQueryResource;
            }
            if (JQueryInclude == JQueryIncludeMode.Google)
            {
                jQueryBlock = jQueryGoogle + jQueryFallbackResource;
            }
            if (JQueryInclude == JQueryIncludeMode.ScriptFolder)
            {
                jQueryBlock = jQueryFolder + jQueryFallbackResource;
            }

            string jCropBlock = null;

            if (JCropInclude == JCropIncludeMode.Embedded)
            {
                jCropBlock = jCropResource;
            }
            else if (JCropInclude == JCropIncludeMode.ScriptFolder)
            {
                jCropBlock = jCropFolder + jCropFallbackResource;
            }

            string webBlock = null;

            if (this.WebCropInclude == WebCropImageIncludeMode.Embedded)
            {
                webBlock = webCropResource;
            }
            else if (this.webCropInclude == WebCropImageIncludeMode.ScriptFolder)
            {
                webBlock = webCropFolder + webCropFallbackResource;
            }

            string jCropCss = null;

            if (JCropCssInclude == JCropCssIncludeMode.Embedded)
            {
                jCropCss = jCropCssResource;
            }
            else if (JCropCssInclude == JCropCssIncludeMode.ScriptFolder)
            {
                jCropCss = jCropCssFolder;
            }


            if (this.IsInUpdatePanel)
            {
                if (jQueryBlock != null && !cs.IsClientScriptBlockRegistered("jquery"))
                {
                    cs.RegisterClientScriptBlock(this.GetType(), "jquery", jQueryBlock, false);
                }

                if (jCropBlock != null && !cs.IsClientScriptBlockRegistered("cropJS"))
                {
                    cs.RegisterClientScriptBlock(this.GetType(), "cropJS", jCropBlock);
                }

                if (webBlock != null && !cs.IsClientScriptBlockRegistered("webcropimage"))
                {
                    cs.RegisterClientScriptBlock(this.GetType(), "webcropimage", webBlock);
                }
            }
            else
            {
                if (jQueryBlock != null && !cs.IsClientScriptBlockRegistered("jquery"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "jquery", jQueryBlock, false);
                }

                if (jCropBlock != null && !cs.IsClientScriptBlockRegistered("cropJS"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "cropJS", jCropBlock, false);
                }

                if (webBlock != null && !cs.IsClientScriptBlockRegistered("webcropimage"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "webcropimage", webBlock, false);
                }
            }


            if (jCropCss != null)
            {
                Page.Header.Controls.Add(new LiteralControl("<link href=\"" + jCropCss + "\" type=\"text/css\" rel=\"stylesheet\" />\r\n"));
            }
        }
Пример #27
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;

            #region Tham số
            string   _ID     = Request["ID"];
            string   _Ten    = Request["Ten"];
            string   _Ma     = Request["Ma"];
            string   _KyHieu = Request["KyHieu"];
            string   _ThuTu  = Request["ThuTu"];
            string   _q      = Request["q"];
            string   _Active = Request["Active"];
            Language Item;
            #endregion
            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid
                if (string.IsNullOrEmpty(jgrsidx))
                {
                    jgrsidx = "ID";
                }
                if (string.IsNullOrEmpty(jgrsord))
                {
                    jgrsord = "asc";
                }

                Pager <Language> PagerGet = LanguageDal.pagerNormal("", false, "L_" + jgrsidx + " " + jgrsord, Request["rows"]);
                List <jgridRow>  ListRow  = new List <jgridRow>();
                foreach (Language item in PagerGet.List)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(),
                                             new string[] { item.ID.ToString()
                                                            , item.Ma
                                                            , item.Ten
                                                            , item.ThuTu.ToString()
                                                            , item.Active.ToString() }));
                }
                jgrid grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PagerGet.TotalPages.ToString(), PagerGet.Total.ToString(), ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "save":
                #region lưu
                if (!string.IsNullOrEmpty(_ID))
                {
                    Item = LanguageDal.SelectById(Convert.ToInt32(_ID));
                }
                else
                {
                    Item = new Language();
                }
                Item.Ten    = _Ten;
                Item.Ma     = _Ma;
                Item.ThuTu  = Int32.Parse(_ThuTu);
                Item.Active = Convert.ToBoolean(_Active);
                if (!string.IsNullOrEmpty(_ID))
                {
                    Item = LanguageDal.Update(Item);
                }
                else
                {
                    Item = LanguageDal.Insert(Item);
                }
                sb.Append("1");
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.Append("(" + JavaScriptConvert.SerializeObject(LanguageDal.SelectById(Convert.ToInt32(_ID))) + ")");
                }
                break;

                #endregion
            case "getActive":
                #region chỉnh sửa
                sb.Append(JavaScriptConvert.SerializeObject(LanguageDal.SelectAll()));
                break;

                #endregion
            case "del":
                #region xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    LanguageDal.DeleteById(Convert.ToInt32(_ID));
                }
                break;

                #endregion
            case "AutoComplete":
                #region xóa
                JavaScriptConvert.SerializeObject(LanguageDal.SelectAll());
                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.language.JScript1.js"));
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(@"<div class=""mdl-head"">
<span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-languageFn"" />
</span>
<a _resource=""admin.system.label.add"" class=""mdl-head-btn mdl-head-add"" id=""languageMdl-addBtn"" href=""javascript:languageFn.add();"">Thêm</a>
<a _resource=""admin.system.label.edit"" class=""mdl-head-btn mdl-head-edit"" id=""languageMdl-editBtn"" href=""javascript:languageFn.edit();"">Sửa</a>
<a  _resource=""admin.system.label.del"" class=""mdl-head-btn mdl-head-del"" id=""languageMdl-delBtn"" href=""javascript:languageFn.del();"">Xóa</a>
</div>

<table id=""languageMdl-List"" class=""mdl-list""></table>
<div id=""languageMdl-Pager""></div>
");
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.language.JScript1.js")
                                , "{languageFn.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #28
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;

            #region Tham số
            string _ID          = Request["ID"];
            string _CQ_ID       = Request["CQ_ID"];
            string _Username    = Request["Username"];
            string _Password    = Request["Password"];
            string _Pwd         = Request["Pwd"];
            string _Ten         = Request["Ten"];
            string _Khoa        = Request["Khoa"];
            string _Luong       = Request["Luong"];
            string _q           = Request["q"];
            string _Anh         = Request["Anh"];
            string _Loai        = Request["Loai"];
            string _ThuKy       = Request["ThuKy"];
            string _refUsername = Request["refUsername"];
            string _Email       = Request["Email"];
            string _Captcha     = Request["Captcha"];
            string _Mobile      = Request["Mobile"];
            string _DiaChi      = Request["DiaChi"];
            string _MoTa        = Request["MoTa"];
            string _Loai_Ten    = Request["Loai_Ten"];
            string _CQ_Ma       = Request["CQ_Ma"];
            string TVDV_ID      = Request["TVDV_ID"];
            string _Lang        = Request["Lang"];
            #endregion
            //if (!Security.IsAuthenticated())
            //{
            //    Response.End();
            //}
            switch (subAct)
            {
            case "get":
                #region lấy danh sách
                if (string.IsNullOrEmpty(jgrsidx))
                {
                    jgrsidx = "ID";
                }
                if (string.IsNullOrEmpty(jgrsord))
                {
                    jgrsord = "asc";
                }
                Pager <Member>  PagerGet = MemberDal.pagerAllChildByUsername("", false, "MEM_" + jgrsidx + " " + jgrsord, Security.Username, _CQ_ID, _q, Request["rows"]);
                List <jgridRow> ListRow  = new List <jgridRow>();
                foreach (Member item in PagerGet.List)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                        item.ID.ToString()
                        , item.Ten
                        , item._CoQuan.Ten
                        , item.Loai_Ten
                        , item.Email
                        , item.Mobile
                        , item.Username
                        , item.Password.Length > 2 ? item.Password.Substring(0, item.Password.Length - 2) : ""
                        , item.Active.ToString()
                        , item.NguoiTao
                    }));
                }
                jgrid grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PagerGet.TotalPages.ToString(), PagerGet.Total.ToString(), ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "getpid":
                #region lấy danh sách cho autocomplete
                Pager <Member> PagerGetPid = MemberDal.pagerAllChildByUsername("", true, null, string.IsNullOrEmpty(Security.Username) ? "sspa" : Security.Username, null, _q, "20");
                sb.Append(JavaScriptConvert.SerializeObject(PagerGetPid.List));
                break;

                #endregion
            case "GetLamDichVuList":
                #region lấy danh sách cho autocomplete
                var listLamDichVu = MemberDal.SelectLamDichVu(TVDV_ID, "sspa");
                sb.Append(JavaScriptConvert.SerializeObject(listLamDichVu));
                break;

                #endregion
            case "getpuse":
                #region lấy danh sách cho autocomplete
                Pager <Member> PagerGetPues = MemberDal.pagerAllByUsername("", true, null, Security.Username, null, _q, "20");
                sb.Append(JavaScriptConvert.SerializeObject(PagerGetPues.List));
                break;

                #endregion
            case "SelectByNodeAndWfId":
                #region lấy danh sách cho autocomplete
                string Username = Security.Username;
                //if (Request["WF_ID"] == "4" && string.IsNullOrEmpty(Request["NODE_ID"]))
                //{
                //    sb.Append(JavaScriptConvert.SerializeObject(MemberDal.SelectLanhDaoByCQMa("1")));
                //}
                //else
                //{
                //    if (!string.IsNullOrEmpty(_CQ_ID))
                //    {
                //        MemberCollection mem = MemberDal.SelectLanhDaoByCQMa(_CQ_ID);
                //        foreach (Member m in mem)
                //        {
                //            Username = m.Username;
                //            break;
                //        }
                //    }
                sb.Append(JavaScriptConvert.SerializeObject(MemberDal.SelectByNodeAndWfId(Request["NODE_ID"], Request["WF_ID"], _q, "20", Username)));
                //}
                break;

                #endregion
            case "del":
                #region xóa
                MemberDal.DeleteByIdList(Request["ID"]);
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.Append("(" + JavaScriptConvert.SerializeObject(MemberDal.SelectById(Convert.ToInt32(_ID))) + ")");
                }
                break;

                #endregion
            case "editX":
                #region editX
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.Append(MemberDal.SelectById(Convert.ToInt32(_ID)).Loai.ToString());
                }
                break;

                #endregion
            case "save":
                #region lưu
                Member ItemSave = new Member();
                if (string.IsNullOrEmpty(_Username))
                {
                    sb.Append("0");
                    break;
                }
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = MemberDal.SelectById(Convert.ToInt32(_ID));
                }
                else
                {
                    if (MemberDal.ValidEmailUsername(_Email, _Username) != "-1" ||
                        MemberDal.ValidEmailUsername(_Email, _Username) != (string.IsNullOrEmpty(_ID) ? "-1" : _ID))
                    {
                        sb.Append("0");
                        break;
                    }
                }
                ItemSave.Luong       = Convert.ToDouble(_Luong);
                ItemSave.Anh         = _Anh;
                ItemSave.CQ_ID       = Convert.ToInt32(_CQ_ID);
                ItemSave.DiaChi      = string.Empty;
                ItemSave.Email       = _Email;
                ItemSave.Ho          = string.Empty;
                ItemSave.Khoa        = Convert.ToBoolean(_Khoa);
                ItemSave.Loai        = Convert.ToInt32("0");
                ItemSave.Mobile      = _Mobile;
                ItemSave.Mota        = string.Empty;
                ItemSave.NgayCapNhat = DateTime.Now;
                ItemSave.NguoiTao    = Security.Username;
                ItemSave.RefUsername = _refUsername;
                ItemSave.Ten         = _Ten;
                ItemSave.Loai_Ten    = _Loai_Ten;
                ItemSave.ThuKy       = Convert.ToBoolean(_ThuKy);
                ItemSave.XacNhan     = false;
                if (!string.IsNullOrEmpty(_ID))
                {
                    if (!string.IsNullOrEmpty(_Password))
                    {
                        //ItemSave.Password = maHoa.EncryptString(_Password, _Username);
                        ItemSave.Password = maHoa.MD5Encrypt(_Password);
                    }
                    ItemSave = MemberDal.Update(ItemSave);
                }
                else
                {
                    ItemSave.NgayTao = DateTime.Now;
                    //ItemSave.Password = maHoa.EncryptString(_Password, _Username);
                    ItemSave.Password = maHoa.MD5Encrypt(_Password);
                    ItemSave.RowId    = Guid.NewGuid();
                    ItemSave.Username = _Username;
                    ItemSave          = MemberDal.Insert(ItemSave);
                }
                sb.Append("1");
                break;

                #endregion
            case "sendmail":
                #region gửi email
                if (!string.IsNullOrEmpty(_Email))
                {
                    string[]          _email = _Email.Split(new char[] { ',' });
                    sendEmailDelegate _send  = new sendEmailDelegate(sendMail);
                    //_send.BeginInvoke(_email, _Ten, _MoTa, null, null);
                    sb.Append("1");
                }
                else
                {
                    sb.Append("0");
                }
                break;

                #endregion
            case "getRoles":
                #region lấy quyền của thành viên
                if (!string.IsNullOrEmpty(_Username))
                {
                    sb.AppendFormat(getRoleByUsername(_Username));
                }
                break;

                #endregion
            case "saveRoles":
                #region lưu quyền
                if (!string.IsNullOrEmpty(_Username))
                {
                    string roleList = Request["roleList"];
                    if (!string.IsNullOrEmpty(roleList))
                    {
                        MemberRoleDal.UpdateRoleListUsername(roleList, _Username);
                    }
                }
                break;

                #endregion
            case "SelectLanhDaoByCQID":
                #region lấy lãnh đạo theo cơ quan
                if (!string.IsNullOrEmpty(_CQ_ID))
                {
                    MemberCollection PG = MemberDal.SelectLanhDaoByCQID(_CQ_ID);
                    sb.Append(JavaScriptConvert.SerializeObject(PG));
                }
                break;

                #endregion
            case "SelectLanhDaoVanBanDi":
                #region lấy lãnh đạo theo cơ quan
                MemberCollection _SelectLanhDaoVanBanDi = MemberDal.SelectLanhDaoVanBanDi();
                sb.Append(JavaScriptConvert.SerializeObject(_SelectLanhDaoVanBanDi));
                break;

                #endregion
            case "SelectLanhDaoByMaCQ":
                #region tim lanh dao theo ma co quan
                MemberCollection _SelectLanhDaoByMaCoQuan = MemberDal.SelectLanhDaoByCQMa(_CQ_Ma);
                sb.Append(JavaScriptConvert.SerializeObject(_SelectLanhDaoByMaCoQuan));
                break;

                #endregion
            case "ValidateEmail":
                #region tim lanh dao theo ma co quan
                if (!string.IsNullOrEmpty(_Email))
                {
                    if (MemberDal.ValidEmail(_Email))
                    {
                        sb.Append("1");
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                break;

                #endregion
            case "ValidateCaptcha":
                #region tim lanh dao theo ma co quan
                if (!string.IsNullOrEmpty(_Captcha))
                {
                    if (Session["capcha"] != null)
                    {
                        if (Session["capcha"].ToString() == _Captcha)
                        {
                            sb.Append("1");
                        }
                        else
                        {
                            sb.Append("0");
                        }
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                else
                {
                    sb.Append("0");
                }
                break;

                #endregion
            case "cungDonVi":
                #region cungDonVi : Lấy thành viên cùng đơn vị
                sb.Append(JavaScriptConvert.SerializeObject(MemberDal.SelectCungDonVi(Security.Username)));
                break;
                #endregion

            case "dangKyCaNhan":
                #region dangKyCaNhan
                using (SqlConnection con = DAL.con())
                {
                    con.Open();
                    SqlTransaction tran = con.BeginTransaction();
                    try
                    {
                        CoQuan ItemCq = CoQuanDal.SelectByMa(tran, "RAOVAT");
                        //Member ItemMe = MemberDal.Insert(tran, ItemCq.ID, _Ten, _Email, _Mobile, _DiaChi, maHoa.EncryptString(_Pwd, _Email));
                        Member     ItemMe = MemberDal.Insert(tran, ItemCq.ID, _Ten, _Email, _Mobile, _DiaChi, maHoa.MD5Encrypt(_Password));
                        MemberRole ItemMR = MemberRoleDal.InsertDangKyCaNhan(tran, ItemCq.ID, _Email);
                        Security.Login(_Email, "true");
                        sb.Append("1");
                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        Security.LogOut();
                        sb.Append(ex.ToString());
                    }
                    finally
                    {
                        con.Close();
                    }
                }

                break;

                #endregion
            case "dangKyGh":
                #region dangKyGh
                using (SqlConnection con = DAL.con())
                {
                    con.Open();
                    SqlTransaction tran = con.BeginTransaction();
                    try
                    {
                        CoQuan ItemCqP = CoQuanDal.SelectByMa(tran, "GIANHANG");
                        CoQuan ItemCq  = CoQuanDal.Insert(tran, ItemCqP.ID, _Ten, _Email);
                        //Member ItemMe = MemberDal.Insert(tran, ItemCq.ID, _Ten, _Email, _Mobile, _DiaChi, maHoa.EncryptString(_Pwd, _Email));
                        Member ItemMe = MemberDal.Insert(tran, ItemCq.ID, _Ten, _Email, _Mobile, _DiaChi, maHoa.MD5Encrypt(_Pwd));
                        MemberRoleDal.InsertDangKyGianHang(tran, ItemCq.ID, _Email, _Ten, _Lang);
                        //LienHe itemLH = LienHeDal.InsertLH(tran, ItemMe.RowId.ToString());
                        Security.Login(_Email, "true");
                        sb.Append("1");
                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        Security.LogOut();
                        sb.Append(ex.ToString());
                    }
                    finally
                    {
                        con.Close();
                    }
                }

                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.thanhvien.JScript1.js"));
                break;

                #endregion
            default:    //Session["capcha"]
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(@"<div class=""mdl-head"">
<span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-thanhvien"" />
</span>
<a class=""mdl-head-btn mdl-head-add"" id=""thanhvienmdl-addBtn"" href=""javascript:thanhvien.add();"">Thêm</a>
<a class=""mdl-head-btn mdl-head-edit"" id=""thanhvienmdl-editBtn"" href=""javascript:thanhvien.edit();"">Sửa</a>
<a class=""mdl-head-btn mdl-head-del"" id=""thanhvienmdl-delBtn"" href=""javascript:thanhvien.del();"">Xóa</a>
<a class=""mdl-head-btn mdl-head-sendmail"" id=""thanhvienmdl-emailBtn"" href=""javascript:thanhvien.sendmail();"">Email</a>
<a class=""mdl-head-btn mdl-head-resetPwd"" id=""thanhvienmdl-reSendPwdBtn"" href=""javascript:thanhvien.resendPwd();"">Cấp mật khẩu</a>
<span class=""mdl-head-filterPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" _value="""" class=""mdl-head-filter mdl-head-filterThanhVienByCQID""/>
</span>
</div>
<table id=""thanhvienmdl-List"" class=""mdl-list"">
</table>
<div id=""thanhvienmdl-Pager""></div><div class=""sub-mdl""><ul><li><a id=""thanhvienmdl-rolemdl-subMdlBtn"" href=""#mdl-1"">Quyền</a></li></ul><div id=""mdl-1"">
<div class=""sub-mdl-list"" id=""thanhvienmdl-rolemdl-mdl""></div>
</div></div>");
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.thanhvien.JScript1.js")
                                , "{thanhvien.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #29
0
        public override void PreRender(Page page, HtmlHead head, ClientScriptManager csm, string cmenu, StringBuilder script)
        {
            Menu                    owner = Owner;
            MenuItemStyle           staticMenuItemStyle     = owner.StaticMenuItemStyleInternal;
            SubMenuStyle            staticMenuStyle         = owner.StaticMenuStyleInternal;
            MenuItemStyle           dynamicMenuItemStyle    = owner.DynamicMenuItemStyleInternal;
            SubMenuStyle            dynamicMenuStyle        = owner.DynamicMenuStyleInternal;
            MenuItemStyleCollection levelMenuItemStyles     = owner.LevelMenuItemStyles;
            List <Style>            levelMenuItemLinkStyles = owner.LevelMenuItemLinkStyles;
            SubMenuStyleCollection  levelSubMenuStyles      = owner.LevelSubMenuStylesInternal;
            MenuItemStyle           staticSelectedStyle     = owner.StaticSelectedStyleInternal;
            MenuItemStyle           dynamicSelectedStyle    = owner.DynamicSelectedStyleInternal;
            MenuItemStyleCollection levelSelectedStyles     = owner.LevelSelectedStylesInternal;
            List <Style>            levelSelectedLinkStyles = owner.LevelSelectedLinkStyles;
            Style                   staticHoverStyle        = owner.StaticHoverStyleInternal;
            Style                   dynamicHoverStyle       = owner.DynamicHoverStyleInternal;

            if (!csm.IsClientScriptIncludeRegistered(typeof(Menu), "Menu.js"))
            {
                string url = csm.GetWebResourceUrl(typeof(Menu), "Menu.js");
                csm.RegisterClientScriptInclude(typeof(Menu), "Menu.js", url);
            }

            script.AppendFormat(onPreRenderScript,
                                cmenu,
                                page.IsMultiForm ? page.theForm : "window",
                                ClientScriptManager.GetScriptLiteral(owner.DisappearAfter),
                                ClientScriptManager.GetScriptLiteral(owner.Orientation == Orientation.Vertical));

            if (owner.DynamicHorizontalOffset != 0)
            {
                script.Append(String.Concat(cmenu, ".dho = ", ClientScriptManager.GetScriptLiteral(owner.DynamicHorizontalOffset), ";\n"));
            }
            if (owner.DynamicVerticalOffset != 0)
            {
                script.Append(String.Concat(cmenu, ".dvo = ", ClientScriptManager.GetScriptLiteral(owner.DynamicVerticalOffset), ";\n"));
            }

            // The order in which styles are defined matters when more than one class
            // is assigned to an element
            RegisterStyle(owner.PopOutBoxStyle, head);
            RegisterStyle(owner.ControlStyle, owner.ControlLinkStyle, head);

            if (staticMenuItemStyle != null)
            {
                RegisterStyle(owner.StaticMenuItemStyle, owner.StaticMenuItemLinkStyle, head);
            }

            if (staticMenuStyle != null)
            {
                RegisterStyle(owner.StaticMenuStyle, head);
            }

            if (dynamicMenuItemStyle != null)
            {
                RegisterStyle(owner.DynamicMenuItemStyle, owner.DynamicMenuItemLinkStyle, head);
            }

            if (dynamicMenuStyle != null)
            {
                RegisterStyle(owner.DynamicMenuStyle, head);
            }

            if (levelMenuItemStyles != null && levelMenuItemStyles.Count > 0)
            {
                levelMenuItemLinkStyles = new List <Style> (levelMenuItemStyles.Count);
                foreach (Style style in levelMenuItemStyles)
                {
                    Style linkStyle = new Style();
                    levelMenuItemLinkStyles.Add(linkStyle);
                    RegisterStyle(style, linkStyle, head);
                }
            }

            if (levelSubMenuStyles != null)
            {
                foreach (Style style in levelSubMenuStyles)
                {
                    RegisterStyle(style, head);
                }
            }

            if (staticSelectedStyle != null)
            {
                RegisterStyle(staticSelectedStyle, owner.StaticSelectedLinkStyle, head);
            }

            if (dynamicSelectedStyle != null)
            {
                RegisterStyle(dynamicSelectedStyle, owner.DynamicSelectedLinkStyle, head);
            }

            if (levelSelectedStyles != null && levelSelectedStyles.Count > 0)
            {
                levelSelectedLinkStyles = new List <Style> (levelSelectedStyles.Count);
                foreach (Style style in levelSelectedStyles)
                {
                    Style linkStyle = new Style();
                    levelSelectedLinkStyles.Add(linkStyle);
                    RegisterStyle(style, linkStyle, head);
                }
            }

            if (staticHoverStyle != null)
            {
                if (head == null)
                {
                    throw new InvalidOperationException("Using Menu.StaticHoverStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
                }
                RegisterStyle(staticHoverStyle, owner.StaticHoverLinkStyle, head);
                script.Append(String.Concat(cmenu, ".staticHover = ", ClientScriptManager.GetScriptLiteral(staticHoverStyle.RegisteredCssClass), ";\n"));
                script.Append(String.Concat(cmenu, ".staticLinkHover = ", ClientScriptManager.GetScriptLiteral(owner.StaticHoverLinkStyle.RegisteredCssClass), ";\n"));
            }

            if (dynamicHoverStyle != null)
            {
                if (head == null)
                {
                    throw new InvalidOperationException("Using Menu.DynamicHoverStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
                }
                RegisterStyle(dynamicHoverStyle, owner.DynamicHoverLinkStyle, head);
                script.Append(String.Concat(cmenu, ".dynamicHover = ", ClientScriptManager.GetScriptLiteral(dynamicHoverStyle.RegisteredCssClass), ";\n"));
                script.Append(String.Concat(cmenu, ".dynamicLinkHover = ", ClientScriptManager.GetScriptLiteral(owner.DynamicHoverLinkStyle.RegisteredCssClass), ";\n"));
            }
        }
Пример #30
0
		public override void RenderBeginTag (HtmlTextWriter writer)
		{
			string skipLinkText = SkipLinkText;
			
			if (!String.IsNullOrEmpty (skipLinkText)) {
				writer.AddAttribute (HtmlTextWriterAttribute.Href, "#" + ClientID + "_SkipLink");
				writer.RenderBeginTag (HtmlTextWriterTag.A);

				ClientScriptManager csm = new ClientScriptManager (null);
				
				writer.AddAttribute (HtmlTextWriterAttribute.Alt, skipLinkText);
				writer.AddAttribute (HtmlTextWriterAttribute.Src, csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif"));
				writer.AddAttribute (HtmlTextWriterAttribute.Height, "0");
				writer.AddAttribute (HtmlTextWriterAttribute.Width, "0");
				writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
				writer.RenderBeginTag (HtmlTextWriterTag.Img);
				
				writer.RenderEndTag (); // img
				writer.RenderEndTag (); // a
			}
			base.RenderBeginTag (writer);
		}
Пример #31
0
        public override void PreRender(Page page, HtmlHead head, ClientScriptManager csm, string cmenu, StringBuilder script)
        {
            Menu owner = Owner;

            script.AppendFormat("new Sys.WebForms.Menu ({{ element: '{0}', disappearAfter: {1}, orientation: '{2}', tabIndex: {3}, disabled: {4} }});",
                                owner.ClientID,
                                ClientScriptManager.GetScriptLiteral(owner.DisappearAfter),
                                owner.Orientation.ToString().ToLowerInvariant(),
                                ClientScriptManager.GetScriptLiteral(owner.TabIndex),
                                (!owner.Enabled).ToString().ToLowerInvariant());

            Type mt = typeof(Menu);

            if (!csm.IsClientScriptIncludeRegistered(mt, "MenuModern.js"))
            {
                string url = csm.GetWebResourceUrl(mt, "MenuModern.js");
                csm.RegisterClientScriptInclude(mt, "MenuModern.js", url);
            }

            if (!owner.IncludeStyleBlock)
            {
                return;
            }

            if (head == null)
            {
                throw new InvalidOperationException("Using Menu.IncludeStyleBlock requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
            }

            StyleBlock block      = new StyleBlock(owner.ClientID);
            Style      style      = owner.ControlStyle;
            bool       horizontal = owner.Orientation == Orientation.Horizontal;

            if (style != null)
            {
                block.RegisterStyle(style);
            }

            // #MenuId img.icon { border-style:none;vertical-align:middle; }
            block.RegisterStyle(HtmlTextWriterStyle.BorderStyle, "none", "img.icon")
            .Add(HtmlTextWriterStyle.VerticalAlign, "middle");

            // #MenuId img.separator { border-style:none;display:block; }
            block.RegisterStyle(HtmlTextWriterStyle.BorderStyle, "none", "img.separator")
            .Add(HtmlTextWriterStyle.Display, "block");

            // #MenuId img.horizontal-separator { border-style:none;vertical-align:middle; }
            if (horizontal)
            {
                block.RegisterStyle(HtmlTextWriterStyle.BorderStyle, "none", "img.horizontal-separator")
                .Add(HtmlTextWriterStyle.VerticalAlign, "middle");
            }

            // #MenuId ul { list-style:none;margin:0;padding:0;width:auto; }
            block.RegisterStyle(HtmlTextWriterStyle.ListStyleType, "none", "ul")
            .Add(HtmlTextWriterStyle.Margin, "0")
            .Add(HtmlTextWriterStyle.Padding, "0")
            .Add(HtmlTextWriterStyle.Width, "auto");

            SubMenuStyle sms = owner.StaticMenuStyleInternal;

            if (sms != null)
            {
                // #MenuId ul.static { ... }
                block.RegisterStyle(sms, "ul.static");
            }

            // #MenuId ul.dynamic { ...; z-index:1; ... }
            NamedCssStyleCollection css = block.RegisterStyle("ul.dynamic");

            sms = owner.DynamicMenuStyleInternal;
            if (sms != null)
            {
                sms.ForeColor = Color.Empty;
                css.Add(sms);
            }

            css.Add(HtmlTextWriterStyle.ZIndex, "1");
            int num = owner.DynamicHorizontalOffset;

            if (num != 0)
            {
                css.Add(HtmlTextWriterStyle.MarginLeft, num + "px");
            }
            num = owner.DynamicVerticalOffset;
            if (num != 0)
            {
                css.Add(HtmlTextWriterStyle.MarginTop, num + "px");
            }

            // BUG: rendering of LevelSubMenuStyles throws InvalidCastException on .NET
            // but I suspect the code it is supposed to generate is as follows:
            //
            // #MenuId ul.levelX { ... }
            //
            // so we will just ignore the bug and go with the above code.
            RenderLevelStyles(block, num, owner.LevelSubMenuStyles, "ul.level");

            // #MenuId a { text-decoration:none;white-space:nowrap;display:block; }
            block.RegisterStyle(HtmlTextWriterStyle.TextDecoration, "none", "a")
            .Add(HtmlTextWriterStyle.WhiteSpace, "nowrap")
            .Add(HtmlTextWriterStyle.Display, "block");

            // #MenuId a.static { ... }
            RenderAnchorStyle(block, owner.StaticMenuItemStyleInternal, "a.static");

            // #MenuId a.popout { background-image:url("...");background-repeat:no-repeat;background-position:right center;padding-right:14px; }
            bool   needDynamicPopOut = false;
            string str = owner.StaticPopOutImageUrl;

            css = null;
            string urlFormat = "url(\"{0}\")";

            if (String.IsNullOrEmpty(str))
            {
                if (owner.StaticEnableDefaultPopOutImage)
                {
                    css = block.RegisterStyle(HtmlTextWriterStyle.BackgroundImage, String.Format(urlFormat, GetArrowResourceUrl(owner)), "a.popout");
                }
                else
                {
                    needDynamicPopOut = true;
                }
            }
            else
            {
                css = block.RegisterStyle(HtmlTextWriterStyle.BackgroundImage, String.Format(urlFormat, str), "a.popout");
                needDynamicPopOut = true;
            }

            if (css != null)
            {
                css.Add("background-repeat", "no-repeat")
                .Add("background-position", "right center")
                .Add(HtmlTextWriterStyle.PaddingRight, "14px");
            }

            // #MenuId a.popout-dynamic { background:url("...") no-repeat right center;padding-right:14px; }
            str = owner.DynamicPopOutImageUrl;
            bool haveDynamicUrl = !String.IsNullOrEmpty(str);

            css = null;
            if (needDynamicPopOut || haveDynamicUrl)
            {
                urlFormat = "url(\"{0}\") no-repeat right center";
                if (!haveDynamicUrl)
                {
                    if (owner.DynamicEnableDefaultPopOutImage)
                    {
                        css = block.RegisterStyle(HtmlTextWriterStyle.BackgroundImage, String.Format(urlFormat, GetArrowResourceUrl(owner)), "a.popout-dynamic");
                    }
                }
                else
                {
                    css = block.RegisterStyle(HtmlTextWriterStyle.BackgroundImage, String.Format(urlFormat, str), "a.popout-dynamic");
                }
            }
            if (css != null)
            {
                haveDynamicPopOut = true;
                css.Add(HtmlTextWriterStyle.PaddingRight, "14px");
            }

            // #MenuId a.dynamic { ... }
            RenderAnchorStyle(block, owner.DynamicMenuItemStyleInternal, "a.dynamic");

            num = owner.StaticDisplayLevels;
            Unit   ssmi = owner.StaticSubMenuIndent;
            string unitName;
            double indent;

            if (ssmi == Unit.Empty)
            {
                unitName = "em";
                indent   = 1;
            }
            else
            {
                unitName = Unit.GetExtension(ssmi.Type);
                indent   = ssmi.Value;
            }

            // #MenuId a.levelX { ... }
            RenderLevelStyles(block, num, owner.LevelMenuItemStyles, "a.level", unitName, indent);

            // #MenuId a.selected.levelX { ... }
            RenderLevelStyles(block, num, owner.LevelSelectedStyles, "a.selected.level");

            // #MenuId a.static.selected { ...;text-decoration:none; }
            RenderAnchorStyle(block, owner.StaticSelectedStyleInternal, "a.static.selected");

            // #MenuId a.dynamic.selected { ...;text-decoration:none;border-style:none; }
            RenderAnchorStyle(block, owner.DynamicSelectedStyleInternal, "a.dynamic.selected");

            // #MenuId a.static.highlighted { ... }
            style = owner.StaticHoverStyleInternal;
            if (style != null)
            {
                block.RegisterStyle(style, "a.static.highlighted");
            }

            // #MenuId a.dynamic.highlighted { ... }
            style = owner.DynamicHoverStyleInternal;
            if (style != null)
            {
                block.RegisterStyle(style, "a.dynamic.highlighted");
            }

            head.Controls.Add(block);
        }
Пример #32
0
		void CreateSideBar (TableCell sideBarCell)
		{
			RegisterApplyStyle (sideBarCell, SideBarStyle);

			if (SkipLinkText != "") {
				System.Web.UI.HtmlControls.HtmlAnchor anchor = new System.Web.UI.HtmlControls.HtmlAnchor ();
				anchor.HRef = "#" + ClientID + "_SkipLink";

				Image img = new Image ();
				ClientScriptManager csm = new ClientScriptManager (null);
				img.ImageUrl = csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif");
				img.Attributes.Add ("height", "0");
				img.Attributes.Add ("width", "0");
				img.AlternateText = SkipLinkText;

				anchor.Controls.Add (img);
				sideBarCell.Controls.Add (anchor);
			}

			if (sideBarTemplate != null) {
				sideBarTemplate.InstantiateIn (sideBarCell);
				stepDatalist = sideBarCell.FindControl (DataListID) as DataList;
				if (stepDatalist == null)
					throw new InvalidOperationException ("The side bar template must contain a DataList control with id '" + DataListID + "'.");
				stepDatalist.ItemDataBound += new DataListItemEventHandler(StepDatalistItemDataBound);
			} else {
				stepDatalist = new DataList ();
				stepDatalist.ID = DataListID;
				stepDatalist.SelectedItemStyle.Font.Bold = true;
				stepDatalist.ItemTemplate = SideBarItemTemplate;
				sideBarCell.Controls.Add (stepDatalist);
			}

			if (SkipLinkText != "") {
				System.Web.UI.HtmlControls.HtmlAnchor anchor = new System.Web.UI.HtmlControls.HtmlAnchor ();
				anchor.ID = "SkipLink";
				sideBarCell.Controls.Add (anchor);
			}

			stepDatalist.ItemCommand += new DataListCommandEventHandler (StepDatalistItemCommand);
			stepDatalist.CellSpacing = 0;
			stepDatalist.DataSource = WizardSteps;
			stepDatalist.SelectedIndex = ActiveStepIndex;
			stepDatalist.DataBind ();
		}
Пример #33
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;

            #region Tham số
            string _ID           = Request["ID"];
            string _PID          = Request["PID"];
            string _LDMID        = Request["LDMID"];
            string _Lang         = Request["Lang"];
            string _Ten          = Request["Ten"];
            string _Alias        = Request["Alias"];
            string _Ma           = Request["Ma"];
            string _KyHieu       = Request["KyHieu"];
            string _GiaTri       = Request["GiaTri"];
            string _KeyWords     = Request["KeyWords"];
            string _Description  = Request["Description"];
            string _LangBased_ID = Request["LangBased_ID"];
            string _ThuTu        = Request["ThuTu"];
            string _Anh          = Request["Anh"];
            string _LangBased    = Request["LangBased"];
            string _q            = Request["q"];
            string _LDM_Ma       = Request["LDM_Ma"];
            if (_PID == "0")
            {
                _PID = string.Empty;
            }
            DanhMuc        Item;
            List <DanhMuc> List = new List <DanhMuc>();
            #endregion

            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid
                List = getTree(DanhMucDal.SelectByLDMID(_LDMID));
                var listRow = List.Select(dm => new jgridRow(dm.ID.ToString(), new string[]
                {
                    dm.ID.ToString(), dm.LangBased.ToString(), dm.ID.ToString(), dm.Lang, dm.ThuTu.ToString(), dm.LDM_Ten, dm.Ma, dm.KyHieu, dm.GiaTri, string.Format("<img class=\"adm-fn-icon\" src=\"../up/i/{0}?ref=\" />", string.IsNullOrEmpty(dm.Anh) ? "fn-icon.jpg" : dm.Anh, Guid.NewGuid().ToString().Replace("-", "")), dm.Ten, string.Format("{0:dd/MM/yy}", dm.NgayCapNhat), dm.NguoiTao + "/" + dm.NguoiSua, dm.Level.ToString(), dm.PID.ToString(), "true", "true"
                })).ToList();
                var grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, List.Count.ToString(), List.Count.ToString(), listRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "getByMa":
                #region lấy dữ liệu cho grid
                List = getTree(DanhMucDal.SelectByLDMMa(_LDM_Ma));
                var listRowByMa = List.Select(dm => new jgridRow(dm.ID.ToString(), new string[]
                {
                    dm.ID.ToString(), dm.LangBased.ToString(), dm.ID.ToString(), dm.Lang, dm.ThuTu.ToString(), dm.LDM_Ten, dm.Ma, dm.KyHieu, dm.GiaTri, string.Format("<img class=\"adm-fn-icon\" src=\"../up/i/{0}?ref=\" />", string.IsNullOrEmpty(dm.Anh) ? "fn-icon.jpg" : dm.Anh, Guid.NewGuid().ToString().Replace("-", "")), dm.Ten, string.Format("{0:dd/MM/yy}", dm.NgayCapNhat), dm.NguoiTao + "/" + dm.NguoiSua, dm.Level.ToString(), dm.PID.ToString(), "true", "true"
                })).ToList();
                var gridByMa = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, List.Count.ToString(), List.Count.ToString(), listRowByMa);
                sb.Append(JavaScriptConvert.SerializeObject(gridByMa));
                break;

                #endregion
            case "del":
                #region xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    DanhMucDal.DeleteById(new Guid(_ID));
                }
                break;

                #endregion
            case "autoCompleteLangBased":
                #region xóa
                sb.Append(JavaScriptConvert.SerializeObject(getTree(DanhMucDal.SelectByLDMMa(_LDM_Ma))));
                break;

                #endregion
            case "autoCompleteLdmMa":
                #region xóa
                sb.Append(JavaScriptConvert.SerializeObject(getTree(DanhMucDal.SelectByLDMMa(_LDM_Ma))));
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(DanhMucDal.SelectById(new Guid(_ID))));
                }
                break;

                #endregion
            case "save":
                #region lưu
                if (!string.IsNullOrEmpty(_ID))
                {
                    Item = DanhMucDal.SelectById(new Guid(_ID));
                }
                else
                {
                    Item = new DanhMuc();
                }
                Item.Ten         = _Ten;
                Item.Ma          = _Ma;
                Item.LDM_ID      = new Guid(_LDMID);
                Item.KyHieu      = _KyHieu;
                Item.NgayCapNhat = DateTime.Now;
                Item.NguoiTao    = Security.Username;
                Item.GiaTri      = _GiaTri;
                Item.ThuTu       = Convert.ToInt32(_ThuTu);
                Item.NguoiSua    = Security.Username;
                Item.KeyWords    = _KeyWords;
                Item.Description = _Description;
                Item.Alias       = _Alias;
                Item.Lang        = _Lang;
                Item.Anh         = _Anh;
                Item.LangBased   = Convert.ToBoolean(_LangBased);
                if (!string.IsNullOrEmpty(_LangBased_ID))
                {
                    Item.LangBased_ID = new Guid(_LangBased_ID);
                }
                if (!string.IsNullOrEmpty(_PID))
                {
                    Item.PID = new Guid(_PID);
                }
                if (!string.IsNullOrEmpty(_ID))
                {
                    Item = DanhMucDal.Update(Item);
                }
                else
                {
                    Item.NgayTao = DateTime.Now;
                    Item.RowId   = Guid.NewGuid();
                    Item.ID      = Guid.NewGuid();
                    if (!string.IsNullOrEmpty(_LangBased_ID))
                    {
                        Item.LangBased_ID = Item.ID;
                    }
                    Item = DanhMucDal.Insert(Item);
                }
                sb.Append("1");
                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.danhmuc.JScript1.js"));
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "mdl.htm"));
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.danhmuc.JScript1.js")
                                , "{danhmuc.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }