public Filter(int departmentId, int filterId) { _departmentId = departmentId; m_Id = filterId; if (filterId == 0) return; SqlParameter _pUId = new SqlParameter("@UId", SqlDbType.Int); _pUId.Value = DBNull.Value; DataRow _row = Data.DBAccess.SelectRecord("sp_SelectAssetFilters", new[] { new SqlParameter("@DId", departmentId), _pUId, new SqlParameter("@Id", filterId) }); if (_row == null) return; string[] _state = _row["FilterState"].ToString().Split('&'); System.Collections.Specialized.StringDictionary _sd = new System.Collections.Specialized.StringDictionary(); for (int i = 0; i < _state.Length; i++) { if (_state[i].Length == 0) continue; string[] _item = _state[i].Split('='); if (_item.Length > 1) _sd.Add(_item[0], _item[1]); else _sd.Add(_item[0], string.Empty); } if (_sd.ContainsKey("fn")) m_FilterName = HttpUtility.UrlDecode(_sd["fn"]); if (_sd.ContainsKey("ca") && _sd["ca"].Length > 0) m_CategoryID = int.Parse(_sd["ca"]); if (_sd.ContainsKey("ty") && _sd["ty"].Length > 0) TypeID = int.Parse(_sd["ty"]); if (_sd.ContainsKey("ma") && _sd["ma"].Length > 0) m_MakeID = int.Parse(_sd["ma"]); if (_sd.ContainsKey("mo") && _sd["mo"].Length > 0) m_ModelID = int.Parse(_sd["mo"]); if (_sd.ContainsKey("st") && _sd["st"].Length > 0) m_StatusID = int.Parse(_sd["st"]); if (_sd.ContainsKey("ac") && _sd["ac"].Length > 0) m_AccountID = int.Parse(_sd["ac"]); if (_sd.ContainsKey("lo") && _sd["lo"].Length > 0) m_LocationID = int.Parse(_sd["lo"]); if (_sd.ContainsKey("ln")) m_LocationName = HttpUtility.UrlDecode(_sd["ln"]); if (_sd.ContainsKey("ow") && _sd["ow"].Length > 0) m_OwnerID = int.Parse(_sd["ow"]); if (_sd.ContainsKey("co") && _sd["co"].Length > 0) m_CheckedOutID = int.Parse(_sd["co"]); if (_sd.ContainsKey("vn") && _sd["vn"].Length > 0) m_VendorID = int.Parse(_sd["vn"]); if (_sd.ContainsKey("wv") && _sd["wv"].Length > 0) m_WarrantyVendorID = int.Parse(_sd["wv"]); if (_sd.ContainsKey("sn")) m_SerialNumber = HttpUtility.UrlDecode(_sd["sn"]); if (_sd.ContainsKey("an")) m_Name = HttpUtility.UrlDecode(_sd["an"]); if (_sd.ContainsKey("po")) m_PONumber = HttpUtility.UrlDecode(_sd["po"]); if (_sd.ContainsKey("fc")) m_FundingCode = HttpUtility.UrlDecode(_sd["fc"]); if (_sd.ContainsKey("ds") && _sd["ds"].Length > 0) m_DateStart = DateTime.Parse(HttpUtility.UrlDecode(_sd["ds"]), new System.Globalization.CultureInfo("en-US")); if (_sd.ContainsKey("de") && _sd["de"].Length > 0) m_DateEnd = DateTime.Parse(HttpUtility.UrlDecode(_sd["de"]), new System.Globalization.CultureInfo("en-US")); if (_sd.ContainsKey("dr") && _sd["dr"].Length > 0) m_DateRange = (StandardDateRange)Enum.Parse(typeof(StandardDateRange), _sd["dr"], true); if (_sd.ContainsKey("ba") && _sd["ba"] == "1") m_DateAquired = true; if (_sd.ContainsKey("bp") && _sd["bp"] == "1") m_DatePurchased = true; if (_sd.ContainsKey("br") && _sd["br"] == "1") m_DateReceived = true; if (_sd.ContainsKey("be") && _sd["be"] == "1") m_DateEntered = true; if (_sd.ContainsKey("bd") && _sd["bd"] == "1") m_DateDeployed = true; if (_sd.ContainsKey("bo") && _sd["bo"] == "1") m_DateOutOfService = true; if (_sd.ContainsKey("bs") && _sd["bs"] == "1") m_DateDisposed = true; if (_sd.ContainsKey("bu") && _sd["bu"] == "1") m_DateUpdated = true; if (_sd.ContainsKey("vc")) m_ValueCurrent = HttpUtility.UrlDecode(_sd["vc"]); if (_sd.ContainsKey("vr")) m_ValueReplacement = HttpUtility.UrlDecode(_sd["vr"]); if (_sd.ContainsKey("vd")) m_ValueDepreciated = HttpUtility.UrlDecode(_sd["vd"]); if (_sd.ContainsKey("vs")) m_ValueSalvage = HttpUtility.UrlDecode(_sd["vs"]); if (_sd.ContainsKey("dc")) m_DisposalCost = HttpUtility.UrlDecode(_sd["dc"]); foreach (AssetTypeProperty _prop in m_CustomProperties) if (_sd.ContainsKey("cp" + _prop.ID.ToString())) _prop.Value = HttpUtility.UrlDecode(_sd["cp" + _prop.ID.ToString()]); }
public Filter(int departmentId, bool isNew) { _departmentId = departmentId; if (isNew) return; UserSetting _c = UserSetting.GetSettings("AssetS"); if (!_c.IsDefined) return; if (_c["FI"] != null && _c["FI"].Length > 0) m_Id = int.Parse(_c["FI"]); if (_c["FN"] != null) m_FilterName = _c["FN"]; if (_c["CA"] != null && _c["CA"].Length > 0) m_CategoryID = int.Parse(_c["CA"]); if (_c["TY"] != null && _c["TY"].Length > 0) TypeID = int.Parse(_c["TY"]); if (_c["MA"] != null && _c["MA"].Length > 0) m_MakeID = int.Parse(_c["MA"]); if (_c["MO"] != null && _c["MO"].Length > 0) m_ModelID = int.Parse(_c["MO"]); if (_c["ST"] != null && _c["ST"].Length > 0) m_StatusID = int.Parse(_c["ST"]); if (_c["AC"] != null && _c["AC"].Length > 0) m_AccountID = int.Parse(_c["AC"]); if (_c["LO"] != null && _c["LO"].Length > 0) m_LocationID = int.Parse(_c["LO"]); if (_c["LN"] != null) m_LocationName = HttpUtility.UrlDecode(_c["LN"]); if (_c["OW"] != null && _c["OW"].Length > 0) m_OwnerID = int.Parse(_c["OW"]); if (_c["CO"] != null && _c["CO"].Length > 0) m_CheckedOutID = int.Parse(_c["CO"]); if (_c["VN"] != null && _c["VN"].Length > 0) m_VendorID = int.Parse(_c["VN"]); if (_c["WV"] != null && _c["WV"].Length > 0) m_WarrantyVendorID = int.Parse(_c["WV"]); if (_c["SN"] != null) m_SerialNumber = HttpUtility.UrlDecode(_c["SN"]); if (_c["AN"] != null) m_Name = HttpUtility.UrlDecode(_c["AN"]); if (_c["PO"] != null) m_PONumber = HttpUtility.UrlDecode(_c["PO"]); if (_c["FC"] != null) m_FundingCode = HttpUtility.UrlDecode(_c["FC"]); if (_c["DS"] != null && _c["DS"].Length > 0) m_DateStart = DateTime.Parse(HttpUtility.UrlDecode(_c["DS"]), new System.Globalization.CultureInfo("en-US")); if (_c["DE"] != null && _c["DE"].Length > 0) m_DateEnd = DateTime.Parse(HttpUtility.UrlDecode(_c["DE"]), new System.Globalization.CultureInfo("en-US")); if (_c["DR"] != null && _c["DR"].Length > 0) m_DateRange = (StandardDateRange)Enum.Parse(typeof(StandardDateRange), _c["DR"], true); if (_c["BA"] != null && _c["BA"].Length > 0) m_DateAquired = bool.Parse(_c["BA"]); if (_c["BP"] != null && _c["BP"].Length > 0) m_DatePurchased = bool.Parse(_c["BP"]); if (_c["BR"] != null && _c["BR"].Length > 0) m_DateReceived = bool.Parse(_c["BR"]); if (_c["BE"] != null && _c["BE"].Length > 0) m_DateEntered = bool.Parse(_c["BE"]); if (_c["BD"] != null && _c["BD"].Length > 0) m_DateDeployed = bool.Parse(_c["BD"]); if (_c["BO"] != null && _c["BO"].Length > 0) m_DateOutOfService = bool.Parse(_c["BO"]); if (_c["BS"] != null && _c["BS"].Length > 0) m_DateDisposed = bool.Parse(_c["BS"]); if (_c["BU"] != null && _c["BU"].Length > 0) m_DateUpdated = bool.Parse(_c["BU"]); if (_c["VC"] != null) m_ValueCurrent = HttpUtility.UrlDecode(_c["VC"]); if (_c["VR"] != null) m_ValueReplacement = HttpUtility.UrlDecode(_c["VR"]); if (_c["VD"] != null) m_ValueDepreciated = HttpUtility.UrlDecode(_c["VD"]); if (_c["VS"] != null) m_ValueSalvage = HttpUtility.UrlDecode(_c["VS"]); if (_c["DC"] != null) m_DisposalCost = HttpUtility.UrlDecode(_c["DC"]); foreach (AssetTypeProperty _prop in m_CustomProperties) if (_c["CP" + _prop.ID.ToString()] != null) _prop.Value = HttpUtility.UrlDecode(_c["CP" + _prop.ID.ToString()]); }
/// <summary> /// Gets the end date of specified standard date range. /// </summary> /// <param name="range">Specifies the standard date range. One of StandardDateRange values.</param> /// <returns>The DateTime value that represents the end date of specified standard date range.</returns> public DateTime GetRangeEndDate(StandardDateRange range) { DateTime Today = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59); int DayOfWeek = (int)Today.AddDays(-1).DayOfWeek; DateTime ThisMonth = new DateTime(Today.Year, Today.Month, 1); DateTime ThisYear = new DateTime(Today.Year, 1, 1); DateTime ThisFiscalYear = new DateTime(((Today.Month >= this.FiscalYearEnd.Month) ? Today.Year : Today.AddYears(-1).Year), this.FiscalYearEnd.Month, this.FiscalYearEnd.Day); switch (range) { case StandardDateRange.Today: return(Today); case StandardDateRange.ThisWeek: return(Today.AddDays(-DayOfWeek + 6)); case StandardDateRange.ThisMonth: return(ThisMonth.AddMonths(1).AddDays(-1)); case StandardDateRange.ThisYear: return(ThisYear.AddYears(1).AddDays(-1)); case StandardDateRange.ThisFiscalYear: return(ThisFiscalYear.AddYears(1).AddDays(-1)); case StandardDateRange.LastWeek: return(Today.AddDays(-DayOfWeek - 1)); case StandardDateRange.LastMonth: return(ThisMonth.AddDays(-1)); case StandardDateRange.LastYear: return(ThisYear.AddDays(-1)); case StandardDateRange.LastFiscalYear: return(ThisFiscalYear.AddDays(-1)); case StandardDateRange.NextWeek: return(Today.AddDays(-DayOfWeek + 13)); case StandardDateRange.NextMonth: return(ThisMonth.AddMonths(2).AddDays(-1)); case StandardDateRange.NextYear: return(ThisYear.AddYears(2).AddDays(-1)); case StandardDateRange.NextFiscalYear: return(ThisFiscalYear.AddYears(2).AddDays(-1)); case StandardDateRange.Next30Days: return(Today.AddDays(30)); case StandardDateRange.Next90Days: return(Today.AddDays(90)); case StandardDateRange.Next365Days: return(Today.AddDays(365)); case StandardDateRange.Rolling30Days: case StandardDateRange.Rolling90Days: case StandardDateRange.Rolling365Days: default: return(Today); } }