using System; using System.Data; using System.Text; using Swift.DAL.BL.Remit.Transaction; using Swift.web.Library; namespace Swift.web.Responsive.Reports.UserWise { public partial class View : System.Web.UI.Page { private const string ViewFunctionId = "40121400"; private readonly RemittanceLibrary _sl = new RemittanceLibrary(); TranReportDao _rptDao = new TranReportDao(); protected void Page_Load(object sender, EventArgs e) { Authenticate(); string reportName = GetStatic.ReadQueryString("reportName", "").ToLower(); string mode = GetStatic.ReadQueryString("mode", "").ToLower(); if (mode == "download") { string format = GetStatic.ReadQueryString("format", "xls"); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "inline; filename=" + reportName + "." + format); exportDiv.Visible = false; } if (reportName == "uwdetail") LoadReport(); else if (reportName == "uwsummary") LoadReportSummary(); else if (reportName == "agentuserwise") LoadReportAgentUserWise(); else if (reportName == "detail") ShowUserWiseTranDetail(); } private void Authenticate() { _sl.CheckAuthentication(ViewFunctionId); } private void PrintFilter(ref DataTable filter) { var html = new StringBuilder("Filter Applied:
"); foreach (DataRow dr in filter.Rows) { html.Append(dr[0] + "=" + dr[1] + " | "); } filters.InnerHtml = html.ToString(); } private void PrintHead(ref DataTable reportHead) { var html = new StringBuilder(""); foreach (DataRow dr in reportHead.Rows) html.Append(dr[0].ToString()); head.InnerHtml = html.ToString(); } private string GetAgentId() { return GetStatic.ReadQueryString("agent", ""); } private string GetBranchId() { return GetStatic.ReadQueryString("branch", ""); } private string GetUserName() { return GetStatic.ReadQueryString("userName", ""); } private string GetFromDate() { return GetStatic.ReadQueryString("fromDate", ""); } private string GetToDate() { return GetStatic.ReadQueryString("toDate", ""); } private string GetFlag() { return GetStatic.ReadQueryString("flag", ""); } private string GetRecCountry() { return GetStatic.ReadQueryString("rCountry", ""); } private void LoadReport() { head.InnerHtml = ""; var ds = _rptDao.UserWiseReport("detail", GetStatic.GetCountry(), GetStatic.GetAgent(), GetBranchId(), GetUserName(), GetFromDate(), GetToDate(), GetRecCountry(), GetStatic.GetUser()); var dtHead = ds.Tables[0]; var dt = ds.Tables[1]; var filter = ds.Tables[3]; var reportHead = ds.Tables[4]; PrintFilter(ref filter); PrintHead(ref reportHead); int cols = dt.Columns.Count; StringBuilder str = new StringBuilder(""); str.Append(""); str.AppendLine(""); for (int i = 1; i < cols - 1; i++) { str.AppendLine(""); } str.AppendLine(""); if (dtHead.Rows.Count > 0) { double[] total = new double[9]; foreach (DataRow dr in dtHead.Rows) { str.AppendLine(PrintRegionBody(ref dt, dr[0].ToString(), ref total)); } str.Append(""); str.Append(""); for (int i = 2; i < 9; i++) { if (i == 2 || i == 4 || i == 6 || i == 8) str.Append(""); else if (i == 3 || i == 7) str.Append(""); else str.Append(""); } str.Append(""); } else { str.Append(""); str.Append(""); str.Append(""); } rptDiv.InnerHtml = str.ToString(); } private string PrintRegionBody(ref DataTable dt, string regionName, ref Double[] total) { double[] subTotal = new double[9]; DataRow[] rows = dt.Select("HEAD='" + regionName + "'"); var html = new StringBuilder(); html.Append(""); html.Append(""); html.Append(""); html.Append(""); int bag_sno = 0; foreach (DataRow dr in rows) { for (int i = 2; i < 9; i++) { var data = GetStatic.ParseDouble(dr[i].ToString()); subTotal[i] += data; total[i] += data; } html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); } html.Append(""); html.Append(""); for (int i = 2; i < 9; i++) { if (i == 2 || i == 4 || i == 6 || i == 8) html.Append(""); else if (i == 3 || i == 7) html.Append(""); else html.Append(""); } html.Append(""); return html.ToString(); } private void LoadReportSummary() { var ds = _rptDao.UserWiseReport("summary", GetStatic.GetCountry(), GetStatic.GetAgent(), GetBranchId(), GetUserName(), GetFromDate(), GetToDate(), GetRecCountry(), GetStatic.GetUser()); var dt = ds.Tables[0]; var filter = ds.Tables[2]; var reportHead = ds.Tables[3]; PrintFilter(ref filter); PrintHead(ref reportHead); int cols = dt.Columns.Count; double[] sum = new double[cols]; StringBuilder str = new StringBuilder("
S.N." + dt.Columns[i].ColumnName + "
Grand Total
" + total[i].ToString() + "" + total[i].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(total[i].ToString())) + "
No Record Found!
User Name: " + regionName + "
" + (++bag_sno).ToString() + "" + dr["Branch"].ToString() + "" + dr["#Send Trans"].ToString() + "" + dr["Send Amount"].ToString() + "" + dr["#Paid Trans"].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(dr["Paid Amount"].ToString())) + "" + dr["#Approved Trans"].ToString() + "" + dr["Approved Amount"].ToString() + "" + dr["#Amendment Count"].ToString() + "
Sub Total
" + subTotal[i].ToString() + "" + subTotal[i].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(subTotal[i].ToString())) + "
"); str.AppendLine(""); for (int i = 0; i < cols; i++) { str.AppendLine(""); } str.AppendLine(""); if (dt.Rows.Count > 0) { int bag_sno = 0; foreach (DataRow row in dt.Rows) { str.Append(""); str.Append(""); for (int i = 0; i < cols; i++) { if (i > 0 && i < cols) { double currVal; double.TryParse(row[i].ToString(), out currVal); sum[i] += currVal; } if (i == 1 || i == 3 || i == 5 || i == 7) { str.Append(""); } else if (i == 2 || i == 6) { str.Append(""); } else if (i == 4) { str.Append(""); } else { str.Append(""); } } str.Append(""); } str.Append(""); str.Append(""); for (int i = 1; i < cols; i++) { if (i == 1 || i == 3 || i == 5 || i == 7) { str.Append(""); } else if (i == 2 || i == 6) { str.Append(""); } else if (i == 4) { str.Append(""); } } str.Append(""); } else { str.Append(""); str.Append(""); str.Append(""); } rptDiv.InnerHtml = str.ToString(); } private void LoadReportAgentUserWise() { var ds = _rptDao.GetUserWiseTransactionReport("A", GetStatic.GetUser(), GetFromDate(), GetToDate(), GetStatic.GetAgentId(), GetUserName()); var dt = ds.Tables[0]; var filter = ds.Tables[2]; var reportHead = ds.Tables[3]; PrintFilter(ref filter); PrintHead(ref reportHead); int cols = dt.Columns.Count; double[] sum = new double[cols]; StringBuilder str = new StringBuilder("
S.N." + dt.Columns[i].ColumnName + "
" + (++bag_sno).ToString() + "" + row[i].ToString() + "" + row[i].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(row[i].ToString())) + "" + row[i].ToString() + "
Total" + sum[i].ToString() + "" + sum[i].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(sum[i].ToString())) + "
No Record Found!
"); str.AppendLine(""); for (int i = 0; i < cols; i++) { str.AppendLine(""); } str.AppendLine(""); if (dt.Rows.Count > 0) { int bag_sno = 0; foreach (DataRow row in dt.Rows) { str.Append(""); str.Append(""); for (int i = 0; i < cols; i++) { if (i > 0 && i < cols) { double currVal; double.TryParse(row[i].ToString(), out currVal); sum[i] += currVal; } if (i == 1) { str.Append(""); //str.Append(""); } else if (i == 3) { str.Append(""); //str.Append(""); } else if (i == 2 || i == 4) { str.Append(""); } else { str.Append(""); } } str.Append(""); } str.Append(""); str.Append(""); for (int i = 1; i < cols; i++) { if (i == 1 || i == 3) { str.Append(""); } else { str.Append(""); } } str.Append(""); } else { str.Append(""); str.Append(""); str.Append(""); } rptDiv.InnerHtml = str.ToString(); } private void ShowUserWiseTranDetail() { var ds = _rptDao.GetUserWiseTransactionReport(GetFlag(), GetStatic.GetUser(), GetFromDate(), GetToDate(), GetAgentId(), GetUserName()); var dt = ds.Tables[0]; var filter = ds.Tables[2]; var reportHead = ds.Tables[3]; PrintFilter(ref filter); PrintHead(ref reportHead); int cols = dt.Columns.Count; double[] sum = new double[cols]; StringBuilder str = new StringBuilder("
S.N." + dt.Columns[i].ColumnName + "
" + (++bag_sno).ToString() + "" + row[i].ToString() + "" + row[i].ToString() + "" + row[i].ToString() + "" + row[i].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(row[i].ToString())) + "" + row[i].ToString() + "
Total" + sum[i].ToString() + "" + GetStatic.ParseMinusValue(GetStatic.ParseDouble(sum[i].ToString())) + "
No Record Found!
"); str.AppendLine(""); for (int i = 0; i < cols; i++) { str.AppendLine(""); } str.AppendLine(""); if (dt.Rows.Count > 0) { int bag_sno = 0; foreach (DataRow row in dt.Rows) { str.Append(""); str.Append(""); for (int i = 0; i < cols; i++) { str.Append(""); } str.Append(""); } } else { str.Append(""); str.Append(""); str.Append(""); } rptDiv.InnerHtml = str.ToString(); } } }
S.N." + dt.Columns[i].ColumnName + "
" + (++bag_sno).ToString() + "" + row[i].ToString() + "
No Record Found!