Пример #1
0
        public ActionResult ExporttoExcel()
        {
            var exportuserdetails = (from data2 in db.GetTransactionsDetails(0, Convert.ToInt32(Session["CustomerId"]), "", Convert.ToString(TempData["status"]))
                                     select new TransactionsModel
            {
                CustomerId = data2.CustomerId,
                Amount = Convert.ToInt32(data2.Amount.Value),
                TransactionDate = data2.TransactionDate,
                TransactionType = data2.TransactionType,
                status = data2.status,
                TransactionId = data2.Id
                                //PaymentMethod = data2.PaymentMethod
            }).ToList();
            List <ExportDetailsModel> ExportUserDetailsModel = new List <Models.ExportDetailsModel>();

            foreach (var item in exportuserdetails)
            {
                var model = new ExportDetailsModel();
                //model.CustomerId = item.CustomerId;
                model.Amount          = item.Amount;
                model.TransactionDate = item.TransactionDate.ToString("dd-MMM-yyyy");
                model.status          = item.status;
                //model.PaymentMethod = item.PaymentMethod;
                model.TransactionType = item.TransactionType;
                //model.CustomerId = item.Id;
                model.TransactionNumber = item.TransactionId;
                ExportUserDetailsModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ExportUserDetailsModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=TransactionsDetails.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"));
        }
Пример #2
0
        public static IEnumerable <GetTransactionsDetails_Result> UserTransactionDetails(int Id, int SearchRecords, int CustomerId, string transactiontype, string status)
        {
            transactiontype = transactiontype.Trim().ToLower();
            status          = status.Trim().ToLower();

            var RtnData = (from data2 in db.GetTransactionsDetails(Id, CustomerId, transactiontype, status)
                           select data2);

            return(RtnData);
        }