public int CountVitalItemsStockOutForAllStore(int month, int year)
 {
     Items itm = new Items();
     DataTable dtItem = itm.GetVitalItems();
     GeneralInfo pipline = new GeneralInfo();
     pipline.LoadAll();
     int min = pipline.Min;
     int max = pipline.Max;
     double eop = pipline.EOP;
     int count = 0;
     Balance bal = new Balance();
     foreach (DataRow dr in dtItem.Rows)
     {
         Int64 AMC = bal.CalculateAMCAll(Convert.ToInt32(dr["ID"]), month, year);
         Int64 minCon = AMC * min;
         Int64 maxCon = AMC * max;
         double eopCon = AMC * (eop + 0.25);
         Int64 SOH = bal.GetSOHForAllStore(Convert.ToInt32(dr["ID"]), month, year);
         decimal MOS = (AMC != 0) ? (SOH / AMC) : 0;
         Int64 reorder = (maxCon > SOH) ? maxCon - SOH : 0;
         if (SOH == 0)
             count++;
         //string status = (SOH <= eopCon && SOH > 0) ? "Near EOP" : ((SOH > maxCon) ? "Excess Stock" : ((SOH <= 0) ? "Stock Out" : "Normal"));
     }
     return count;
 }
 public int CountBelowMin(int storeId, int month, int year)
 {
     Items itm = new Items();
     DataTable dtItem = itm.GetAllItems(1);
     GeneralInfo pipline = new GeneralInfo();
     pipline.LoadAll();
     int min = pipline.Min;
     int max = pipline.Max;
     double eop = pipline.EOP;
     int count = 0;
     Balance bal = new Balance();
     if (storeId == 0)
     {
         count += (from DataRow dr in dtItem.Rows
                   let AMC = bal.CalculateAMCAll(Convert.ToInt32(dr["ID"]), month, year)
                   let MinCon = AMC * min
                   let maxCon = AMC * max
                   let eopCon = AMC * (eop + 0.25)
                   let SOH = bal.GetSOHAll(Convert.ToInt32(dr["ID"]), month, year)
                   let MOS = (AMC != 0) ? (SOH / AMC) : 0
                   let reorder = (maxCon > SOH) ? maxCon - SOH : 0
                   where SOH > eopCon && (SOH <= MinCon)
                   select MinCon).Count();
     }
     else
     {
         count += (from DataRow dr in dtItem.Rows
                   let AMC = bal.CalculateAMC(Convert.ToInt32(dr["ID"]), storeId, month, year)
                   let MinCon = AMC * min
                   let maxCon = AMC * max
                   let eopCon = AMC * (eop + 0.25)
                   let SOH = bal.GetSOH(Convert.ToInt32(dr["ID"]), storeId, month, year)
                   let MOS = (AMC != 0) ? (SOH / AMC) : 0
                   let reorder = (maxCon > SOH) ? maxCon - SOH : 0
                   where SOH > eopCon && (SOH <= MinCon)
                   select MinCon).Count();
     }
     return count;
 }