예제 #1
0
        public string GetCallbackResult()
        {
            //return string.Empty;
            ThemeHelper theme = new ThemeHelper(Theme);
            if (!Enabled)
            {
                return string.Empty;
            }

            mv.Width = DateBoxWidth;
            mv.BorderStyle = BorderStyle.None;
            mv.ShowTitle = false;
            mv.DayRender += MonthViewDayRender;

            mv.Font.Name = "Tahoma";
            mv.DayStyle.MergeWith(theme.DayStyle);
            mv.DayHeaderStyle.MergeWith(theme.DayStyle);
            mv.SelectedDayStyle.MergeWith(theme.SelectedDayStyle);
            mv.TodayDayStyle.MergeWith(theme.TodayDayStyle);

            //next & prev formats

            DropDownList list = theme.CreateFooterDropDownList();
            //list.MergeStyle(monthYearDropDownStyle);

            StringBuilder sb = new StringBuilder();
            StringWriter writer = new StringWriter(sb);
            HtmlTextWriter tw = new HtmlTextWriter(writer);

            if (this.EnableDropShadow)
            {
                tw.AddStyleAttribute(HtmlTextWriterStyle.Display, "#EFEFEF");
            }
            tw.AddAttribute(HtmlTextWriterAttribute.Id, "FADatePickerDropShadow_" + this.ClientID);
            tw.AddStyleAttribute(HtmlTextWriterStyle.ZIndex, (this.ZIndex + 1).ToString());
            tw.AddStyleAttribute(HtmlTextWriterStyle.Left, this.CalendarOffsetX.ToString());
            tw.AddStyleAttribute(HtmlTextWriterStyle.Top, this.CalendarOffsetY.ToString());
            tw.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline");
            tw.AddStyleAttribute("min-width", this.mv.Width.ToString());
            tw.AddAttribute("CellPadding", "0");
            tw.AddAttribute("CellSpacing", "0");
            tw.RenderBeginTag(HtmlTextWriterTag.Table);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            tw.RenderBeginTag(HtmlTextWriterTag.Td);
            tw.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "white");
            tw.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, "gray");
            tw.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
            tw.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "1px");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Left, "-4px");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Top, "-4px");
            tw.AddStyleAttribute(HtmlTextWriterStyle.Width, this.mv.Width.ToString());
            tw.AddAttribute(HtmlTextWriterAttribute.Id, "FADatePickerCalendarContainer_" + this.ClientID);
            tw.AddAttribute("CellPadding", "0");
            tw.AddAttribute("CellSpacing", "0");
            tw.RenderBeginTag(HtmlTextWriterTag.Table);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            tw.RenderBeginTag(HtmlTextWriterTag.Td);

            Table table = theme.CreateTitleTable(this.Page);
            table.Width = Unit.Percentage(100.0);
            table.MergeStyle(this.MonthViewTitleStyle);
            table.ID = "FADatePickerCalendarTitle_" + this.ClientID;
            table.RenderBeginTag(tw);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            TableCell cell = new TableCell();
            cell.Style.Add(HtmlTextWriterStyle.TextAlign, "left");
            cell.MergeStyle(this.MonthViewNextPrevStyle);
            cell.RenderBeginTag(tw);

            if ((this.mv.VisibleDate.Month > this.MinDate.Month) || (this.mv.VisibleDate.Year > this.MinDate.Year))
            {
                try
                {
                    DateTime dt = this.mv.VisibleDate.AddMonths(-1);
                    dt = dt.AddDays((double)-(dt.Day - 1));
                    if (this.NextPrevFormat == NextPrevFormat.ShortMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + dt.ToString("MMM") + "</div>");
                    }
                    else if (this.NextPrevFormat == NextPrevFormat.FullMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + dt.ToString("MMMM") + "</div>");
                    }
                    else
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + dt.ToShortDateString() + "')\">" + this.PrevMonthText + "</div>");
                    }
                }
                catch
                {
                }
            }

            cell.RenderEndTag(tw);
            tw.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "center");
            tw.RenderBeginTag(HtmlTextWriterTag.Td);
            tw.WriteLine(this.mv.VisibleDate.ToString("MMMM yyyy"));
            tw.RenderEndTag();
            TableCell cell2 = new TableCell();
            cell2.Style.Add(HtmlTextWriterStyle.TextAlign, "right");
            cell2.MergeStyle(this.MonthViewNextPrevStyle);
            cell2.RenderBeginTag(tw);

            if ((this.mv.VisibleDate.Month < this.MaxDate.Month) || (this.mv.VisibleDate.Year < this.MaxDate.Year))
            {
                try
                {
                    DateTime time9 = this.mv.VisibleDate.AddMonths(1);
                    time9 = time9.AddDays((double)-(time9.Day - 1));
                    if (this.NextPrevFormat == NextPrevFormat.ShortMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + time9.ToString("MMM") + "</div>");
                    }
                    else if (this.NextPrevFormat == NextPrevFormat.FullMonth)
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + time9.ToString("MMMM") + "</div>");
                    }
                    else
                    {
                        tw.WriteLine("<div style='cursor:pointer;' onclick=\"javascript:CallServer_" + this.ClientID + "('" + time9.ToShortDateString() + "')\">" + this.NextMonthText + "</div>");
                    }
                }
                catch
                {
                }
            }
            cell2.RenderEndTag(tw);
            tw.RenderEndTag();
            table.RenderEndTag(tw);

            this.mv.RenderControl(tw);

            Table table2 = theme.CreateFooterTable(this.Page);
            table2.ID = string.Format("{0}_Footer", this.ClientID);
            table2.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
            table2.Width = Unit.Percentage(100.0);
            table2.MergeStyle(this.MonthViewFooterStyle);
            table2.RenderBeginTag(tw);
            tw.RenderBeginTag(HtmlTextWriterTag.Tr);
            tw.RenderBeginTag(HtmlTextWriterTag.Td);
            if (this.ShowTodayButton)
            {
                Button button = theme.CreateFooterButton();
                //button.MergeStyle(this.TodayButtonStyle);
                //button.Text = this.TodayButtonText;
                button.OnClientClick = "javascript:SetDate_" + this.ClientID + "('" + DateTime.Today.ToString(this.DateFormat) + "'); return false;";
                button.RenderControl(tw);
            }

            if (this.ShowEmptyButton)
            {
                Button button2 = theme.CreateFooterButton();
                //button2.MergeStyle(this.TodayButtonStyle);
                //button2.Text = this.NoneButtonText;
                button2.OnClientClick = "javascript:SetDate_" + this.ClientID + "(''); return false;";
                button2.RenderControl(tw);
            }
            list.RenderControl(tw);
            //list2.RenderControl(tw);
            tw.RenderEndTag();
            tw.RenderEndTag();
            table2.RenderEndTag(tw);
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();
            tw.RenderEndTag();

            return sb.ToString();
        }
