protected override void AfterSave() { #region detail if (this.Row.tbDetailJenisInformasiRow.Count > 0) { string idIn = ""; int i = 0; foreach (TbDetailJenisInformasiRow detailRow in this.Row.tbDetailJenisInformasiRow) { setFolder = this.Row.KodeRt + "/" + "Informasi/" + this.Row.JenisInformasi + "/" + detailRow.Judul + "/"; FileChanger.CreateFolder(setFolder); detailRow.IdJenisInformasi = this.Row.Id; detailRow.DibuatOleh = this.Row.DibuatOleh; source = detailRow.NamaFile; if (source != null) { var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); detailRow.NamaFile = destination; } if (detailRow.Id != null) { this.Connection.UpdateById(detailRow); } else { int insertId = (int)this.Connection.InsertAndGetID(detailRow); //set accountRow.Id detailRow.Id = (int)insertId; } i++; idIn += detailRow.Id.ToString(); if (i < this.Row.tbDetailJenisInformasiRow.Count) { idIn += ","; } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisInformasi WHERE Id Not In ({0}) and IdJenisInformasi = {1}", idIn, this.Row.Id)); } else { this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisInformasi WHERE IdJenisInformasi = {0} ", this.Row.Id)); } #endregion }
protected override void BeforeSave() { #region header setFolder = this.Row.KodeRt + "/" + "Questioner/" + this.Row.Judul + "/"; FileChanger.CreateFolder(setFolder); if (this.Row.FileName != null) { source = Row.FileName; var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); this.Row.FileName = destination; } #endregion }
protected override void AfterSave() { #region detail if (this.Row.tbDetailJenisKegiatanRow.Count > 0) { string idIn = ""; int i = 0; foreach (TbDetailJenisKegiatanRow detailRow in this.Row.tbDetailJenisKegiatanRow) { setFolder = this.Row.KodeRt + "/" + "Kegiatan/" + this.Row.JenisKegiatan + "/" + detailRow.NamaKegiatan + "/"; FileChanger.CreateFolder(setFolder); detailRow.IdJenisKegiatan = this.Row.Id; detailRow.DibuatOleh = this.Row.DibuatOleh; source = detailRow.NamaFile; if (source != null) { var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); detailRow.NamaFile = destination; } if (detailRow.Dokumentasi != null && detailRow.Dokumentasi != "[]") { string currentPath = ""; var resultFile = Newtonsoft.Json.JsonConvert.DeserializeObject <List <FileNameResult> >(detailRow.Dokumentasi); foreach (var item in resultFile) { source = item.Filename; var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); currentPath = splt[splt.Length - 2] + "/"; if (splt.Length > 2) { currentPath = splt[splt.Length - 5] + "/" + splt[splt.Length - 4] + "/" + splt[splt.Length - 3] + "/" + splt[splt.Length - 2] + "/"; } } detailRow.Dokumentasi = detailRow.Dokumentasi.Replace(currentPath, setFolder); } if (detailRow.Id != null) { this.Connection.UpdateById(detailRow); } else { int insertId = (int)this.Connection.InsertAndGetID(detailRow); //set accountRow.Id detailRow.Id = (int)insertId; } i++; idIn += detailRow.Id.ToString(); if (i < this.Row.tbDetailJenisKegiatanRow.Count) { idIn += ","; } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisKegiatan WHERE Id Not In ({0}) and IdJenisKegiatan = {1}", idIn, this.Row.Id)); } else { this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisKegiatan WHERE IdJenisKegiatan = {0}", this.Row.Id)); } #endregion }