public ActionResult Edit(int id) { Context.Rekenings dbitem = RepoRekening.FindByPK(id); Rekening model = new Rekening(dbitem); ViewBag.name = model.NoRekening; return(View("Form", model)); }
public void setDb(Context.Rekenings dbitem) { dbitem.Id = Id; dbitem.NamaRekening = NamaRekening; dbitem.NoRekening = NoRekening; dbitem.IdBank = IdBank.Value; dbitem.Type = Type_; dbitem.SetAsDefault = SetAsDefault; }
public JsonResult Delete(int id) { ResponeModel response = new ResponeModel(true); Context.Rekenings dbItem = RepoRekening.FindByPK(id); RepoRekening.delete(dbItem); return(Json(response)); }
public Rekening(Context.Rekenings dbitem) { Id = dbitem.Id; NamaRekening = dbitem.NamaRekening; NoRekening = dbitem.NoRekening; IdBank = dbitem.IdBank; StrBank = dbitem.LookupCodeBank.Nama; Type_ = dbitem.Type; SetAsDefault = dbitem.SetAsDefault; }
public ActionResult Edit(Rekening model) { if (ModelState.IsValid) { if (RepoRekening.IsExist(model.IdBank.Value, model.NoRekening, model.Id)) { ModelState.AddModelError("NoRekening", "No Rekening sudah terdaftar."); return(View("Form", model)); } Context.Rekenings dbitem = RepoRekening.FindByPK(model.Id); model.setDb(dbitem); RepoRekening.save(dbitem); return(RedirectToAction("Index")); } return(View("Form", model)); }
public string UploadRekening(IEnumerable <HttpPostedFileBase> filesRekening) { ResponeModel response = new ResponeModel(); //algoritma if (filesRekening != null) { foreach (var file in filesRekening) { try { using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet.First(); var noOfRow = workSheet.Dimension.End.Row; var regexItem = new System.Text.RegularExpressions.Regex("^[0-9]*$"); for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { //cek mandatory field if (workSheet.Cells[rowIterator, 1].Value != null && workSheet.Cells[rowIterator, 2].Value != null && workSheet.Cells[rowIterator, 3].Value != null && workSheet.Cells[rowIterator, 4].Value != null && regexItem.IsMatch(workSheet.Cells[rowIterator, 2].Value.ToString())) { int id = 0; int resId; if (workSheet.Cells[rowIterator, 5].Value != null) { if (int.TryParse(workSheet.Cells[rowIterator, 5].Value.ToString(), out resId)) { id = resId; } } try { Context.Rekenings dbitem = new Context.Rekenings();; if (id != 0) { if (RepoRekening.IsExist(RepoLookup.FindByName(workSheet.Cells[rowIterator, 3].Value.ToString()).Id, workSheet.Cells[rowIterator, 2].Value.ToString(), id)) { continue; } dbitem = RepoRekening.FindByPK(id); } else { if (RepoRekening.IsExist(RepoLookup.FindByName(workSheet.Cells[rowIterator, 3].Value.ToString()).Id, workSheet.Cells[rowIterator, 2].Value.ToString())) { ModelState.AddModelError("NoRekening", "No Rekening sudah terdaftar."); continue; } } dbitem.Id = id; dbitem.NamaRekening = workSheet.Cells[rowIterator, 1].Value.ToString(); dbitem.NoRekening = workSheet.Cells[rowIterator, 2].Value.ToString(); dbitem.IdBank = RepoLookup.FindByName(workSheet.Cells[rowIterator, 3].Value.ToString()).Id; string type = workSheet.Cells[rowIterator, 4].Value.ToString().ToUpper(); if (type != "PPN" && type != "NON PPN") { continue; } dbitem.Type = type; RepoRekening.save(dbitem); } catch (Exception) { } } } } response.Success = true; } catch (Exception e) { response.Success = false; response.Message = e.Message.ToString(); } } } return(new JavaScriptSerializer().Serialize(new { Response = response })); }