예제 #2
0
        protected GridViewRow BuildHeader()
        {
            GridViewRow tr = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);

            TableCell thTL = new TableCell();
            thTL.Style.Add(HtmlTextWriterStyle.Width, "6px");
            thTL.CssClass = "GridViewHeaderTL";
            tr.Cells.Add(thTL);

            for (int i = 0; i < this.Columns.Count; i++)
            {
                TableCell th = new TableCell();
                th.CssClass = "GridViewHeaderTC";

                if (this.Columns[i] is SortableField && ((this.Columns[i] as SortableField).ShowSort))
                {
                    ImageButton imgSort = new ImageButton();
                    imgSort.ID = "imgSort_" + i.ToString();
                    imgSort.CssClass = "GridViewHeaderSort";
                    imgSort.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(RainstormStudios.Web.UI.WebControls.GridView), "RainstormStudios.Web.UI.WebControls.images.gridView.Sort.png");
                    imgSort.AlternateText = "";
                    imgSort.CommandArgument = (this.Columns[i] as BoundField).DataField;
                    imgSort.CommandName = "Sort";
                    imgSort.Command += new CommandEventHandler(this.imgSort_OnCommand);
                    th.Controls.Add(imgSort);
                    imgSort.Attributes.Add("name", imgSort.UniqueID);
                }

                bool usedTemplate = false;
                if (this.Columns[i] is System.Web.UI.WebControls.TemplateField)
                {
                    TemplateField fld = (this.Columns[i] as TemplateField);
                    ITemplate hdrTmpl = fld.HeaderTemplate;
                    if (hdrTmpl != null)
                    {
                        hdrTmpl.InstantiateIn(th);
                        usedTemplate = true;
                    }
                }

                if (!usedTemplate)
                {
                    // Standard field
                    Label lblHdr = new Label();
                    lblHdr.Text = this.Columns[i].HeaderText;
                    th.Controls.Add(lblHdr);
                }

                th.MergeStyle(this.Columns[i].HeaderStyle);
                tr.Cells.Add(th);
            }

            TableCell thTR = new TableCell();
            thTR.Style.Add(HtmlTextWriterStyle.Width, "6px");
            thTR.CssClass = "GridViewHeaderTR";
            tr.Cells.Add(thTR);

            this._hdrRow = tr;
            this.OnItemCreated(new GridViewItemEventArgs(tr));
            return tr;
        }
