protected void btnSave_Click(object sender, EventArgs e) { List <string> results = new List <string>(); try { if (ValidateInput()) { string noticeFolder = AppConstant.NoticeFolder; if (string.IsNullOrEmpty(noticeFolder)) { throw new Exception("ไม่พบ NoticeFolder(ข้อมูลประกาศ) ใน File Config"); } string physicalPath = Server.MapPath(noticeFolder); results = NoticeBiz.InsertData(txtTopic.Text.Trim(), physicalPath, noticeFolder, fuImage.FileName, fuImage.PostedFile.ContentLength, fuAttachFile.FileName, (fuAttachFile.PostedFile != null ? fuAttachFile.PostedFile.ContentLength : 0), rbActive.Checked, HttpContext.Current.User.Identity.Name); string mainFolder = Path.Combine(physicalPath, results[0]); //results[0] = noticeId if (!Directory.Exists(mainFolder)) { Directory.CreateDirectory(mainFolder); } if (fuImage.HasFile && !string.IsNullOrEmpty(results[1])) { fuImage.SaveAs(results[1]); } if (fuAttachFile.HasFile && !string.IsNullOrEmpty(results[2])) { fuAttachFile.SaveAs(results[2]); } //ClearPopupControl(); //DoSearchNotice(0); //AppUtil.ClientAlert(Page, "บันทึกข้อมูลเรียบร้อย"); AppUtil.ClientAlertAndRedirect(Page, "บันทึกข้อมูลเรียบร้อย", "SLM_SCR_021.aspx"); } else { mpePopup.Show(); } } catch (Exception ex) { string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; _log.Debug(message); if (results.Count > 0 && !string.IsNullOrEmpty(results[0])) { NoticeBiz.DeleteData(int.Parse(results[0])); } AppUtil.ClientAlert(Page, message); } }