Exemple #1
0
        protected void _grdViewStyle_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    Label lnkFile    = (Label)e.Row.FindControl("_lblCSS");
                    Label lblDefault = (Label)e.Row.FindControl("_lblDefault");

                    // Change the color of Row which indicate the current default style
                    string defaultCSSFile = AppFunctions.GetDefaultThemeCssFilePath(Server.MapPath("~"));
                    defaultCSSFile = defaultCSSFile.Replace(@"\", "/");
                    defaultCSSFile = defaultCSSFile.Substring(defaultCSSFile.LastIndexOf("/") + 1);
                    if (Convert.ToString(lnkFile.Text) == defaultCSSFile)
                    {
                        e.Row.BackColor    = ColorExtender.ColorPicker.StringToColor("Yellow");
                        lblDefault.Visible = true;
                    }
                    else
                    {
                        lblDefault.Visible = false;
                    }

                    LinkButton lnkDefault = (LinkButton)e.Row.FindControl("_lnkDefault");
                    if (lnkDefault != null)
                    {
                        lnkDefault.Attributes.Add("onclick", "javascript:return confirm('Are you sure you wish to make this stylesheet the default style?')");
                    }

                    LinkButton linkCopy = (LinkButton)e.Row.FindControl("_linkCopy");
                    if (linkCopy != null)
                    {
                        linkCopy.Attributes.Add("onclick", "return showSaveAsModalPopupViaClient('" + lnkFile.Text + "');");
                    }

                    LinkButton linkEdit = (LinkButton)e.Row.FindControl("_linkEdit");
                    if (lnkFile.Text.ToUpper() == "IRISLEGAL.CSS")
                    {
                        lblDefault.Text    = string.Format(" ({0} Default)", Solicitors.Branding.Strings.DivisionName);
                        lblDefault.Visible = true;
                        if (linkEdit != null)
                        {
                            linkEdit.Visible = false;
                        }
                    }

                    LinkButton linkArchive = (LinkButton)e.Row.FindControl("_linkArchive");
                    if (lnkFile.Text.ToUpper() == "IRISLEGAL.CSS" || Convert.ToString(lnkFile.Text) == defaultCSSFile)
                    {
                        if (linkArchive != null)
                        {
                            linkArchive.Visible = false;
                        }
                    }
                    else
                    {
                        if (linkArchive != null)
                        {
                            linkArchive.Attributes.Add("onclick", "javascript:return confirm('Are you sure you wish to archive this style? Any users attached to this style will revert to the default one.')");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
            }
        }