//DU Info public Int64 CalculateDUAMC(int itemId, int receivingUnit, int month, int year, int LastSOH) { GeneralInfo info = new GeneralInfo(); info.LoadAll(); int range = 3; try { range = info.DUAMCRange; } catch { } Int64 cons = 0; IssueDoc iss = new IssueDoc(); int yr = (month > 10) ? year + 1 : year; DateTime dt1 = new DateTime(yr, month, DateTime.DaysInMonth(yr, month)); DateTime dt2 = dt1.AddMonths(-range); int mon = dt2.Month; range = iss.GetAvailableNoOfMonthsDU(itemId, receivingUnit, dt2, dt1); yr = (mon > 10) ? year + 1 : year; cons = iss.GetDUConsumptionAfterMonth(itemId, receivingUnit, mon, yr); //for (int m = mon+1; m < month; m++ ) //{ // yr = (m > 10) ? year - 1 : year; // cons = cons + iss.GetDUConsumptionByMonth(itemId, receivingUnit, m, yr); //} yr = (month > 10) ? year + 1 : year; //yr = (month > 10) ? year : year + 1 ; //Int64 lastIss = iss.GetDUIssueByMonth(itemId, receivingUnit, month, yr); Int64 lastIss = iss.GetDULastIssueQty(itemId, receivingUnit); // lastIss = ((lastIss > 0)? (lastIss - LastSOH) : lastIss ); cons = cons + lastIss - LastSOH; //cons = cons - LastSOH; cons = ((cons > 0) ? cons : 0); Int64 AMC = cons / range; return AMC; }