/* * protected void BtnDownLoadExcel_Click(object sender, EventArgs e) * { * * //다운로드 되도록 헤더 설정 * Response.Clear(); * Response.AddHeader("content-disposition", "attachment;filename=DataGrid.xls"); * Response.ContentType = "application/vnd.xls"; * * System.IO.StringWriter stringWriter = new System.IO.StringWriter(); * System.Web.UI.HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); * * //한글 정상표시되도록 * Response.Charset = "UTF-8"; * Response.ContentEncoding = System.Text.Encoding.Default; * * //페이징 되어있을경우 전체리스트가 출력되지 않으므로 잠시 중지 * * GridView.AllowPaging = false; * GridView.DataBind(); * EnableViewState = false; * * //아래 주석처리된 부분은 페이지상에 <%%>를 써서 렌더링 하는 부분이 없을때만 동작합니다. * //마스터페이지 이용시 오류를 피해가는 방법입니다. * //HtmlForm frm = new HtmlForm(); * //Controls.Add(frm); * //frm.Controls.Add(GridView); * //frm.RenderControl(htmlWriter); * // 엑셀에서 자동 숫자변환 안되도록 하는 스타일 * string strStyle = @"<style>td { mso-number-format:\@; } </style>"; * * GridView.RenderControl(htmlWriter); * // 엑셀에서 자동 숫자변환 안되도록 스타일 적용 * Response.Write(strStyle); * Response.Write(stringWriter.ToString()); * Response.End(); * * //현재 페이징으로 복귀. * GridView.AllowPaging = true; * GridView.DataBind(); * } * * protected void BtnDownLoadExcel_Click(object sender, EventArgs e) * { * Response.ClearHeaders(); * string fileName = "파일명[" + DateTime.Today.ToString().Substring(0, 10) + "].xls"; * Response.ContentType = "application/vnd.ms-excel"; * Response.AddHeader("Content-Disposition", "attachment;fileName=" + fileName); * Response.Charset = "euc-kr"; * * Button1.Visible = false; * * System.IO.StringWriter tw = new System.IO.StringWriter(); * System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); * String convStr = this.View.hw Table1.ToString(); * * Response.Write(convStr); * } */ public ActionResult PaymentList(DateTime?SearchDate) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } PaymentListData PaymentList = new PaymentListData(); if (SearchDate == null) { PaymentList.SearchDate = DateTime.Today; PaymentList.Payments = db.Payments.Include(p => p.Employee) // .Include(p => p.MaterialBuy) .Where(p => p.Date == PaymentList.SearchDate) .OrderByDescending(p => p.Date); } else { PaymentList.SearchDate = (DateTime)SearchDate; PaymentList.Payments = db.Payments.Include(p => p.Employee) // .Include(p => p.MaterialBuy) .Where(p => p.Date == SearchDate) .OrderByDescending(p => p.Date); } return(View(PaymentList)); }
public ActionResult PaymentListDetails(DateTime SearchDate) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } PaymentListData PaymentList = new PaymentListData(); PaymentList.SearchDate = DateTime.Today; PaymentList.Payments = db.Payments.Include(p => p.Employee) .Include(p => p.Company) // .Include(p => p.MaterialBuy) .Where(p => p.Date == SearchDate && p.Type == PaymentType.Bank) .OrderByDescending(p => p.Date); return(View(PaymentList)); }