public static List <StationeryCollectionList> getStationeryCollectionList(string deptId) { List <StationeryCollectionList> stationeryCollectionLists = new List <StationeryCollectionList>(); List <Disbursement> disbursements = getDisbursement(deptId); int no = 1; for (int i = 0; i < disbursements.Count; i++) { StationeryCollectionList stationeryCollectionList = new StationeryCollectionList(); stationeryCollectionList.No = no; stationeryCollectionList.DisbursementId = disbursements[i].DisbursementId; if (disbursements[i].DateDisbursed != null) { DateTime dateTime = (DateTime)disbursements[i].DateDisbursed; string dateString = dateTime.ToString("dd MMM yyyy"); stationeryCollectionList.DateOfDisbursement = dateString; } stationeryCollectionList.Status = disbursements[i].Status; stationeryCollectionList.Remark = disbursements[i].Remark; stationeryCollectionLists.Add(stationeryCollectionList); no++; } return(stationeryCollectionLists); }
public static List <StationeryCollectionList> getStationeryCollectionListByYear(String year, String deptId) { List <StationeryCollectionList> stationeryCollectionLists = new List <StationeryCollectionList>(); List <Disbursement> disbursements = getDisbursement(deptId); int no = 1; for (int i = 0; i < disbursements.Count; i++) { StationeryCollectionList stationeryCollectionList = new StationeryCollectionList(); stationeryCollectionList.No = no; //DateTime dateTime = (DateTime)disbursements[i].DateDisbursed; //string currentYear = dateTime.ToString("yyyy"); string currentYear = (disbursements[i].DateDisbursed != null) ? ((DateTime)disbursements[i].DateDisbursed).ToString("yyyy") : ""; if (currentYear == year) { stationeryCollectionList.DisbursementId = disbursements[i].DisbursementId; string dateString = (disbursements[i].DateDisbursed != null) ? ((DateTime)disbursements[i].DateDisbursed).ToString("dd MMM yyyy") : ""; stationeryCollectionList.DateOfDisbursement = dateString; stationeryCollectionList.Status = disbursements[i].Status; stationeryCollectionList.Remark = disbursements[i].Remark; stationeryCollectionLists.Add(stationeryCollectionList); no++; } } return(stationeryCollectionLists); }