protected void GridACCPeriodType_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { try { if (bo.checkIsAccountingPeriodTypeIdInCurrency(uow, e.Values["AccountingPeriodTypeId"].ToString().Trim())) { e.Cancel = true; throw new Exception(String.Format("Lỗi không thể xóa vì có chứa Chu Kỳ ")); } else { e.Cancel = true; uow.BeginTransaction(); Guid a = Guid.Parse(e.Keys[0].ToString()); AccountingPeriodType accpT = uow.GetObjectByKey <AccountingPeriodType>(a); accpT.RowStatus = Utility.Constant.ROWSTATUS_DELETED; accpT.Save(); uow.CommitTransaction(); } } catch (Exception) { uow.RollbackTransaction(); e.Cancel = true; throw; } }
protected void cboAccountPeriod_ItemsRequestedByFilterCondition(object source, ListEditItemsRequestedByFilterConditionEventArgs e) { ASPxComboBox combo = source as ASPxComboBox; XPCollection <AccountingPeriod> collection = new XPCollection <AccountingPeriod>(session); collection.SkipReturnedObjects = e.BeginIndex; collection.TopReturnedObjects = e.EndIndex - e.BeginIndex + 1; AccountingPeriodTypeBO typeBO = new AccountingPeriodTypeBO(); AccountingPeriodType minAccountingPeriodType = typeBO.GetMinAccountingPeriodType(session); CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_IsActive = new BinaryOperator("IsActive", true, BinaryOperatorType.Equal); CriteriaOperator criteria_Type = new BinaryOperator("AccountingPeriodTypeId", minAccountingPeriodType, BinaryOperatorType.Equal); CriteriaOperator criteria = CriteriaOperator.And(criteria_IsActive, criteria_RowStatus, criteria_Type); XPCollection <AccountingPeriod> AccountingPeriodCol = new XPCollection <AccountingPeriod>(session, criteria); criteria = CriteriaOperator.And( CriteriaOperator.Or( new BinaryOperator("Code", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like), new BinaryOperator("Description", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like) ), new BinaryOperator("RowStatus", 1, BinaryOperatorType.GreaterOrEqual), new InOperator("this", AccountingPeriodCol) ); collection.Criteria = criteria; collection.Sorting.Add(new SortProperty("Code", DevExpress.Xpo.DB.SortingDirection.Ascending)); combo.DataSource = collection; combo.DataBindItems(); }
protected void ASPxGridView2_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { e.NewValues["RowStatus"] = Constant.ROWSTATUS_ACTIVE; if (e.NewValues["IsDefault"] == null) { e.NewValues["IsDefault"] = false; } if (Util.isExistXpoObject <AccountingPeriodType>("Name", (string)e.NewValues["Name"])) { e.Cancel = true; throw(new Exception("Trùng tên thể loại chu kì")); } if ((bool)e.NewValues["IsDefault"] == true) { CriteriaOperator criteria = new BinaryOperator("IsDefault", true, BinaryOperatorType.Equal); AccountingPeriodType type = session.FindObject <AccountingPeriodType>(criteria); e.NewValues["RowStatus"] = Constant.ROWSTATUS_ACTIVE; if (type != null) { if (AccountingPeriodTypeBO.IsUsedAccoutingPeriodType(session, type.AccountingPeriodTypeId)) { ASPxGridView2.CancelEdit(); throw new Exception("Loại chu kì nhỏ nhất " + type.Name + " đang được sử dụng nên không thể thay đổi"); } type.IsDefault = false; type.Save(); } } }
protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) { AccountingPeriodType type = session.GetObjectByKey <AccountingPeriodType>(Guid.Parse(e.Parameter.ToString())); if (type.IsDefault == true) { XPOAccountingPeriodLookup.Criteria = "[RowStatus] > 0s And [IsActive] = True And [IsActive] <> True And [Code] <> 'NAAN_DEFAULT' And [AccountingPeriodTypeId.IsDefault] = True"; } else { XPOAccountingPeriodLookup.Criteria = "[RowStatus] > 0s And [IsActive] = True And [Code] <> 'NAAN_DEFAULT' And [AccountingPeriodTypeId.IsDefault] = True"; } }
private void InitializeTenant(AccountingPeriodType accountingPeriodType) { var connString = TestUtilities.GetConnectionString(); using (var connection = new NpgsqlConnection(connString)) { _tenantId = connection.QueryFirstOrDefault <int>(@" INSERT INTO ""Tenant"" ( ""Name"", ""AccountingPeriodType"" ) VALUES ( 'Unit Testing, Inc.', @accountingPeriodType ) RETURNING ""Id"";", new { accountingPeriodType }); } }
protected void ASPxGridView1_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) { CriteriaOperator criteria_0 = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_1 = new BinaryOperator("IsDefault", true, BinaryOperatorType.Equal); CriteriaOperator criteria = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1); AccountingPeriodType type = session.FindObject <AccountingPeriodType>(criteria); if (type != null) { e.NewValues["AccountingPeriodTypeId!Key"] = type.AccountingPeriodTypeId; } e.NewValues["IsDefault"] = false; }
protected void GridACCPeriodType_RowUpdating1(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { e.Cancel = true; //check Name if (!e.OldValues["Name"].Equals(e.NewValues["Name"])) { if (bo.checkAccountingPeriodType_Name(uow, e.NewValues["Name"].ToString().Trim())) { e.Cancel = true; throw new Exception(String.Format("Lỗi trùng Tên Chu Kỳ Thuế")); } } //end check name AccountingPeriodType AccPt = uow.GetObjectByKey <AccountingPeriodType>(Guid.Parse(e.Keys[0].ToString())); #region update IsDefautl if (e.NewValues["IsDefault"] == null) { e.NewValues["IsDefault"] = false; } bool IsDefault = bool.Parse(e.NewValues["IsDefault"].ToString()); if (IsDefault) { if (bo.changeIsDefaultAccountingPeriodType(uow)) { e.NewValues["IsDefault"] = true; } } #endregion AccPt.Name = e.NewValues["Name"].ToString(); AccPt.IsDefault = bool.Parse(e.NewValues["IsDefault"].ToString()); if (e.NewValues["Description"] == null) { e.NewValues["Description"] = ""; } AccPt.Description = e.NewValues["Description"].ToString(); uow.FlushChanges(); GridACCPeriodType.DataBind(); GridACCPeriodType.CancelEdit(); } catch (Exception) { e.Cancel = true; throw; } }
public bool checkAccountingPeriodType_Name(UnitOfWork session, string name) { AccountingPeriodType AccountingPeriodType_Name = session.FindObject <AccountingPeriodType>( CriteriaOperator.And( new BinaryOperator("Name", name, BinaryOperatorType.Equal), new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.Equal) )); if (AccountingPeriodType_Name != null) { return(true); } return(false); }
protected void GridACCPeriodType_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { try { e.Cancel = true; if (bo.checkAccountingPeriodType_Name(uow, e.NewValues["Name"].ToString().Trim())) { e.Cancel = true; throw new Exception(String.Format("Lỗi trùng Tên Chu Kỳ Thuế")); } else { AccountingPeriodType AccPT = new AccountingPeriodType(uow); #region Add IsDefault if (e.NewValues["IsDefault"] == null) { e.NewValues["IsDefault"] = false; } bool isDefault = bool.Parse(e.NewValues["IsDefault"].ToString()); if (isDefault) { if (bo.changeIsDefaultAccountingPeriodType(uow)) { e.NewValues["IsDefault"] = true; } } #endregion AccPT.Name = e.NewValues["Name"].ToString(); AccPT.IsDefault = bool.Parse(e.NewValues["IsDefault"].ToString()); AccPT.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE; if (e.NewValues["Description"] == null) { e.NewValues["Description"] = ""; } AccPT.Description = e.NewValues["Description"].ToString(); uow.FlushChanges(); GridACCPeriodType.DataBind(); GridACCPeriodType.CancelEdit(); } } catch (Exception) { e.Cancel = true; throw; } }
public AccountingPeriodType GetMinAccountingPeriodType(Session session) { AccountingPeriodType result = null; try { CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_IsDefault = new BinaryOperator("IsDefault", true, BinaryOperatorType.Equal); CriteriaOperator criteria = CriteriaOperator.And(criteria_IsDefault, criteria_RowStatus); result = session.FindObject <AccountingPeriodType>(criteria); } catch (Exception) { } return(result); }
public AccountingPeriod(int tenantId, AccountingPeriodType periodType, int year, byte month) { if (month < 1 || month > 12) { throw new ArgumentOutOfRangeException( nameof(month), $"'{nameof(month)}' must be a valid calendar month. {month} is not a valid value."); } if (periodType == AccountingPeriodType.Year && month != 12) { throw new ArgumentException( $"'{nameof(month)}' must be set to 12 to create a period of type '{nameof(AccountingPeriodType.Year)}'", nameof(month)); } if (periodType == AccountingPeriodType.Quarter && month % 3 != 0) { throw new ArgumentException( $"'{nameof(month)}' must be set to 3, 6, 9 or 12 to create a period of type '{nameof(AccountingPeriodType.Quarter)}'", nameof(month)); } PeriodType = periodType; TenantId = tenantId; Year = year; Month = month; Quarter = GetQuarter(month); var periodDate = new DateTime(year, month, 1); switch (periodType) { case AccountingPeriodType.Month: Name = $"{periodDate.ToString("MMMM")} {year}"; break; case AccountingPeriodType.Quarter: Name = $"{year} Q{Quarter}"; break; case AccountingPeriodType.Year: Name = year.ToString(); break; } }
protected void ASPxGridView2_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { if (Util.isExistXpoObject <AccountingPeriodType>("Name", (string)e.NewValues["Name"])) { CriteriaOperator criteria_0 = new BinaryOperator("Name", (string)e.NewValues["Name"], BinaryOperatorType.Equal); CriteriaOperator criteria_1 = new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_2 = new BinaryOperator("AccountingPeriodTypeId", e.Keys[0], BinaryOperatorType.NotEqual); CriteriaOperator criteria = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1, criteria_2); AccountingPeriodType type = session.FindObject <AccountingPeriodType>(criteria); if (type != null) { e.Cancel = true; throw (new Exception("Trùng tên thể loại chu kì")); } } if (e.NewValues["IsDefault"] == null) { e.NewValues["IsDefault"] = false; } if ((bool)e.NewValues["IsDefault"] == true) { CriteriaOperator criteria = new BinaryOperator("IsDefault", true, BinaryOperatorType.Equal); AccountingPeriodType type = session.FindObject <AccountingPeriodType>(criteria); if (type != null) { if (AccountingPeriodTypeBO.IsUsedAccoutingPeriodType(session, type.AccountingPeriodTypeId)) { ASPxGridView2.CancelEdit(); throw new Exception("Loại chu kì nhỏ nhất " + type.Name + " đang được sử dụng nên không thể thay đổi"); } type.IsDefault = false; type.Save(); } } else { if (e.OldValues["IsDefault"].ToString() == "True") { e.Cancel = true; ASPxGridView2.CancelEdit(); throw (new Exception("Phải luôn có 1 thể loại chu kì nhỏ nhất")); } } }
protected void cp_Grid1_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) { try { AccountingPeriodType type = session.GetObjectByKey <AccountingPeriodType>(Guid.Parse(e.Parameter.ToString())); ASPxCallbackPanel cp_Grid = sender as ASPxCallbackPanel; ASPxGridLookup grid = cp_Grid.FindControl("GridUnderPeriod") as ASPxGridLookup; if (type.IsDefault == true) { XPOAccountingPeriodLookup.Criteria = "[RowStatus] > 0s And [IsActive] = True And [IsActive] <> True And [Code] <> 'NAAN_DEFAULT' And [AccountingPeriodTypeId.IsDefault] = True"; grid.GridView.DataBind(); } else { XPOAccountingPeriodLookup.Criteria = "[RowStatus] > 0s And [IsActive] = True And [Code] <> 'NAAN_DEFAULT' And [AccountingPeriodTypeId.IsDefault] = True"; grid.GridView.DataBind(); } } catch (Exception) { } }
public async Task <AccountingPeriod> FetchOrCreateAccountingPeriodAsync( int tenantId, AccountingPeriodType periodType, DateTime date) { switch (periodType) { case AccountingPeriodType.Month: return(await FetchOrCreateMonthlyAccountingPeriodAsync(tenantId, date.Year, (byte)date.Month)); case AccountingPeriodType.Quarter: var quarter = AccountingPeriod.GetQuarter((byte)date.Month); return(await FetchOrCreateQuarterlyAccountingPeriodAsync(tenantId, date.Year, quarter)); case AccountingPeriodType.Year: return(await FetchOrCreateYearlyAccountingPeriodAsync(tenantId, date.Year)); default: throw new ArgumentOutOfRangeException( nameof(periodType), $"{periodType} is not a valid value for '${nameof(periodType)}'"); } }
public void Clear <T>(Session session) { AccountingPeriodType type = session.GetObjectByKey <AccountingPeriodType>(Guid.Parse("7ad4ca8c-898d-4850-89ce-86b4d70e50b8")); }
protected void treelistACCPeriod_NodeInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { try { e.Cancel = true; ASPxTreeList treelist = sender as ASPxTreeList; object keyValue = GetMasterRowKeyValue(treelist); AccountingPeriodType AccPTypeId = uow.GetObjectByKey <AccountingPeriodType>(Guid.Parse(keyValue.ToString())); if (AccPTypeId == null) { throw new Exception(String.Format("AccountingPeriodType is not exist in System")); } if (bo.checkAccountingPeriod_Code(uow, e.NewValues["Code"].ToString().Trim(), AccPTypeId.AccountingPeriodTypeId.ToString())) { throw new Exception(String.Format("Lỗi Chu Kỳ Đã Có")); } else { AccountingPeriod ap = new AccountingPeriod(uow); #region add parentACCPeriodId string parentKeyStr = treelist.NewNodeParentKey.ToString(); if (parentKeyStr != null && !parentKeyStr.Equals(String.Empty)) { NAS.DAL.Accounting.Journal.AccountingPeriod parentAccPeriod = uow.GetObjectByKey <NAS.DAL.Accounting.Journal.AccountingPeriod>(Guid.Parse(parentKeyStr.ToString())); if (parentAccPeriod == null) { throw new Exception(String.Format("AccountingPeriod is not exist in system")); } // ap.ParentAccountingPeriodId = parentAccPeriod; } #endregion #region add AccountingPeriodTypeId if (AccPTypeId != null) { ap.AccountingPeriodTypeId = AccPTypeId; } #endregion #region add OrganizationId Organization org = uow.FindObject <Organization>(new BinaryOperator("Name", "QUASAPHARCO", BinaryOperatorType.Equal)); if (org != null) { ap.OrganizationId = org; } #endregion #region add IsActive if (e.NewValues["IsActive"] != null) { bool IsActive = bool.Parse(e.NewValues["IsActive"].ToString()); if (IsActive) { if (bo.changeIsActiveAccountingPeriod(uow))//, Guid.Parse(treelistCurrency.FocusedNode.Key.ToString()) { e.NewValues["IsActive"] = true; } if (bo.changeIsDefaultAccountingPeriodType(uow)) { AccPTypeId.IsDefault = true; AccPTypeId.Save(); // bo.changeIsActiveParentInParentAccP(uow, Guid.Parse(parentKeyStr.ToString()), IsActive); } } else { e.NewValues["IsActive"] = false; } ap.IsActive = bool.Parse(e.NewValues["IsActive"].ToString()); } #endregion ap.Code = e.NewValues["Code"].ToString(); ap.FromDateTime = DateTime.Parse(e.NewValues["FromDateTime"].ToString()); ap.ToDateTime = DateTime.Parse(e.NewValues["ToDateTime"].ToString()); if (e.NewValues["Description"] == null) { e.NewValues["Description"] = ""; } ap.Description = e.NewValues["Description"].ToString(); ap.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE; uow.FlushChanges(); treelist.CancelEdit(); } GridACCPeriodType.DataBind(); treelist.JSProperties.Add("cpSaved", true); } catch (Exception) { e.Cancel = true; throw; } }
protected void treelistACCPeriod_NodeUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { e.Cancel = true; //CHECK CODE ASPxTreeList treelist = sender as ASPxTreeList; object keyValue = GetMasterRowKeyValue(treelist); AccountingPeriodType AccPTId = uow.GetObjectByKey <AccountingPeriodType>(Guid.Parse(keyValue.ToString())); if (AccPTId == null) { throw new Exception(String.Format("AccountingPeriodType is not exist in system")); } if (!e.OldValues["Code"].Equals(e.NewValues["Code"])) { if (bo.checkAccountingPeriod_Code(uow, e.NewValues["Code"].ToString().Trim(), AccPTId.AccountingPeriodTypeId.ToString())) { e.Cancel = true; throw new Exception(String.Format("Lỗi Chu Kỳ đã có")); } } //END CHECK CODE AccountingPeriod ap = uow.GetObjectByKey <AccountingPeriod>(Guid.Parse(e.Keys[0].ToString())); if (ap != null) { if (e.NewValues["IsActive"] != null) { bool IsActive = bool.Parse(e.NewValues["IsActive"].ToString()); if (IsActive) { if (bo.changeIsActiveAccountingPeriod(uow))//, Guid.Parse(treelistCurrency.FocusedNode.Key.ToString()) { ap.IsActive = true; } if (bo.changeIsDefaultAccountingPeriodType(uow)) { AccPTId.IsDefault = true; AccPTId.Save(); //if (ap.ParentAccountingPeriodId != null) //{ // Guid parentID = Guid.Parse(ap.ParentAccountingPeriodId.AccountingPeriodId.ToString()); // bo.changeIsActiveParentInParentAccP(uow, parentID, IsActive); //} } } else { ap.IsActive = false; } } if (e.NewValues["Description"] == null) { e.NewValues["Description"] = ""; } ap.Description = e.NewValues["Description"].ToString(); ap.Code = e.NewValues["Code"].ToString(); ap.FromDateTime = DateTime.Parse(e.NewValues["FromDateTime"].ToString()); ap.ToDateTime = DateTime.Parse(e.NewValues["ToDateTime"].ToString()); uow.FlushChanges(); } treelist.CancelEdit(); GridACCPeriodType.DataBind(); treelist.JSProperties.Add("cpSaved", true); } catch (Exception) { e.Cancel = true; throw; } }
/// <summary> /// Instantiate a new Tenant, specifying the Tenant's preferred Accounting Period Type /// </summary> /// <param name="name"></param> /// <param name="accountingPeriodType"></param> public Tenant(string name, AccountingPeriodType accountingPeriodType) { Name = name; AccountingPeriodType = accountingPeriodType; }
public static AccountingPeriod GetAccountingPeriod(Session session, DateTime Date) { //CriteriaOperator criteria_0 = new BinaryOperator("Rowstatus", 0, BinaryOperatorType.Greater); //CriteriaOperator criteria_1 = new BinaryOperator("IsDefault", true, BinaryOperatorType.Greater); //CriteriaOperator criteria = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1); //AccountingPeriodType periodType = session.FindObject<AccountingPeriodType>(criteria); //AccountingPeriod accountingPeriod = null; //criteria_1 = new BinaryOperator("IsActive", true, BinaryOperatorType.Equal); //CriteriaOperator criteria_2 = new BinaryOperator("FromDateTime", issuedDate, BinaryOperatorType.LessOrEqual); //CriteriaOperator criteria_3 = new BinaryOperator("ToDateTime", issuedDate, BinaryOperatorType.GreaterOrEqual); //CriteriaOperator criteria_4 = new BinaryOperator("AccountingPeriodTypeId", periodType, BinaryOperatorType.Equal); //criteria = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1, criteria_2, criteria_3, criteria_4); //XPCollection<AccountingPeriod> accountingPeriodCollection = new XPCollection<AccountingPeriod>(criteria); //accountingPeriod = accountingPeriodCollection.FirstOrDefault(); //return accountingPeriod; AccountingPeriod accountingPeriod = null; try { //CriteriaOperator criteria_0 = new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater); //CriteriaOperator criteria_1 = new BinaryOperator("IsActive", true, BinaryOperatorType.Equal); //CriteriaOperator criteria_2 = new BinaryOperator("FromDateTime", issuedDate, BinaryOperatorType.LessOrEqual); //CriteriaOperator criteria_3 = new BinaryOperator("ToDateTime", issuedDate, BinaryOperatorType.GreaterOrEqual); //CriteriaOperator criteria_4 = new BinaryOperator(new OperandProperty("AccountingPeriodTypeId.IsDefault"), new OperandValue(true), BinaryOperatorType.Equal); //CriteriaOperator criteria = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1, criteria_2, criteria_3, criteria_4); //XPCollection<AccountingPeriod> accountingPeriodCollection = new XPCollection<AccountingPeriod>(session, criteria); //accountingPeriod = accountingPeriodCollection.FirstOrDefault(); //issuedDate = DateTime.ParseExact(issuedDate.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); AccountingPeriodTypeBO typeBO = new AccountingPeriodTypeBO(); AccountingPeriodType minAccountingPeriodType = typeBO.GetMinAccountingPeriodType(session); if (minAccountingPeriodType == null) { return(null); } CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_IsActive = new BinaryOperator("IsActive", true, BinaryOperatorType.Equal); CriteriaOperator criteria_FromDate = new BinaryOperator("FromDateTime", Date, BinaryOperatorType.LessOrEqual); CriteriaOperator criteria_ToDate = new BinaryOperator("ToDateTime", Date, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_Type = new BinaryOperator("AccountingPeriodTypeId", minAccountingPeriodType, BinaryOperatorType.Equal); CriteriaOperator criteria = CriteriaOperator.And(criteria_FromDate, criteria_IsActive, criteria_RowStatus, criteria_ToDate, criteria_Type); XPCollection <AccountingPeriod> AccountingPeriodCol = new XPCollection <AccountingPeriod>(session, criteria); if (AccountingPeriodCol == null) { return(null); } if (AccountingPeriodCol.Count == 0) { return(null); } accountingPeriod = AccountingPeriodCol.FirstOrDefault(); //XPQuery<AccountingPeriod> qr1 = new XPQuery<AccountingPeriod>(session); //var col = from r in qr1 // where r.RowStatus >= 1 // && r.FromDateTime <= Date // && r.ToDateTime >= Date // && r.AccountingPeriodTypeId == minAccountingPeriodType // select r; //if (col == null) return null; //if (col.Count() == 0) return null; //accountingPeriod = col.FirstOrDefault() as AccountingPeriod; } catch (Exception) { throw; } return(accountingPeriod); }