public static bool BenifitCalculationOfPeriod(GLBenifitCalcsInfo benifitInfo) { if (benifitInfo.FK_GEPeriodID.HasValue == false || benifitInfo.GLBenifitCalcID == Guid.Empty) { return(false); } GEPeriodsInfo period = new GEPeriodsController().GetObjectByID(benifitInfo.FK_GEPeriodID.Value) as GEPeriodsInfo; if (period == null) { return(false); } DateTime startDate = new DateTime(period.Year.Value, period.Month.Value, 1); DateTime endDate = startDate.AddMonths(1).AddSeconds(-10); BenifitCalculationOfRange(benifitInfo, startDate, endDate); if (BusinessObjectHelper.IsModifiedObject(benifitInfo)) { new GLBenifitCalcsController().UpdateObject(benifitInfo); return(true); } return(false); }
void btnRecalcInventory_Click(object sender, EventArgs e) { Control period = UIManager.GetControl("period"); Control stock = UIManager.GetControl("stock"); if (period != null && stock != null && (period as ABCPeriodEdit).EditValue != null && (stock as ABCSearchControl).EditValue != null) { Guid periodID = ABCHelper.DataConverter.ConvertToGuid((period as ABCPeriodEdit).EditValue); Guid stockID = ABCHelper.DataConverter.ConvertToGuid((stock as ABCSearchControl).EditValue); if (periodID != Guid.Empty && stockID != Guid.Empty) { GEPeriodsInfo preriodInfo = new GEPeriodsController().GetObjectByID(periodID) as GEPeriodsInfo; GECompanyUnitsInfo stockInfo = new GECompanyUnitsController().GetObjectByID(stockID) as GECompanyUnitsInfo; if (preriodInfo != null && stockInfo != null) { ABCHelper.ABCWaitingDialog.Show("", String.Format("Tính tồn kho tháng {0}/{1} {2}. . .!", preriodInfo.Month, preriodInfo.Year, stockInfo.No)); InventoryProvider.PeriodEndingProcessing(periodID, stockID); if (this.DataManager.DataObjectsList.ContainsKey((stock as ABCSearchControl).DataSource)) { this.DataManager.DataObjectsList[(stock as ABCSearchControl).DataSource].Refresh(); } ABCHelper.ABCWaitingDialog.Close(); } } } }
public static void GeneratePeriods( ) { GEPeriodsController periodCtrl = new GEPeriodsController(); for (int year = ABCApp.ABCDataGlobal.WorkingDate.Year; year <= ABCApp.ABCDataGlobal.WorkingDate.Year + 1; year++) { String strQuery = String.Format(@"SELECT COUNT(*) FROM GEPeriods WHERE Year = {0}", year); object objAmt = BusinessObjectController.GetData(strQuery); if (objAmt == null || objAmt == DBNull.Value || Convert.ToInt32(objAmt) != 12) { strQuery = String.Format(@"DELETE FROM GEPeriods WHERE Year = {0}", year); BusinessObjectController.RunQuery(strQuery); for (int i = 1; i <= 12; i++) { GEPeriodsInfo period = new GEPeriodsInfo(); period.Month = i; period.Year = year; period.Period = new DateTime(period.Year.Value, period.Month.Value, 1); if (i >= 10) { period.No = String.Format("Tháng {0}/{1}", period.Month.Value, period.Year.Value); } else { period.No = String.Format("Tháng 0{0}/{1}", period.Month.Value, period.Year.Value); } period.Closed = false; periodCtrl.CreateObject(period); } } } }
public static DateTime GetFirstDay(Guid periodID) { GEPeriodsInfo period = new GEPeriodsController().GetObjectByID(periodID) as GEPeriodsInfo; if (period != null) { return(new DateTime(period.Year.Value, period.Month.Value, 1)); } return(DateTime.MinValue); }
public static int GetYear(Guid periodID) { GEPeriodsInfo currentPeriod = new GEPeriodsController().GetObjectByID(periodID) as GEPeriodsInfo; if (currentPeriod == null && currentPeriod.Year.HasValue) { return(0); } return(currentPeriod.Year.Value); }
public static Guid GetPeriod(Guid currentPeriodID, int index) { GEPeriodsInfo currentPeriod = new GEPeriodsController().GetObjectByID(currentPeriodID) as GEPeriodsInfo; if (currentPeriod == null) { return(Guid.Empty); } DateTime dtNext = new DateTime(currentPeriod.Year.Value, currentPeriod.Month.Value, 1).AddMonths(index); return(GetPeriod(dtNext.Year, dtNext.Month)); }
void btnRecalcInventory_Click(object sender, EventArgs e) { Control period = UIManager.GetControl("period"); if (period != null && (period as ABCPeriodEdit).EditValue != null) { Guid periodID = ABCHelper.DataConverter.ConvertToGuid((period as ABCPeriodEdit).EditValue); if (periodID != Guid.Empty) { GEPeriodsInfo preriodInfo = new GEPeriodsController().GetObjectByID(periodID) as GEPeriodsInfo; if (preriodInfo != null) { ABCHelper.ABCWaitingDialog.Show("", String.Format("Tính tồn kho tháng {0}/{1}. . .!", preriodInfo.Month, preriodInfo.Year)); InventoryProvider.PeriodEndingProcessing(periodID); DoAction(ABCCommon.ABCScreenAction.Refresh, false); ABCHelper.ABCWaitingDialog.Close(); } } } }
public static Guid GetPeriod(int year, int month) { if (year < 2000 || month <= 0) { return(Guid.Empty); } String strQuery = String.Format(@"SELECT * FROM GEPeriods WHERE Year = {0} AND Month = {1} ", year, month); GEPeriodsInfo period = new GEPeriodsController().GetObject(strQuery) as GEPeriodsInfo; if (period != null) { return(period.GEPeriodID); } else { period = new GEPeriodsInfo(); period.Month = month; period.Year = year; period.Period = new DateTime(period.Year.Value, period.Month.Value, 1); if (month >= 10) { period.No = String.Format("Tháng {0}/{1}", period.Month.Value, period.Year.Value); } else { period.No = String.Format("Tháng 0{0}/{1}", period.Month.Value, period.Year.Value); } period.Closed = false; new GEPeriodsController().CreateObject(period); return(period.GetID()); } return(Guid.Empty); }
public static void BenifitCalculate( ) { object objTime = BusinessObjectController.GetData(String.Format(@"SELECT MAX(JournalDate) FROM GLJournalEntrys WHERE ABCStatus ='Alive' AND (EntryType IS NULL OR EntryType != '{0}')", ABCCommon.ABCConstString.EntryTypePeriodEnding)); DateTime currentPeriod = Convert.ToDateTime(objTime.ToString()); if (currentPeriod == null || currentPeriod.Year <= 1000) { return; } AccountForReCalcList.Clear(); GLBenifitCalcsController benifitCalcCtrl = new GLBenifitCalcsController(); List <BusinessObject> lstPeriods = new GEPeriodsController().GetListAllObjects(); foreach (GEPeriodsInfo period in lstPeriods) { if (period.Period.HasValue == false || period.Closed) { continue; } GLBenifitCalcsInfo benifitInfo = benifitCalcCtrl.GetObjectByColumn("FK_GEPeriodID", period.GEPeriodID) as GLBenifitCalcsInfo; if (benifitInfo == null) { DateTime dtStart = new DateTime(SystemProvider.AppConfig.StartDate.Value.Year, SystemProvider.AppConfig.StartDate.Value.Month, 1); if (dtStart <= period.Period.Value && period.Period.Value <= currentPeriod) { benifitInfo = new GLBenifitCalcsInfo(); benifitInfo.FK_GEPeriodID = period.GEPeriodID; benifitInfo.Month = period.Month; benifitInfo.Year = period.Year; benifitInfo.Period = period.Period; benifitInfo.ApprovalStatus = ABCCommon.ABCConstString.ApprovalTypeNew; benifitCalcCtrl.CreateObject(benifitInfo); if (BenifitCalculationOfPeriod(benifitInfo)) { if (period.Period.Value.Year != currentPeriod.Year || period.Period.Value.Month != currentPeriod.Month) { PostBenifitCalculation(benifitInfo); } } } } else { if (period.Period.Value.Year == currentPeriod.Year && period.Period.Value.Month == currentPeriod.Month) { BenifitCalculationOfPeriod(benifitInfo); } else { if (period.Period.Value.AddMonths(1).Year == currentPeriod.Year && period.Period.Value.AddMonths(1).Month == currentPeriod.Month) { if (BenifitCalculationOfPeriod(benifitInfo) || benifitInfo.ApprovalStatus != ABCCommon.ABCConstString.ApprovalTypeApproved) { PostBenifitCalculation(benifitInfo); } } } } } foreach (Guid iAccountID in AccountForReCalcList) { AccountingProvider.CalculateAccount(iAccountID); } DataCachingProvider.RefreshLookupTable("GLJournalVouchers"); }