private void SaveInfo(string strLink = "") { try { //get image string News_Image1; if (trUploadImage1.Visible == true) { if (fileImage1.PostedFile != null) { News_Image1 = Path.GetFileName(fileImage1.PostedFile.FileName); } else { News_Image1 = ""; } } else { News_Image1 = hplImage1.Text; } if (m_gift_id == 0) { //insert ESHOP_GIFT gift_insert = new ESHOP_GIFT(); gift_insert .GIFT_NAME =txtGiftName.Text; gift_insert .GIFT_DESC = txtGiftDesc.Value; gift_insert .GIFT_POINT = Utils.CIntDef(txtGiftPoint.Value); gift_insert.GIFT_AMOUNT = Utils.CIntDef(txtGridAmount.Value); gift_insert.GIFT_MAX_AMOUNT = Utils.CIntDef(txtGridMaxAmount.Value); gift_insert.GIFT_CONTENT = Utils.CStrDef(txtGiftContent.Value); gift_insert .GIFT_IMAGE = News_Image1; gift_insert .GIFT_PULISHDATE = DateTime.Now; //english language DB.ESHOP_GIFTs.InsertOnSubmit(gift_insert); DB.SubmitChanges(); //update cat news var _new = DB.GetTable<ESHOP_GIFT>().OrderByDescending(g => g.GIFT_ID).Take(1); m_gift_id = _new.Single().GIFT_ID; strLink = string.IsNullOrEmpty(strLink) ? "gift.aspx?gift_id=" + m_gift_id : strLink; } else { //update var c_update = DB.GetTable<ESHOP_GIFT>().Where(g => g.GIFT_ID == m_gift_id); if (c_update.ToList().Count > 0) { c_update.ToList()[0].GIFT_NAME = txtGiftName.Text; c_update.ToList()[0].GIFT_DESC = txtGiftDesc.Value; c_update.ToList()[0].GIFT_POINT =Utils.CIntDef(txtGiftPoint.Value); c_update.ToList()[0].GIFT_AMOUNT = Utils.CIntDef(txtGridAmount.Value); c_update.ToList()[0].GIFT_MAX_AMOUNT = Utils.CIntDef(txtGridMaxAmount.Value); c_update.ToList()[0].GIFT_CONTENT = Utils.CStrDef(txtGiftContent.Value); c_update.ToList()[0].GIFT_PULISHDATE = DateTime.Now; c_update.ToList()[0].GIFT_IMAGE = News_Image1; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "gift_list.aspx" : strLink; } } //update images if (trUploadImage1.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("../data/news/" + m_gift_id); string fullpathfile = pathfile + "/" + News_Image1; 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 News_Image1; if (trUploadImage1.Visible == true) { if (fileImage1.PostedFile != null) { News_Image1 = Path.GetFileName(fileImage1.PostedFile.FileName); } else { News_Image1 = ""; } } else { News_Image1 = hplImage1.Text; } if (m_gift_id == 0) { //insert ESHOP_GIFT gift_insert = new ESHOP_GIFT(); gift_insert.GIFT_NAME = txtGiftName.Text; gift_insert.GIFT_DESC = txtGiftDesc.Value; gift_insert.GIFT_POINT = Utils.CIntDef(txtGiftPoint.Value); gift_insert.GIFT_AMOUNT = Utils.CIntDef(txtGridAmount.Value); gift_insert.GIFT_MAX_AMOUNT = Utils.CIntDef(txtGridMaxAmount.Value); gift_insert.GIFT_CONTENT = Utils.CStrDef(txtGiftContent.Value); gift_insert.GIFT_IMAGE = News_Image1; gift_insert.GIFT_PULISHDATE = DateTime.Now; //english language DB.ESHOP_GIFTs.InsertOnSubmit(gift_insert); DB.SubmitChanges(); //update cat news var _new = DB.GetTable <ESHOP_GIFT>().OrderByDescending(g => g.GIFT_ID).Take(1); m_gift_id = _new.Single().GIFT_ID; strLink = string.IsNullOrEmpty(strLink) ? "gift.aspx?gift_id=" + m_gift_id : strLink; } else { //update var c_update = DB.GetTable <ESHOP_GIFT>().Where(g => g.GIFT_ID == m_gift_id); if (c_update.ToList().Count > 0) { c_update.ToList()[0].GIFT_NAME = txtGiftName.Text; c_update.ToList()[0].GIFT_DESC = txtGiftDesc.Value; c_update.ToList()[0].GIFT_POINT = Utils.CIntDef(txtGiftPoint.Value); c_update.ToList()[0].GIFT_AMOUNT = Utils.CIntDef(txtGridAmount.Value); c_update.ToList()[0].GIFT_MAX_AMOUNT = Utils.CIntDef(txtGridMaxAmount.Value); c_update.ToList()[0].GIFT_CONTENT = Utils.CStrDef(txtGiftContent.Value); c_update.ToList()[0].GIFT_PULISHDATE = DateTime.Now; c_update.ToList()[0].GIFT_IMAGE = News_Image1; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "gift_list.aspx" : strLink; } } //update images if (trUploadImage1.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("../data/news/" + m_gift_id); string fullpathfile = pathfile + "/" + News_Image1; 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); } } }