private void SaveDesignTemplate(System.Web.HttpContext context) { string jsonViewList = context.Request["viewList"]; VshopDesignTemplate template = StoreHelper.GetVshopDesignTemplate(1, true); StringBuilder stringBuider = new StringBuilder(); stringBuider.Append("{"); if (template == null) { VshopDesignTemplate newTemplate = new VshopDesignTemplate(); newTemplate.AddTime = DateTime.Now; newTemplate.TemplateName = "首页模版"; newTemplate.TemplateType = 1; newTemplate.InUse = false; newTemplate.Content = jsonViewList; newTemplate.SupplierId = CheckSupplierRole(); if (StoreHelper.AddVshopDesignTemplate(newTemplate)) { stringBuider.Append("\"success\":1,"); stringBuider.Append("\"mesg:\",\"添加成功\""); } else { stringBuider.Append("\"success\":0,"); stringBuider.Append("\"mesg:\",\"添加失败\""); } } else { template.Content = jsonViewList; template.SupplierId = CheckSupplierRole(); if (StoreHelper.UpdateVshopDesignTemplate(template)) { if (!string.IsNullOrEmpty(context.Request["strHtml"])) { string path = HttpContext.Current.Server.MapPath("/Vshop/index.html"); if (File.Exists(path)) { File.Delete(path); CreateHtml(context.Request["strHtml"]); } } stringBuider.Append("\"success\":1,"); stringBuider.Append("\"mesg:\",\"更新成功\""); } else { stringBuider.Append("\"success\":0,"); stringBuider.Append("\"mesg:\",\"更新失败\""); } } stringBuider.Append("}"); context.Response.Write(stringBuider.ToString()); context.Response.End(); }
public static bool AddVshopDesignTemplate(VshopDesignTemplate template) { bool b = false; if (template != null) { b = new VshopDesignTemplateDao().AddVshopDesignTemplate(template); } return(b); }
private void LoadDesignTemplate(System.Web.HttpContext context) { string json = string.Empty; VshopDesignTemplate template = StoreHelper.GetVshopDesignTemplate(1, true, HiContext.Current.User.UserId); if (template != null) { json = Newtonsoft.Json.JsonConvert.SerializeObject(template); } context.Response.Write(json); context.Response.End(); }
public bool UpdateVshopDesignTemplate(VshopDesignTemplate template) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("update Ecshop_VshopDesignTemplate SET TemplateName=@TemplateName,InUse=@InUse,TemplateType=@TemplateType,Content=@Content,SupplierId=@SupplierId WHERE Id=@Id"); this.database.AddInParameter(sqlStringCommand, "TemplateName", DbType.String, template.TemplateName); this.database.AddInParameter(sqlStringCommand, "InUse", DbType.Boolean, template.InUse); this.database.AddInParameter(sqlStringCommand, "TemplateType", DbType.Int32, template.TemplateType); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, template.Content); this.database.AddInParameter(sqlStringCommand, "SupplierId", DbType.Int32, template.SupplierId); this.database.AddInParameter(sqlStringCommand, "Id", DbType.Int32, template.Id); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public bool AddVshopDesignTemplate(VshopDesignTemplate template) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Ecshop_VshopDesignTemplate VALUES (@TemplateName,@AddTime,@InUse,@TemplateType,@Content,@SupplierId)"); this.database.AddInParameter(sqlStringCommand, "TemplateName", DbType.String, template.TemplateName); this.database.AddInParameter(sqlStringCommand, "AddTime", DbType.DateTime, template.AddTime); this.database.AddInParameter(sqlStringCommand, "InUse", DbType.Boolean, template.InUse); this.database.AddInParameter(sqlStringCommand, "TemplateType", DbType.Int32, template.TemplateType); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, template.Content); this.database.AddInParameter(sqlStringCommand, "SupplierId", DbType.Int32, template.SupplierId); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public VshopDesignTemplate GetVshopDesignTemplate(int TemplateType, bool IsInUse) { VshopDesignTemplate template = null; DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT TOP 1 * FROM Ecshop_VshopDesignTemplate where TemplateType=@TemplateType "); this.database.AddInParameter(sqlStringCommand, "TemplateType", DbType.Int32, TemplateType); // this.database.AddInParameter(sqlStringCommand, "IsInUse", DbType.Boolean, IsInUse); using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { template = ReaderConvert.ReaderToModel <VshopDesignTemplate>(dataReader); } return(template); }
public static bool UpdateVshopDesignTemplate(VshopDesignTemplate template) { return(new VshopDesignTemplateDao().UpdateVshopDesignTemplate(template)); }