private void copyAtt(int id) { try { var _oldNews = DB.GetTable <ESHOP_NEWS_ATT>().Where(n => n.NEWS_ID == m_news_id); foreach (var item in _oldNews) { ESHOP_NEWS_ATT att_insert = new ESHOP_NEWS_ATT(); att_insert.NEWS_ATT_NAME = item.NEWS_ATT_NAME; att_insert.EXT_ID = item.EXT_ID; att_insert.NEWS_ATT_ORDER = item.NEWS_ATT_ORDER; att_insert.NEWS_ATT_URL = item.NEWS_ATT_URL; att_insert.NEWS_ATT_FILE = item.NEWS_ATT_FILE; att_insert.NEWS_ID = id; DB.ESHOP_NEWS_ATTs.InsertOnSubmit(att_insert); } DB.SubmitChanges(); } catch (Exception ex) { clsVproErrorHandler.HandlerError(ex); } }
private void SaveInfo(string strLink = "") { try { //get image string Att_File; if (trUpload.Visible == true) { if (fileImage1.PostedFile != null) { Att_File = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Att_File = ""; } } else { Att_File = hplFile.Text; } if (m_att_id == 0) { //insert ESHOP_NEWS_ATT g_insert = new ESHOP_NEWS_ATT(); g_insert.NEWS_ATT_NAME = txtTitle.Value; g_insert.EXT_ID = Utils.CIntDef(ddlExtFiles.SelectedValue); g_insert.NEWS_ATT_ORDER = Utils.CIntDef(txtOrder.Value); g_insert.NEWS_ATT_URL = txtUrl.Value; g_insert.NEWS_ID = m_news_id; g_insert.NEWS_ATT_FILE = Att_File; DB.ESHOP_NEWS_ATTs.InsertOnSubmit(g_insert); DB.SubmitChanges(); //get new id var _new = DB.GetTable<ESHOP_NEWS_ATT>().OrderByDescending(g => g.NEWS_ATT_ID).Take(1); m_att_id = _new.Single().NEWS_ATT_ID; strLink = string.IsNullOrEmpty(strLink) ? "news_attachment.aspx?type=" + _type + "&news_id=" + m_news_id : strLink; } else { //update var g_update = DB.GetTable<ESHOP_NEWS_ATT>().Where(g => g.NEWS_ATT_ID == m_att_id); if (g_update.ToList().Count > 0) { g_update.Single().NEWS_ATT_NAME = txtTitle.Value; g_update.Single().EXT_ID = Utils.CIntDef(ddlExtFiles.SelectedValue); g_update.Single().NEWS_ATT_ORDER = Utils.CIntDef(txtOrder.Value); g_update.Single().NEWS_ATT_URL = txtUrl.Value; g_update.Single().NEWS_ATT_FILE = Att_File; g_update.Single().NEWS_ID = m_news_id; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "news_attachment.aspx?type="+_type+"&news_id=" + m_news_id : strLink; } } //update images if (trUpload.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("/data/news/" + m_news_id); string fullpathfile = pathfile + "/" + Att_File; 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 { //get image string Att_File; if (trUpload.Visible == true) { if (fileImage1.PostedFile != null) { Att_File = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Att_File = ""; } } else { Att_File = hplFile.Text; } if (m_att_id == 0) { //insert ESHOP_NEWS_ATT g_insert = new ESHOP_NEWS_ATT(); g_insert.NEWS_ATT_NAME = txtTitle.Value; g_insert.EXT_ID = Utils.CIntDef(ddlExtFiles.SelectedValue); g_insert.NEWS_ATT_ORDER = Utils.CIntDef(txtOrder.Value); g_insert.NEWS_ATT_URL = txtUrl.Value; g_insert.NEWS_ID = m_news_id; g_insert.NEWS_ATT_FILE = Att_File; DB.ESHOP_NEWS_ATTs.InsertOnSubmit(g_insert); DB.SubmitChanges(); //get new id var _new = DB.GetTable <ESHOP_NEWS_ATT>().OrderByDescending(g => g.NEWS_ATT_ID).Take(1); m_att_id = _new.Single().NEWS_ATT_ID; strLink = string.IsNullOrEmpty(strLink) ? "news_attachment.aspx?type=" + _type + "&news_id=" + m_news_id : strLink; } else { //update var g_update = DB.GetTable <ESHOP_NEWS_ATT>().Where(g => g.NEWS_ATT_ID == m_att_id); if (g_update.ToList().Count > 0) { g_update.Single().NEWS_ATT_NAME = txtTitle.Value; g_update.Single().EXT_ID = Utils.CIntDef(ddlExtFiles.SelectedValue); g_update.Single().NEWS_ATT_ORDER = Utils.CIntDef(txtOrder.Value); g_update.Single().NEWS_ATT_URL = txtUrl.Value; g_update.Single().NEWS_ATT_FILE = Att_File; g_update.Single().NEWS_ID = m_news_id; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "news_attachment.aspx?type=" + _type + "&news_id=" + m_news_id : strLink; } } //update images if (trUpload.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("/data/news/" + m_news_id); string fullpathfile = pathfile + "/" + Att_File; 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 copyAtt(int id) { try { var _oldNews = DB.GetTable<ESHOP_NEWS_ATT>().Where(n => n.NEWS_ID == m_news_id); foreach (var item in _oldNews) { ESHOP_NEWS_ATT att_insert = new ESHOP_NEWS_ATT(); att_insert.NEWS_ATT_NAME = item.NEWS_ATT_NAME; att_insert.EXT_ID = item.EXT_ID; att_insert.NEWS_ATT_ORDER = item.NEWS_ATT_ORDER; att_insert.NEWS_ATT_URL = item.NEWS_ATT_URL; att_insert.NEWS_ATT_FILE = item.NEWS_ATT_FILE; att_insert.NEWS_ID = id; DB.ESHOP_NEWS_ATTs.InsertOnSubmit(att_insert); } DB.SubmitChanges(); } catch (Exception ex) { clsVproErrorHandler.HandlerError(ex); } }