Exemple #1
0
        public ActionResult CustomerExcel(string sheetName, string fileName)
        {
            if (String.IsNullOrEmpty(sheetName))
            {
                sheetName = "工作表1";
            }
            if (String.IsNullOrEmpty(fileName))
            {
                fileName = string.Concat(DateTime.Now.ToString("yyyyMMddHHmmss"), ".xlsx");
            }

            var data           = CustomerBankRepo.All().Select(p => new { p.銀行名稱, p.銀行代碼, p.分行代碼, p.帳戶名稱, p.帳戶號碼, p.客戶資料.客戶名稱 });
            var workbook       = new XLWorkbook();
            var MymemoryStream = new MemoryStream();
            //設置默認Style
            var style = workbook.Style;

            style.Font.FontName = "Microsoft YaHei";
            style.Font.FontSize = 16;
            var worksheet = workbook.Worksheets.Add(sheetName);

            worksheet.Cell(1, 1).Value = "銀行名稱";
            worksheet.Cell(1, 2).Value = "銀行代碼";
            worksheet.Cell(1, 3).Value = "分行代碼";
            worksheet.Cell(1, 4).Value = "帳戶名稱";
            worksheet.Cell(1, 5).Value = "帳戶號碼";
            worksheet.Cell(1, 6).Value = "客戶名稱";
            worksheet.Cell(2, 1).InsertData(data);

            workbook.SaveAs(MymemoryStream);

            return(File(MymemoryStream.ToArray(), "application/vnd.ms-excel", fileName));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            客戶銀行資訊 客戶銀行資訊 = CustomerBankRepo.Find(id);

            CustomerBankRepo.Delete(客戶銀行資訊);
            CustomerBankRepo.UnitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        // GET: CustomerBankInformation
        public ActionResult Index(string Keyword, int page = 1)
        {
            var data = CustomerBankRepo.Search(Keyword).Include(p => p.客戶資料);

            ViewBag.Keyword = Keyword;
            var Result = data.ToPagedList(page, pageSize);

            return(View("Index2", Result));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "Id,客戶Id,銀行名稱,銀行代碼,分行代碼,帳戶名稱,帳戶號碼")] 客戶銀行資訊 客戶銀行資訊)
        {
            if (ModelState.IsValid)
            {
                CustomerBankRepo.Add(客戶銀行資訊);
                CustomerBankRepo.UnitOfWork.Commit();
                return(RedirectToAction("Index"));
            }

            ViewBag.客戶Id = new SelectList(CustomerRepo.All(), "Id", "客戶名稱", 客戶銀行資訊.客戶Id);
            return(View(客戶銀行資訊));
        }
Exemple #5
0
        // GET: CustomerBankInformation/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶銀行資訊 客戶銀行資訊 = CustomerBankRepo.Find(id.Value);

            if (客戶銀行資訊 == null)
            {
                return(HttpNotFound());
            }
            return(View(客戶銀行資訊));
        }
Exemple #6
0
        // GET: CustomerBankInformation/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶銀行資訊 客戶銀行資訊 = CustomerBankRepo.Find(id.Value);

            if (客戶銀行資訊 == null)
            {
                return(HttpNotFound());
            }

            ViewBag.客戶Id = new SelectList(CustomerRepo.All(), "Id", "客戶名稱", 客戶銀行資訊.客戶Id);
            return(View(客戶銀行資訊));
        }
Exemple #7
0
        public ActionResult Search(string Keyword)
        {
            var data = CustomerBankRepo.Search(Keyword);

            return(View("Index", data));
        }