/// <summary> /// 获得数字过滤框items的最大值 /// </summary> /// <param name="customDate">配置文件配置过来的CustomDate实体</param> /// <param name="dateTime">时间参数</param> /// <returns>返回的数字过滤框item的最大值</returns> internal static int GetMaxValue(CustomDate customDate, DateTime dateTime) { int resultStr = dateTime.Year; switch (customDate.MaxValueType) { case "年": resultStr = CommonContant.ServerDateTime.AddYears(0 - customDate.PianyiNum).Year; break; case "月": resultStr = CommonContant.ServerDateTime.AddMonths(0 - customDate.PianyiNum).Month; break; case "季": resultStr = ConvertMonthToQuarter(CommonContant.ServerDateTime.AddMonths(0 - customDate.PianyiNum * 3).Month); break; case "周": resultStr = ConvertDayToWeek(CommonContant.ServerDateTime.AddDays(0 - customDate.PianyiNum * 7).Day); break; case "日": resultStr = CommonContant.ServerDateTime.AddDays(0 - customDate.PianyiNum).Day; break; } return(resultStr); }
/// <summary> /// 根据xml配置信息给过滤对象赋值 /// </summary> /// <param name="xml">文本节点</param> public void Deserialize(XmlNode xml) { if (xml == null) { return; } XmlDocument Doc = new XmlDocument(); Doc.LoadXml(xml.OuterXml); if (Doc.DocumentElement != null) { XmlNodeList bindFilterNodes = Doc.DocumentElement.GetElementsByTagName("BindFilter"); if (bindFilterNodes[0] != null) { XmlNode n = bindFilterNodes[0]; BindFilter bindFilter = new BindFilter(); bindFilter.Deserialize(n); this.BindFilter = bindFilter; } XmlNode otherDefaultValueNode = Doc.DocumentElement.GetElementsByTagName("OtherDefaultValue")[0]; if (otherDefaultValueNode != null) { CustomDate OtherDefaultValue = new CustomDate(); OtherDefaultValue.Deserialize(otherDefaultValueNode); this.OtherDefaultValue = OtherDefaultValue; } XmlNode finalCustomDateValueNode = Doc.DocumentElement.GetElementsByTagName("FinalCustomDateValue")[0]; if (finalCustomDateValueNode != null) { CustomDate FinalCustomDateValue = new CustomDate(); FinalCustomDateValue.Deserialize(finalCustomDateValueNode); this.FinalCustomDateValue = FinalCustomDateValue; } XmlNode FirstDefaultCustomDateValueNode = Doc.DocumentElement.GetElementsByTagName("FirstDefaultCustomDateValue")[0]; if (FirstDefaultCustomDateValueNode != null) { CustomDate FirstDefaultCustomDateValue = new CustomDate(); FirstDefaultCustomDateValue.Deserialize(FirstDefaultCustomDateValueNode); this.FirstDefaultCustomDateValue = FirstDefaultCustomDateValue; } if (Doc.DocumentElement.GetElementsByTagName("XmlWidth")[0] != null) { this.XmlWidth = int.Parse(Doc.DocumentElement.GetElementsByTagName("XmlWidth")[0].InnerText); } if (Doc.DocumentElement.GetElementsByTagName("BlnNewReportMoren")[0] != null) { this.BlnNewReportMoren = Doc.DocumentElement.GetElementsByTagName("BlnNewReportMoren")[0].InnerText == "true"; } if (Doc.DocumentElement.GetElementsByTagName("ReportTypeIndex")[0] != null) { this.ReportTypeIndex = Doc.DocumentElement.GetElementsByTagName("ReportTypeIndex")[0].InnerText; } if (Doc.DocumentElement.GetElementsByTagName("ReportValueType")[0] != null) { this.ReportValueType = int.Parse(Doc.DocumentElement.GetElementsByTagName("ReportValueType")[0].InnerText); } if (Doc.DocumentElement.GetElementsByTagName("IsSingleQuarter")[0] != null) { this.IsSingleQuarter = Doc.DocumentElement.GetElementsByTagName("IsSingleQuarter")[0].InnerText == "true"; } XmlNode defaultvaluenode = Doc.DocumentElement.GetElementsByTagName("DefaultValue")[0]; if (defaultvaluenode != null) { foreach (XmlAttribute attribute in defaultvaluenode.Attributes) { if (attribute.Name.Contains("type")) { if (attribute.Value.Contains("dateTime")) { this.DefaultValue = Convert.ToDateTime(defaultvaluenode.InnerText); } else if (attribute.Value.Contains("int") || attribute.Value.Contains("Int")) { this.DefaultValue = int.Parse(defaultvaluenode.InnerText); } else { this.DefaultValue = defaultvaluenode.InnerText; } } } } } // BlnNewReportMoren if (xml.Attributes["BindParam"] != null) { this.BindParam = xml.Attributes["BindParam"].Value; } if (xml.Attributes["BindValue"] != null) { this.BindValue = xml.Attributes["BindValue"].Value; } if (xml.Attributes["BindingType"] != null) { this.BindingType = (ValueBindingType)Enum.Parse(typeof(ValueBindingType), xml.Attributes["BindingType"].Value); } if (xml.Attributes["BlnAll"] != null) { this.BlnAll = xml.Attributes["BlnAll"].Value == "true"; } if (xml.Attributes["BlnChangeComboValue"] != null) { this.BlnChangeComboValue = xml.Attributes["BlnChangeComboValue"].Value == "true"; } if (xml.Attributes["BlnControlCaption"] != null) { this.BlnControlCaption = xml.Attributes["BlnControlCaption"].Value == "true"; } if (xml.Attributes["BlnDateToString"] != null) { this.BlnDateToString = xml.Attributes["BlnDateToString"].Value == "true"; } if (xml.Attributes["BlnDynamicColumn"] != null) { this.BlnDynamicColumn = xml.Attributes["BlnDynamicColumn"].Value == "true"; } if (xml.Attributes["BlnIsshowSureButton"] != null) { this.BlnIsshowSureButton = xml.Attributes["BlnIsshowSureButton"].Value == "true"; } if (xml.Attributes["BlnMaxDayIsToday"] != null) { this.BlnMaxDayIsToday = xml.Attributes["BlnMaxDayIsToday"].Value == "true"; } if (xml.Attributes["BlnNeedToTradingDay"] != null) { this.BlnNeedToTradingDay = xml.Attributes["BlnNeedToTradingDay"].Value == "true"; } if (xml.Attributes["BlnSCItemDynamic"] != null) { this.BlnSCItemDynamic = xml.Attributes["BlnSCItemDynamic"].Value == "true"; } if (xml.Attributes["ChartFilter"] != null) { this.ChartFilter = (FILTER)Enum.Parse(typeof(FILTER), xml.Attributes["ChartFilter"].Value); } if (xml.Attributes["ControlType"] != null) { this.ControlType = (ContnrolModeType)Enum.Parse(typeof(ContnrolModeType), xml.Attributes["ControlType"].Value); } if (xml.Attributes["DefaultValue"] != null) { this.DefaultValue = xml.Attributes["DefaultValue"].Value; } if (xml.Attributes["Filter"] != null) { this.Filter = (FILTER)Enum.Parse(typeof(FILTER), xml.Attributes["Filter"].Value); } if (xml.Attributes["Index"] != null) { this.Index = int.Parse(xml.Attributes["Index"].Value); } if (xml.Attributes["IsChangeToLastTime"] != null) { this.IsChangeToLastTime = xml.Attributes["IsChangeToLastTime"].Value == "true"; } if (xml.Attributes["IsHideCtrl"] != null) { this.IsHideCtrl = xml.Attributes["IsHideCtrl"].Value == "true"; } if (xml.Attributes["IsSendFilter"] != null) { this.IsSendFilter = xml.Attributes["IsSendFilter"].Value == "true"; } //if (xml.Attributes["IsSingleQuarter"] != null) // this.IsSingleQuarter = xml.Attributes["IsSingleQuarter"].Value == "true"; if (xml.Attributes["Key"] != null) { this.Key = xml.Attributes["Key"].Value; } if (xml.Attributes["MaxValue"] != null) { this.MaxValue = int.Parse(xml.Attributes["MaxValue"].Value); } if (xml.Attributes["MergeItems"] != null) { this.MergeItems = int.Parse(xml.Attributes["MergeItems"].Value); } if (xml.Attributes["MinValue"] != null) { this.MinValue = int.Parse(xml.Attributes["MinValue"].Value); } if (xml.Attributes["MonthOrQuarter"] != null) { this.MonthOrQuarter = (MonthOrQuarter)Enum.Parse(typeof(MonthOrQuarter), xml.Attributes["MonthOrQuarter"].Value); } if (xml.Attributes["OtherBindParam"] != null) { this.OtherBindParam = xml.Attributes["OtherBindParam"].Value; } if (xml.Attributes["ReportType"] != null) { this.ReportType = xml.Attributes["ReportType"].Value; } if (xml.Attributes["RowIndex"] != null) { this.RowIndex = int.Parse(xml.Attributes["RowIndex"].Value); } if (xml.Attributes["SCItemComType"] != null) { this.SCItemComType = xml.Attributes["SCItemComType"].Value; } if (xml.Attributes["SCItemComboColName"] != null) { this.SCItemComboColName = xml.Attributes["SCItemComboColName"].Value; } if (xml.Attributes["Text"] != null) { this.Text = xml.Attributes["Text"].Value; } }
/// <summary> /// 获取过滤框的对应时间 /// </summary> /// <param name="date"></param> /// <param name="nowTime">当前时间</param> /// <returns>获取的时间</returns> public static DateTime GetCustomDate(CustomDate date, DateTime nowTime) { DateTime resultTime = nowTime; switch (date.CalType) { case "年": //resultTime = CommonContant.ServerDateTime.AddYears(0 - date.Value); resultTime = Convert.ToDateTime(CommonContant.ServerDateTime.Year.ToString() + "-01-01").AddYears(0 - date.Value); break; case "季": resultTime = CommonContant.ServerDateTime.AddMonths(0 - date.Value * 3); break; case "月": resultTime = CommonContant.ServerDateTime.AddMonths(0 - date.Value); break; case "天": resultTime = CommonContant.ServerDateTime.AddDays(0 - date.Value); break; case "CuuertMonth": resultTime = CommonContant.ServerDateTime.AddMonths(0 - date.Value); break; case "日": resultTime = date.DateTime; break; case "StartMonth": DateTime startMonth = nowTime.AddDays(1 - nowTime.Day); //本月月初 resultTime = startMonth.AddMonths(0 - date.Value); break; case "CuuertDay": resultTime = nowTime.AddDays(0 - date.Value); break; case "EndMonth": DateTime startMonth1 = nowTime.AddDays(1 - nowTime.Day); //本月月初 resultTime = startMonth1.AddDays((nowTime.AddMonths(1) - nowTime).Days - 1).AddMonths(0 - date.Value); break; case "StartWeek": DateTime startWeek = nowTime.AddDays(1 - Convert.ToInt32(nowTime.DayOfWeek.ToString("d"))); //周一 resultTime = startWeek.AddDays(0 - date.Value * 7); break; case "EndWeek": DateTime startWeek1 = nowTime.AddDays(1 - Convert.ToInt32(nowTime.DayOfWeek.ToString("d"))); //周一 resultTime = startWeek1.AddDays(6).AddDays(0 - date.Value * 7); ; //周日 break; case "StartYear": DateTime startYear = new DateTime(nowTime.Year, 1, 1); //本年年初 resultTime = startYear.AddYears(0 - date.Value); break; case "EndYear": DateTime endYear = new DateTime(nowTime.Year, 12, 31); //本年年末 resultTime = endYear.AddYears(0 - date.Value); break; case "CuuertYear": DateTime cuuertYear = nowTime.Date; resultTime = cuuertYear.AddYears(0 - date.Value); break; } return(resultTime); }
/// <summary> /// 根据xml配置信息给过滤对象赋值 /// </summary> /// <param name="xml">文本节点</param> public void Deserialize(XmlNode xml) { if (xml == null) { return; } XmlDocument Doc = new XmlDocument(); Doc.LoadXml(xml.OuterXml); if (Doc.DocumentElement != null) { XmlNodeList ControlValuesNodes = Doc.DocumentElement.GetElementsByTagName("ControlValues"); List <SpeicalDateControlValue> values = new List <SpeicalDateControlValue>(); foreach (XmlNode node in ControlValuesNodes) { if (node != null) { SpeicalDateControlValue speicalDate = new SpeicalDateControlValue(); speicalDate.Deserialize(node); values.Add(speicalDate); } } this.ControlValues = values.ToArray(); XmlNode CustomDateNode = Doc.DocumentElement.GetElementsByTagName("CustomDate")[0]; if (CustomDateNode != null) { CustomDate Value = new CustomDate(); Value.Deserialize(CustomDateNode); this.CustomDate = CustomDate; } if (Doc.DocumentElement.GetElementsByTagName("BindFilterKey")[0] != null) { this.BindFilterKey = Doc.DocumentElement.GetElementsByTagName("BindFilterKey")[0].InnerText; } } if (xml.Attributes != null) { if (xml.Attributes["UrlCaptionCol"] != null) { this.UrlCaptionCol = xml.Attributes["UrlCaptionCol"].Value; } if (xml.Attributes["UrlShowName"] != null) { this.UrlShowName = xml.Attributes["UrlShowName"].Value; } if (xml.Attributes["BandCaptionFilterName"] != null) { this.BandCaptionFilterName = xml.Attributes["BandCaptionFilterName"].Value; } if (xml.Attributes["BandCaptionFormat"] != null) { this.BandCaptionFormat = xml.Attributes["BandCaptionFormat"].Value; } if (xml.Attributes["BandName"] != null) { this.BandName = xml.Attributes["BandName"].Value; } if (xml.Attributes["BindingDynamicName"] != null) { this.BindingDynamicName = xml.Attributes["BindingDynamicName"].Value; } if (xml.Attributes["BlnColumnRank"] != null) { this.BlnColumnRank = xml.Attributes["BlnColumnRank"].Value == "true"; } if (xml.Attributes["BlnRowGroup"] != null) { this.BlnRowGroup = xml.Attributes["BlnRowGroup"].Value == "true"; } if (xml.Attributes["BlnRowKey"] != null) { this.BlnRowKey = xml.Attributes["BlnRowKey"].Value == "true"; } if (xml.Attributes["Caption"] != null) { this.Caption = xml.Attributes["Caption"].Value; } if (xml.Attributes["BrowseWay"] != null) { this.BrowseWay = (BrowseWay)Enum.Parse(typeof(BrowseWay), xml.Attributes["BrowseWay"].Value); } if (xml.Attributes["CaptionFilterName"] != null) { this.CaptionFilterName = xml.Attributes["CaptionFilterName"].Value; } if (xml.Attributes["CaptionFormat"] != null) { this.CaptionFormat = xml.Attributes["CaptionFormat"].Value; } if (xml.Attributes["ColType"] != null) { this.ColType = (DATATYPE)Enum.Parse(typeof(DATATYPE), xml.Attributes["ColType"].Value); } if (xml.Attributes["FilterDateValueFormat"] != null) { this.FilterDateValueFormat = xml.Attributes["FilterDateValueFormat"].Value; } if (xml.Attributes["FormatString"] != null) { this.FormatString = xml.Attributes["FormatString"].Value; } if (xml.Attributes["IsAsc"] != null) { this.IsAsc = xml.Attributes["IsAsc"].Value == "true"; } if (xml.Attributes["IsBigText"] != null) { this.IsBigText = xml.Attributes["IsBigText"].Value == "true"; } if (xml.Attributes["IsFields"] != null) { this.IsFields = xml.Attributes["IsFields"].Value == "true"; } if (xml.Attributes["IsGroup"] != null) { this.IsGroup = (GROUPTYPE)Enum.Parse(typeof(GROUPTYPE), xml.Attributes["IsGroup"].Value); } if (xml.Attributes["IsWeb"] != null) { this.IsWeb = xml.Attributes["IsWeb"].Value == "true"; } if (xml.Attributes["Name"] != null) { this.Name = xml.Attributes["Name"].Value; } if (xml.Attributes["OrderBy"] != null) { this.OrderBy = xml.Attributes["OrderBy"].Value == "true"; } if (xml.Attributes["Postion"] != null) { this.Postion = int.Parse(xml.Attributes["Postion"].Value); } if (xml.Attributes["ResponseColumnFilter"] != null) { this.ResponseColumnFilter = (FILTER)Enum.Parse(typeof(FILTER), xml.Attributes["ResponseColumnFilter"].Value); } if (xml.Attributes["ResponseColumnNative"] != null) { this.ResponseColumnNative = (FILTER)Enum.Parse(typeof(FILTER), xml.Attributes["ResponseColumnNative"].Value); } if (xml.Attributes["ResponseFilter"] != null) { this.ResponseFilter = xml.Attributes["ResponseFilter"].Value == "true"; } if (xml.Attributes["ResponseFilterName"] != null) { this.ResponseFilterName = xml.Attributes["ResponseFilterName"].Value; } if (xml.Attributes["ResponseFilterNativeName"] != null) { this.ResponseFilterNativeName = xml.Attributes["ResponseFilterNativeName"].Value; } if (xml.Attributes["ResponseNative"] != null) { this.ResponseNative = xml.Attributes["ResponseNative"].Value == "true"; } if (xml.Attributes["SaveUrlColumnName"] != null) { this.SaveUrlColumnName = xml.Attributes["SaveUrlColumnName"].Value; } if (xml.Attributes["ShowControl"] != null) { this.ShowControl = xml.Attributes["ShowControl"].Value; } if (xml.Attributes["SourceName"] != null) { this.SourceName = xml.Attributes["SourceName"].Value; } if (xml.Attributes["StrCaptionExpress"] != null) { this.StrCaptionExpress = xml.Attributes["StrCaptionExpress"].Value; } if (xml.Attributes["StrStarName"] != null) { this.StrStarName = xml.Attributes["StrStarName"].Value; } if (xml.Attributes["Total"] != null) { this.Total = xml.Attributes["Total"].Value == "true"; } if (xml.Attributes["TotalCaption"] != null) { this.TotalCaption = xml.Attributes["TotalCaption"].Value; } if (xml.Attributes["Visible"] != null) { this.Visible = xml.Attributes["Visible"].Value == "true"; } if (xml.Attributes["VisibleIndex"] != null) { this.VisibleIndex = int.Parse(xml.Attributes["VisibleIndex"].Value); } if (xml.Attributes["WebColShowCaption"] != null) { this.WebColShowCaption = xml.Attributes["WebColShowCaption"].Value; } if (xml.Attributes["Width"] != null) { this.Width = int.Parse(xml.Attributes["Width"].Value); } } }