예제 #3
0
 private void ApplySortingStyle(TableCell cell, DataControlField field, TableItemStyle ascendingStyle, TableItemStyle descendingStyle) {
     if (!String.IsNullOrEmpty(SortExpression) && String.Equals(field.SortExpression, SortExpression, StringComparison.OrdinalIgnoreCase)) {
         if (SortDirection == SortDirection.Ascending) {
             cell.MergeStyle(ascendingStyle);
         }
         else {
             cell.MergeStyle(descendingStyle);
         }
     }
 }
예제 #4
0
        protected int CreateControlHeirarchy(IEnumerable dataSource, bool useDataSource)
        {
            // Clear/create the rows ArrayList
            if (this._rows == null)
                this._rows = new ArrayList();
            else
                this._rows.Clear();

            GridViewRow hdr = this.BuildHeader();

            if (this.PageIndex < 0)
                this.PageIndex = 0;
            //int startRec = this.PageIndex * this.PageSize;
            int itemCount = 0; //, recCount = 0;
            if (dataSource != null)
            {
                foreach (var dataItem in dataSource)
                {
                    //if (recCount < startRec || itemCount >= this.PageSize)
                    //{
                    //    recCount++;
                    //    continue;
                    //}

                    GridViewRow tr = new GridViewRow(itemCount + (this.ShowHeader ? 1 : 0), itemCount, DataControlRowType.DataRow, (itemCount % 2 == 0 ? DataControlRowState.Normal : DataControlRowState.Alternate));
                    tr.CssClass = (itemCount % 2 == 0) ? "GridViewLineAlt" : "GridViewLine";

                    TableCell tdL = new TableCell();
                    tdL.CssClass = "GridViewLineLeft";
                    tr.Cells.Add(tdL);

                    int curColCount = 0;
                    for (int i = 0; i < this.Columns.Count; i++)
                    {
                        TableCell td = new TableCell();

                        DataControlField column = this.Columns[i];

                        bool usedTemplate = false;
                        if (column is TemplateField)
                        {
                            TemplateField fld = (column as TemplateField);
                            ITemplate template = null;
                            if (itemCount % 2 != 0)
                                template = fld.AlternatingItemTemplate;
                            if (template == null)
                                template = fld.ItemTemplate;

                            if (template != null)
                            {
                                template.InstantiateIn(td);
                                usedTemplate = true;
                            }
                        }

                        if (!usedTemplate)
                        {
                            string dataStr = string.Empty;
                            if (column is BoundField)
                            {
                                BoundField fld = (column as BoundField);
                                if (!string.IsNullOrEmpty(fld.DataField))
                                    dataStr = DataBinder.GetPropertyValue(dataItem, fld.DataField, fld.DataFormatString);
                                else
                                {
                                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(dataItem);
                                    if (props.Count >= 1)
                                        if (null != props[0].GetValue(dataItem))
                                            dataStr = props[0].GetValue(dataItem).ToString();
                                }
                            }

                            if (column is CheckBoxField)
                            {
                                CheckBoxField fld = (column as CheckBoxField);
                                CheckBox chkFld = new CheckBox();
                                chkFld.ID = string.Format("chkField_{0}_{1}", itemCount, i);
                                string fldStr = string.Empty;
                                if (!string.IsNullOrEmpty(fld.Text))
                                    fldStr = fld.Text;
                                else if (!string.IsNullOrEmpty(fld.DataField))
                                    fldStr = dataStr;
                                chkFld.Text = fldStr;
                                chkFld.MergeStyle(fld.ControlStyle);
                                td.Controls.Add(chkFld);
                            }
                            else if (column is CommandField)
                            {
                                CommandField fld = (column as CommandField);

                                string keyArg = string.Empty;
                                if (this.DataKeyNames != null && this.DataKeyNames.Length > 0)
                                    keyArg = string.Join(",", this.DataKeyNames);

                                if (fld.ShowSelectButton)
                                {
                                    WebControl btn = this.GetButton(fld, "Select", keyArg, itemCount, i, fld.SelectText, fld.SelectImageUrl);
                                    td.Controls.Add(btn);
                                }

                                if (fld.ShowEditButton)
                                {
                                    WebControl btn = this.GetButton(fld, "Edit", keyArg, itemCount, i, fld.EditText, fld.EditImageUrl);
                                    td.Controls.Add(btn);
                                }

                                if (fld.ShowDeleteButton)
                                {
                                    WebControl btn = this.GetButton(fld, "Delete", keyArg, itemCount, i, fld.DeleteText, fld.DeleteImageUrl);
                                    td.Controls.Add(btn);
                                }
                            }
                            else if (column is ButtonField)
                            {
                                ButtonField fld = (column as ButtonField);

                                string keyArg = string.Empty;
                                if (this.DataKeyNames != null && this.DataKeyNames.Length > 0)
                                    keyArg = string.Join(",", this.DataKeyNames);

                                string btnText = dataStr = DataBinder.GetPropertyValue(dataItem, fld.DataTextField, fld.DataTextFormatString);
                                WebControl btn = this.GetButton(fld, fld.CommandName, keyArg, itemCount, i, btnText, fld.ImageUrl);
                                td.Controls.Add(btn);
                            }
                            else
                            {
                                td.Text = dataStr;
                            }
                        }

                        td.MergeStyle(column.ItemStyle);
                        if (curColCount > 0)
                            td.Style.Add("border-left", "solid 1px #ccccd3");
                        curColCount++;
                        tr.Cells.Add(td);
                    }

                    if (this.AutoGenerateColumns)
                    {
                        // If auto-generate columns is set to true, then create a column for each field in the data.
                        PropertyDescriptorCollection props = TypeDescriptor.GetProperties(dataItem);
                        for (int i = 0; i < props.Count; i++)
                        {
                            TableCell td = new TableCell();

                            if (null != props[i].GetValue(dataItem))
                                td.Text = props[i].GetValue(dataItem).ToString();

                            td.MergeStyle(this.ItemStyle);
                            if (curColCount > 0)
                                td.Style.Add("border-left", "solid 1px #ccccd3");
                            curColCount++;
                            tr.Cells.Add(td);
                        }
                    }

                    TableCell tdR = new TableCell();
                    tdR.CssClass = "GridViewLineRight";
                    tr.Cells.Add(tdR);

                    _rows.Add(tr);
                    this.OnItemCreated(new GridViewItemEventArgs(tr));
                    itemCount++;
                }
                //this.TotalRecordCount = recCount;
                //this.PageCount = (int)Math.Ceiling((double)this.TotalRecordCount / (double)this.PageSize);
            }
            this._rowCol = new GridViewRowCollection(this._rows);
            //this.ViewState["!_tblData"] = dataSource;

            GridViewRow ftr = this.BuildFooter();

            //if (this.CacheDuration > 0)
            //{
            //    System.Web.HttpContext.Current.Cache.Remove("GridViewObj" + this.UniqueID);
            //    System.Web.HttpContext.Current.Cache.Insert("GridViewObj" + this.UniqueID, dataSource, null, DateTime.Now.AddMinutes(this.CacheDuration), TimeSpan.Zero);
            //}

            return itemCount;
        }