private void ExportDetails() { try { DataRow dr; BuildTable(); string filePath = ""; string fromDate = dpFrom.Value.ToShortDateString(); string toDate = dpTo.Value.ToShortDateString(); dtTeam = Teams(); for (int i = 0; i <= dtTeam.Rows.Count - 1; i++) { dr = dtResult.NewRow(); int teamId = Convert.ToInt32(dtTeam.Rows[i]["T_ID"]); string teamName = dtTeam.Rows[i]["T_TeamName"].ToString(); dr["TeamName"] = teamName; dr["DateRange"] = fromDate + " - " + toDate; int totalWorkingDays = GetNumberOfWorkingDays(dpFrom.Value, dpTo.Value); dt = new System.Data.DataTable(); dt = GetHours(teamId, fromDate, toDate); if (dt.Rows.Count > 0) { dr["BillableHours"] = dt.Rows[0]["Billable Hours"]; dr["PTOs"] = dt.Rows[0]["PTO"]; dr["EEA"] = dt.Rows[0]["EEA"]; dr["Meeting"] = dt.Rows[0]["Meeting"]; dr["Nontask"] = dt.Rows[0]["Nontask"]; dr["Others"] = dt.Rows[0]["Others"]; dr["Available Time"] = dt.Rows[0]["Available Time"]; } dr["WorkingHours"] = totalWorkingDays * 8; dt = new System.Data.DataTable(); dt = GetUsersCount(teamId, fromDate, toDate); if (dt.Rows.Count > 0) { dr["UserCount"] = dt.Rows[0]["UsersCount"]; } dtResult.Rows.Add(dr); } if (rbWithMgr.Checked) { filePath = "D:\\Util\\" + dpFrom.Value.ToString("MM-dd-yyyy") + "-" + dpTo.Value.ToString("MM-dd-yyyy") + ".csv"; } else { filePath = "D:\\Util\\" + dpFrom.Value.ToString("MM-dd-yyyy") + "-" + dpTo.Value.ToString("MM-dd-yyyy") + "(WithoutManager).csv"; } CSVUtility.ToCSV(dtResult, filePath); MessageBox.Show("RU Report Generated"); } catch (Exception ex) { lblStatus.Text = ex.Message; } }