private void SaveInfo(string strLink = "") { try { string Name = txtName.Value; string Desc = txtDesc.Value; //get image string Ext_Image; if (trUploadImage1.Visible == true) { if (fileImage1.PostedFile != null) { Ext_Image = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Ext_Image = ""; } } else { Ext_Image = hplImage1.Text; } if (m_ext_id == 0) { //insert ESHOP_EXT_FILE g_insert = new ESHOP_EXT_FILE(); g_insert.EXT_FILE_NAME = Name; g_insert.EXT_FILE_DESC = Desc; g_insert.EXT_FILE_IMAGE = Ext_Image; DB.ESHOP_EXT_FILEs.InsertOnSubmit(g_insert); DB.SubmitChanges(); //get new id var _new = DB.GetTable <ESHOP_EXT_FILE>().OrderByDescending(g => g.EXT_FILE_ID).Take(1); m_ext_id = _new.Single().EXT_FILE_ID; strLink = string.IsNullOrEmpty(strLink) ? "extensionfiles_list.aspx" : strLink; } else { //update var g_update = DB.GetTable <ESHOP_EXT_FILE>().Where(g => g.EXT_FILE_ID == m_ext_id); if (g_update.ToList().Count > 0) { g_update.Single().EXT_FILE_NAME = Name; g_update.Single().EXT_FILE_DESC = Desc; g_update.Single().EXT_FILE_IMAGE = Ext_Image; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "extensionfiles_list.aspx" : strLink; } } //update images if (trUploadImage1.Visible) { if (fileImage1.PostedFile != null) { string pathfile = Server.MapPath("../data/ext_files/" + m_ext_id); string fullpathfile = pathfile + "/" + Ext_Image; if (!Directory.Exists(pathfile)) { Directory.CreateDirectory(pathfile); } fileImage1.PostedFile.SaveAs(fullpathfile); } } } catch (Exception ex) { clsVproErrorHandler.HandlerError(ex); } finally { if (!string.IsNullOrEmpty(strLink)) { Response.Redirect(strLink); } } }
private void SaveInfo(string strLink = "") { try { string Name = txtName.Value; string Desc = txtDesc.Value; //get image string Ext_Image; if (trUploadImage1.Visible == true) { if (fileImage1.PostedFile != null) { Ext_Image = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Ext_Image = ""; } } else { Ext_Image = hplImage1.Text; } if (m_ext_id == 0) { //insert ESHOP_EXT_FILE g_insert = new ESHOP_EXT_FILE(); g_insert.EXT_FILE_NAME = Name; g_insert.EXT_FILE_DESC = Desc; g_insert.EXT_FILE_IMAGE = Ext_Image; DB.ESHOP_EXT_FILEs.InsertOnSubmit(g_insert); DB.SubmitChanges(); //get new id var _new = DB.GetTable<ESHOP_EXT_FILE>().OrderByDescending(g => g.EXT_FILE_ID).Take(1); m_ext_id = _new.Single().EXT_FILE_ID; strLink = string.IsNullOrEmpty(strLink) ? "extensionfiles_list.aspx" : strLink; } else { //update var g_update = DB.GetTable<ESHOP_EXT_FILE>().Where(g => g.EXT_FILE_ID == m_ext_id); if (g_update.ToList().Count > 0) { g_update.Single().EXT_FILE_NAME = Name; g_update.Single().EXT_FILE_DESC = Desc; g_update.Single().EXT_FILE_IMAGE = Ext_Image; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "extensionfiles_list.aspx" : strLink; } } //update images if (trUploadImage1.Visible) { if (fileImage1.PostedFile != null) { string pathfile = Server.MapPath("../data/ext_files/" + m_ext_id); string fullpathfile = pathfile + "/" + Ext_Image; if (!Directory.Exists(pathfile)) { Directory.CreateDirectory(pathfile); } fileImage1.PostedFile.SaveAs(fullpathfile); } } } catch (Exception ex) { clsVproErrorHandler.HandlerError(ex); } finally { if (!string.IsNullOrEmpty(strLink)) { Response.Redirect(strLink); } } }