private void SaveInfo(string strLink = "") { try { //get image string Banner_File; if (trUpload.Visible == true) { if (fileImage1.PostedFile != null) { Banner_File = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Banner_File = ""; } } else { Banner_File = hplFile.Text; } if (m_ad_id == 0) { //insert ESHOP_AD_ITEM g_insert = new ESHOP_AD_ITEM(); g_insert.AD_ITEM_CODE = txtCode.Value; g_insert.AD_ITEM_DESC = txtDesc.Value; g_insert.AD_ITEM_URL = txtUrl.Value; g_insert.AD_ITEM_TARGET = ddlTarget.SelectedValue; g_insert.AD_ITEM_TYPE = Utils.CIntDef(rblBannerType.SelectedValue); g_insert.AD_ITEM_POSITION = Utils.CIntDef(rblAdPos.SelectedValue); g_insert.AD_ITEM_WIDTH = Utils.CIntDef(txtWidth.Value); g_insert.AD_ITEM_HEIGHT = Utils.CIntDef(txtHeight.Value); g_insert.AD_ITEM_ORDER = Utils.CIntDef(txtOrder.Value); g_insert.AD_ITEM_DATEFROM = ucFromDate.returnDate; g_insert.AD_ITEM_DATETO = ucToDate.returnDate; g_insert.AD_ITEM_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue); g_insert.AD_ITEM_FILENAME = Banner_File; //g_insert.AD_ITEM_FIELD1 = Utils.CStrDef(txtClip.Value); DB.ESHOP_AD_ITEMs.InsertOnSubmit(g_insert); DB.SubmitChanges(); //get new id var _new = DB.GetTable<ESHOP_AD_ITEM>().OrderByDescending(g => g.AD_ITEM_ID).Take(1); m_ad_id = _new.Single().AD_ITEM_ID; SaveAdItemsCat(m_ad_id); DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "aditem.aspx?ad_id="+m_ad_id+"" : strLink; } else { //update var g_update = DB.GetTable<ESHOP_AD_ITEM>().Where(g => g.AD_ITEM_ID == m_ad_id); if (g_update.ToList().Count > 0) { g_update.Single().AD_ITEM_CODE = txtCode.Value; g_update.Single().AD_ITEM_DESC = txtDesc.Value; g_update.Single().AD_ITEM_URL = txtUrl.Value; g_update.Single().AD_ITEM_TARGET = ddlTarget.SelectedValue; g_update.Single().AD_ITEM_TYPE = Utils.CIntDef(rblBannerType.SelectedValue); g_update.Single().AD_ITEM_POSITION = Utils.CIntDef(rblAdPos.SelectedValue); g_update.Single().AD_ITEM_WIDTH = Utils.CIntDef(txtWidth.Value); g_update.Single().AD_ITEM_HEIGHT = Utils.CIntDef(txtHeight.Value); g_update.Single().AD_ITEM_ORDER = Utils.CIntDef(txtOrder.Value); g_update.Single().AD_ITEM_DATEFROM = ucFromDate.returnDate; g_update.Single().AD_ITEM_DATETO = ucToDate.returnDate; g_update.Single().AD_ITEM_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue); g_update.Single().AD_ITEM_FILENAME = Banner_File; //g_update.Single().AD_ITEM_FIELD1 = Utils.CStrDef(txtClip.Value); SaveAdItemsCat(g_update.Single().AD_ITEM_ID); DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "aditem.aspx?ad_id=" + m_ad_id + "" : strLink; } } //update images if (trUpload.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("/data/aditems/" + m_ad_id); string fullpathfile = pathfile + "/" + Banner_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 Banner_File; if (trUpload.Visible == true) { if (fileImage1.PostedFile != null) { Banner_File = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Banner_File = ""; } } else { Banner_File = hplFile.Text; } if (m_ad_id == 0) { //insert ESHOP_AD_ITEM g_insert = new ESHOP_AD_ITEM(); g_insert.AD_ITEM_CODE = txtCode.Value; g_insert.AD_ITEM_DESC = txtDesc.Value; g_insert.AD_ITEM_URL = txtUrl.Value; g_insert.AD_ITEM_TARGET = ddlTarget.SelectedValue; g_insert.AD_ITEM_TYPE = Utils.CIntDef(rblBannerType.SelectedValue); g_insert.AD_ITEM_POSITION = Utils.CIntDef(rblAdPos.SelectedValue); g_insert.AD_ITEM_WIDTH = Utils.CIntDef(txtWidth.Value); g_insert.AD_ITEM_HEIGHT = Utils.CIntDef(txtHeight.Value); g_insert.AD_ITEM_ORDER = Utils.CIntDef(txtOrder.Value); //g_insert.AD_ITEM_DATEFROM = ucFromDate.returnDate; //g_insert.AD_ITEM_DATETO = ucToDate.returnDate; g_insert.AD_ITEM_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue); g_insert.AD_ITEM_FILENAME = Banner_File; //g_insert.AD_ITEM_FIELD1 = Utils.CStrDef(txtClip.Value); DB.ESHOP_AD_ITEMs.InsertOnSubmit(g_insert); DB.SubmitChanges(); //get new id var _new = DB.GetTable <ESHOP_AD_ITEM>().OrderByDescending(g => g.AD_ITEM_ID).Take(1); m_ad_id = _new.Single().AD_ITEM_ID; SaveAdItemsCat(m_ad_id); DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "aditem_list.aspx" : strLink; } else { //update var g_update = DB.GetTable <ESHOP_AD_ITEM>().Where(g => g.AD_ITEM_ID == m_ad_id); if (g_update.ToList().Count > 0) { g_update.Single().AD_ITEM_CODE = txtCode.Value; g_update.Single().AD_ITEM_DESC = txtDesc.Value; g_update.Single().AD_ITEM_URL = txtUrl.Value; g_update.Single().AD_ITEM_TARGET = ddlTarget.SelectedValue; g_update.Single().AD_ITEM_TYPE = Utils.CIntDef(rblBannerType.SelectedValue); g_update.Single().AD_ITEM_POSITION = Utils.CIntDef(rblAdPos.SelectedValue); g_update.Single().AD_ITEM_WIDTH = Utils.CIntDef(txtWidth.Value); g_update.Single().AD_ITEM_HEIGHT = Utils.CIntDef(txtHeight.Value); g_update.Single().AD_ITEM_ORDER = Utils.CIntDef(txtOrder.Value); //g_update.Single().AD_ITEM_DATEFROM = ucFromDate.returnDate; //g_update.Single().AD_ITEM_DATETO = ucToDate.returnDate; g_update.Single().AD_ITEM_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue); g_update.Single().AD_ITEM_FILENAME = Banner_File; //g_update.Single().AD_ITEM_FIELD1 = Utils.CStrDef(txtClip.Value); SaveAdItemsCat(g_update.Single().AD_ITEM_ID); DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "aditem_list.aspx" : strLink; } } //update images if (trUpload.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("/data/aditems/" + m_ad_id); string fullpathfile = pathfile + "/" + Banner_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); } } }