コード例 #1
0
        private void SaveInfo()
        {
            try
            {
                var G_info = DB.GetTable<ESHOP_CONFIG>().OrderBy(c => c.CONFIG_ID).Take(1);

                if (G_info.ToList().Count > 0)
                {
                    G_info.Single().CONFIG_HITCOUNTER = Utils.CIntDef(txtHitcouter.Value);
                  
                    DB.SubmitChanges();
                }
                else
                { //insert
                    ESHOP_CONFIG config_insert = new ESHOP_CONFIG();

                    config_insert.CONFIG_HITCOUNTER = Utils.CIntDef(txtHitcouter.Value);

                    DB.ESHOP_CONFIGs.InsertOnSubmit(config_insert);
                    DB.SubmitChanges();
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
コード例 #2
0
        private void SaveInfo()
        {
            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;
                }

                //get image
                string BG_File;

                if (trUploadBG.Visible == true)
                {
                    if (fileImageBG.PostedFile != null)
                    {
                        BG_File = Path.GetFileName(fileImageBG.PostedFile.FileName);
                    }
                    else
                    {
                        BG_File = "";
                    }
                }
                else
                {
                    BG_File = hplFileBG.Text;
                }

                var G_info = DB.GetTable<ESHOP_CONFIG>().OrderBy(c => c.CONFIG_ID).Take(1);

                if (G_info.ToList().Count > 0)
                {
                    G_info.Single().CONFIG_TITLE = txtSeoTitle.Value;
                    G_info.Single().CONFIG_DESCRIPTION = txtSeoDesc.Value;
                    G_info.Single().CONFIG_KEYWORD = txtSeoKeyword.Value;

                    G_info.Single().CONFIG_TITLE_EN = txtSeoTitleEn.Value;
                    G_info.Single().CONFIG_DESCRIPTION_EN = txtSeoDescEn.Value;
                    G_info.Single().CONFIG_KEYWORD_EN = txtSeoKeywordEn.Value;

                    G_info.Single().CONFIG_FAVICON = Banner_File;
                    G_info.Single().CONFIG_FIELD1 = BG_File;
                    G_info.Single().CONFIG_FIELD2 = ColorPicker1.Color;
                    DB.SubmitChanges();
                }
                else
                { 
                    //insert
                    ESHOP_CONFIG config_insert = new ESHOP_CONFIG();

                    config_insert.CONFIG_TITLE = txtSeoTitle.Value;
                    config_insert.CONFIG_DESCRIPTION = txtSeoDesc.Value;
                    config_insert.CONFIG_KEYWORD = txtSeoKeyword.Value;

                    config_insert.CONFIG_TITLE_EN = txtSeoTitleEn.Value;
                    config_insert.CONFIG_DESCRIPTION_EN = txtSeoDescEn.Value;
                    config_insert.CONFIG_KEYWORD_EN = txtSeoKeywordEn.Value;
                    config_insert.CONFIG_FAVICON = Banner_File;
                    config_insert.CONFIG_FIELD1 = BG_File;
                    config_insert.CONFIG_FIELD1 = ColorPicker1.Color;

                    DB.ESHOP_CONFIGs.InsertOnSubmit(config_insert);
                    DB.SubmitChanges();
                }

                //update images
                if (trUpload.Visible)
                {
                    if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName))
                    {
                        string pathfile = Server.MapPath("/data/configs");
                        string fullpathfile = pathfile + "/" + Banner_File;

                        if (!Directory.Exists(pathfile))
                        {
                            Directory.CreateDirectory(pathfile);
                        }

                        fileImage1.PostedFile.SaveAs(fullpathfile);
                    }
                }

                //update imagesBG
                if (trUploadBG.Visible)
                {
                    //if (!string.IsNullOrEmpty(fileImageBG.PostedFile.FileName))
                    //{
                    //    string pathfile = Server.MapPath("/data/configs");
                    //    string fullpathfile = pathfile + "/" + BG_File;

                    //    if (!Directory.Exists(pathfile))
                    //    {
                    //        Directory.CreateDirectory(pathfile);
                    //    }

                    //    fileImageBG.PostedFile.SaveAs(fullpathfile);
                    //}
                    CpanelUtils.ImageResize(Server.MapPath("/data/configs/"), fileImageBG.Value, 1366, fileImageBG.PostedFile.InputStream);
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
            finally
            {
                getInfo();
            }
        }