Exemplo n.º 1
0
        private void SaveInfo(string strLink = "")
        {
            try
            {
                //get image1
                string Online_Image1;

                //if (trUploadImage1.Visible == true)
                //{
                //    if (fileImage1.PostedFile != null)
                //    {
                //        Online_Image1 = Path.GetFileName(fileImage1.PostedFile.FileName);
                //    }
                //    else
                //    {
                //        Online_Image1 = "";
                //    }
                //}
                //else
                //{
                //    Online_Image1 = hplImage1.Text;
                //}


                if (m_online_id == 0)
                {
                    //insert
                    ESHOP_ONLINE g_insert = new ESHOP_ONLINE();
                    g_insert.ONLINE_NICKNAME = txtName.Value;
                    g_insert.ONLINE_DESC     = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDesc.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                    //g_insert.ONLINE_DESC_EN = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDescEn.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                    g_insert.ONLINE_ORDER    = Utils.CIntDef(txtOrder.Value);
                    g_insert.ONLINE_TYPE     = Utils.CIntDef(rblType.SelectedValue);
                    g_insert.ONLINE_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue);
                    //g_insert.ONLINE_IMAGE = Online_Image1;

                    DB.ESHOP_ONLINEs.InsertOnSubmit(g_insert);

                    DB.SubmitChanges();

                    var _online = DB.GetTable <ESHOP_ONLINE>().OrderByDescending(g => g.ONLINE_ID).Take(1);

                    m_online_id = _online.Single().ONLINE_ID;

                    strLink = string.IsNullOrEmpty(strLink) ? "online.aspx?online_id=" + m_online_id : strLink;
                }
                else
                {
                    //update
                    var g_update = DB.GetTable <ESHOP_ONLINE>().Where(g => g.ONLINE_ID == m_online_id);

                    if (g_update.ToList().Count > 0)
                    {
                        g_update.Single().ONLINE_NICKNAME = txtName.Value;
                        g_update.Single().ONLINE_DESC     = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDesc.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                        //g_update.Single().ONLINE_DESC_EN = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDescEn.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                        g_update.Single().ONLINE_ORDER    = Utils.CIntDef(txtOrder.Value);
                        g_update.Single().ONLINE_TYPE     = Utils.CIntDef(rblType.SelectedValue);
                        g_update.Single().ONLINE_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue);
                        // g_update.Single().ONLINE_IMAGE = Online_Image1;

                        DB.SubmitChanges();

                        strLink = string.IsNullOrEmpty(strLink) ? "online.aspx?online_id=" + m_online_id : strLink;
                    }
                }

                //update images 1
                //if (trUploadImage1.Visible)
                //{
                //    if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName))
                //    {
                //        string pathfile = Server.MapPath("../data/onlines/" + m_online_id);
                //        string fullpathfile = pathfile + "/" + Online_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);
                }
            }
        }
Exemplo n.º 2
0
        private void SaveInfo(string strLink = "")
        {
            try
            {

                //get image1
                string Online_Image1;

                //if (trUploadImage1.Visible == true)
                //{
                //    if (fileImage1.PostedFile != null)
                //    {
                //        Online_Image1 = Path.GetFileName(fileImage1.PostedFile.FileName);
                //    }
                //    else
                //    {
                //        Online_Image1 = "";
                //    }
                //}
                //else
                //{
                //    Online_Image1 = hplImage1.Text;
                //}


                if (m_online_id == 0)
                {
                    //insert
                    ESHOP_ONLINE g_insert = new ESHOP_ONLINE();
                    g_insert.ONLINE_NICKNAME = txtName.Value;
                    g_insert.ONLINE_DESC = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDesc.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                    //g_insert.ONLINE_DESC_EN = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDescEn.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                    g_insert.ONLINE_ORDER = Utils.CIntDef(txtOrder.Value);
                    g_insert.ONLINE_TYPE = Utils.CIntDef(rblType.SelectedValue);
                    g_insert.ONLINE_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue);
                    //g_insert.ONLINE_IMAGE = Online_Image1;

                    DB.ESHOP_ONLINEs.InsertOnSubmit(g_insert);

                    DB.SubmitChanges();

                    var _online = DB.GetTable<ESHOP_ONLINE>().OrderByDescending(g => g.ONLINE_ID).Take(1);

                    m_online_id = _online.Single().ONLINE_ID;

                    strLink = string.IsNullOrEmpty(strLink) ? "online_list.aspx" : strLink;
                }
                else
                {
                    //update
                    var g_update = DB.GetTable<ESHOP_ONLINE>().Where(g => g.ONLINE_ID == m_online_id);

                    if (g_update.ToList().Count > 0)
                    {
                        g_update.Single().ONLINE_NICKNAME = txtName.Value;
                        g_update.Single().ONLINE_DESC = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDesc.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                        //g_update.Single().ONLINE_DESC_EN = Utils.CStrDef(System.Web.HttpUtility.HtmlDecode(txtDescEn.Value.Replace("\r\n", "<br>").Replace(" ", "&nbsp;")), "");
                        g_update.Single().ONLINE_ORDER = Utils.CIntDef(txtOrder.Value);
                        g_update.Single().ONLINE_TYPE = Utils.CIntDef(rblType.SelectedValue);
                        g_update.Single().ONLINE_LANGUAGE = Utils.CIntDef(rblLanguage.SelectedValue);
                       // g_update.Single().ONLINE_IMAGE = Online_Image1;

                        DB.SubmitChanges();

                        strLink = string.IsNullOrEmpty(strLink) ? "online_list.aspx" : strLink;
                    }
                }

                //update images 1
                //if (trUploadImage1.Visible)
                //{
                //    if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName))
                //    {
                //        string pathfile = Server.MapPath("../data/onlines/" + m_online_id);
                //        string fullpathfile = pathfile + "/" + Online_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); }
            }
        }