public BillSearchReportModel getModel() { BillSearchReportModel model = new BillSearchReportModel(); model.getPaymentType = getPaymentType(); model.getBillingType = getBillingType(); return(model); }
public BillSearchReportModel getSearchModel(BillSearchReportModel m) { BillSearchReportModel model = new BillSearchReportModel(); DataSet ds = new DataSet(); string datefrom; string dateto; if (m.DateTo.HasValue) { dateto = Convert.ToDateTime(m.DateTo).AddDays(1).ToShortDateString(); } else { dateto = string.Empty; } if (m.DateFrom.HasValue) { datefrom = Convert.ToDateTime(m.DateFrom).ToShortDateString(); } else { datefrom = string.Empty; } ds = excuteSp(m.OrderType == null ? string.Empty : m.OrderType, m.PaymentType == null ? string.Empty : m.PaymentType, m.BillNo == null ? 0 : Convert.ToInt32(m.BillNo), datefrom, dateto); if (ds.Tables.Count > 0) { string s = GetJson(ds.Tables[0]); model.allbill = s; } model.getPaymentType = getPaymentType(); model.getBillingType = getBillingType(); model.GetallVats = getAllvats(); return(model); }
public ActionResult ExportToexcel(BillSearchReportModel m) { DataSet ds = new DataSet(); string datefrom; string dateto; if (m.DateTo.HasValue) { dateto = Convert.ToDateTime(m.DateTo).AddDays(1).ToShortDateString(); } else { dateto = string.Empty; } if (m.DateFrom.HasValue) { datefrom = Convert.ToDateTime(m.DateFrom).ToShortDateString(); } else { datefrom = string.Empty; } ds = bill.excuteSp(m.OrderType == string.Empty ? m.OrderType : m.OrderType, m.PaymentType == string.Empty ? m.PaymentType : m.PaymentType, m.BillNo == null ? 0 : Convert.ToInt32(m.BillNo), datefrom, dateto); GridView gv = new GridView(); DataTable tb = new DataTable(); if (ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=NibsReport.xls"); Response.ContentType = "application/ms-excel"; Response.Charset = ""; HttpContext.Response.Write("<Table border='1' bgColor='#ffffff' " + "borderColor='#000000' cellSpacing='0' cellPadding='0' " + "style='font-size:10.0pt; font-family:Calibri; background:white;'>"); HttpContext.Response.Write("<TR>"); for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { HttpContext.Response.Write("<TH>" + dt.Columns[i].ColumnName + "</TH>"); } HttpContext.Response.Write("</TR>"); foreach (DataRow item in dt.Rows) { HttpContext.Response.Write("<TR>"); for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { HttpContext.Response.Write("<TD>" + item[i].ToString() + "</TD>"); } HttpContext.Response.Write("</TR>"); } HttpContext.Response.Write("<TR>"); HttpContext.Response.Write("<TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD>"); HttpContext.Response.Write("</TR>"); HttpContext.Response.Write("<TR>"); HttpContext.Response.Write("<TD><b>Sum</b></TD><TD></TD><TD></TD><TD></TD><TD></TD>"); for (int i = 5; i < ds.Tables[0].Columns.Count; i++) { string sum = ""; sum = dt.Compute("SUM([" + dt.Columns[i].ToString() + "])", "").ToString(); HttpContext.Response.Write("<TD><b>" + sum + "</b></TD>"); } HttpContext.Response.Write("</TR>"); } //gv.DataSource = ds; //gv.DataBind(); //Response.ClearContent(); //Response.Buffer = true; //Response.AddHeader("content-disposition", "attachment; filename=Report.xls"); //Response.ContentType = "application/ms-excel"; //Response.Charset = ""; //StringWriter sw = new StringWriter(); //HtmlTextWriter htw = new HtmlTextWriter(sw); //gv.RenderControl(htw); //Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return(RedirectToAction("Index")); }
public ActionResult Index(BillSearchReportModel model) { return(View(bill.getSearchModel(model))); }