コード例 #1
0
 /// <summary>
 /// 添加一个自定义标签
 /// </summary>
 /// <param name="value">自定义标签数据</param>
 /// <returns>返回新增的自定义标签的ID</returns>
 public int InsertMyTag(MyTagItem value)
 {
     int id = 0;
     _DbParameter[] pars ={
                            new _DbParameter().Set("@Key", DbType.String, value.Key),
                            new _DbParameter().Set("@Intro", DbType.String, value.Intro),
                            new _DbParameter().Set("@Code", DbType.String, value.Code),
                            new _DbParameter().Set("@Publish", DbType.String, value.Publish.ToString("yyyy-MM-dd HH:mm:ss")),
                            new _DbParameter().Set("@Priority", DbType.Int32, value.Priority),
                            new _DbParameter().Set("@Show", DbType.Int32, value.Show ? 1 : 0)
                        };
     conn.ExecuteNonQuery("INSERT INTO [MyTag] ([Key], [Intro], [Code], [Publish], [Priority], [Show]) VALUES (@Key, @Intro, @Code, @Publish, @Priority, @Show)", pars);
     id = Convert.ToInt32(conn.ExecuteNewField("[MyTag]", null, null));
     return id;
 }
コード例 #2
0
 /// <summary>
 /// 取得自定义标签
 /// </summary>
 /// <param name="id">自定义标签编号</param>
 /// <returns>返回自定义标签数据</returns>
 public MyTagItem GetMyTag(int id)
 {
     MyTagItem item = new MyTagItem();
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[MyTag]", "[ID], [Key], [Intro], [Code], [Publish], [Priority], [Show]", string.Format("[ID] = {0}", id), null, null, 1, 1, ref rows))
     {
         while (reader.Read())
         {
             item.ID = reader.GetInt32(0);
             item.Key = reader.GetString(1);
             item.Intro = reader.GetString(2);
             item.Code = reader.GetString(3);
             item.Publish = reader.GetDateTime(4);
             item.Priority = reader.GetInt32(5);
             item.Show = reader.GetInt32(6) == 0 ? false : true;
         }
     }
     return item;
 }
コード例 #3
0
 /// <summary>
 /// 筛选自定义标签
 /// </summary>
 /// <param name="intCurPage">当前页码</param>
 /// <param name="btePerPage">分页大小</param>
 /// <param name="selAll">是否在所有数据里筛选</param>
 /// <returns>返回自定义标签数据列表</returns>
 public DataList<MyTagItem> SelectMyTag(int intCurPage, int btePerPage, bool selAll)
 {
     DataList<MyTagItem> list = new DataList<MyTagItem>();
     string sqlWhere = selAll ? string.Empty : "[Show] <> 0";
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[MyTag]", "[ID], [Key], [Intro], [Code], [Publish], [Priority], [Show]", sqlWhere, "[Priority]", "ASC", intCurPage, btePerPage, ref rows))
     {
         while (reader.Read())
         {
             MyTagItem item = new MyTagItem();
             item.ID = reader.GetInt32(0);
             item.Key = reader.GetString(1);
             item.Intro = reader.GetString(2);
             item.Code = reader.GetString(3);
             item.Publish = reader.GetDateTime(4);
             item.Priority = reader.GetInt32(5);
             item.Show = reader.GetInt32(6) == 0 ? false : true;
             list.Add(item);
         }
     }
     list.Number = rows;
     return list;
 }
コード例 #4
0
 /// <summary>
 /// 修改一个自定义标签
 /// </summary>
 /// <param name="value">自定义标签数据</param>
 /// <returns>返回被修改的自定义标签编号</returns>
 public int UpdateMyTag(MyTagItem value)
 {
     int id = 0;
     _DbParameter[] pars ={
                            new _DbParameter().Set("@Key", DbType.String, value.Key),
                            new _DbParameter().Set("@Intro", DbType.String, value.Intro),
                            new _DbParameter().Set("@Code", DbType.String, value.Code),
                            new _DbParameter().Set("@Publish", DbType.String, value.Publish.ToString("yyyy-MM-dd HH:mm:ss")),
                            new _DbParameter().Set("@Priority", DbType.Int32, value.Priority),
                            new _DbParameter().Set("@Show", DbType.Int32, value.Show ? 1 : 0),
                            new _DbParameter().Set("@ID", DbType.Int32, value.ID)
                        };
     conn.ExecuteNonQuery("UPDATE [MyTag] SET [Key] = @Key, [Intro] = @Intro, [Code] = @Code, [Publish] = @Publish, [Priority] = @Priority, [Show] = @Show WHERE [ID] = @ID", pars);
     id = value.ID;
     return id;
 }
コード例 #5
0
 /// <summary>
 /// 提交页面窗体
 /// </summary>
 /// <returns>返回发布页面控件代码</returns>
 public string Post()
 {
     StringBuilder sr = new StringBuilder();
     int id = SiteFun.ToInt(SiteFun.Query("id"));
     MyTagData mtData = new MyTagData(conn);
     if (SiteFun.IsPost)
     {
         MyTagItem postVal = new MyTagItem();
         postVal.ID = id;
         postVal.Key = SiteFun.Post("key");
         postVal.Intro = SiteFun.Post("intro");
         postVal.Code = SiteFun.Post("code");
         postVal.Publish = SiteFun.ToDate(SiteFun.Post("publish"));
         postVal.Priority = SiteFun.ToInt(SiteFun.Post("priority"));
         postVal.Show = SiteFun.ToInt(SiteFun.Post("show")) == 0 ? false : true;
         if (string.IsNullOrEmpty(postVal.Key)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoKey"))); }
         else
         {
             if (postVal.ID == 0) { mtData.InsertMyTag(postVal); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgInsertDat"), "?act=myTag&mode=list")); }
             else { mtData.UpdateMyTag(postVal); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgUpdateDat"), "?act=myTag&mode=list")); }
         }
         ClearCache();
     }
     //取得默认值
     MyTagItem old = mtData.GetMyTag(id);
     sr.Append(AdminUI.AdminBoxStart(true));
     sr.Append(HtmlUI.FormStart());
     sr.Append(HtmlUI.TableStart("onCenter"));
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Key")) + HtmlUI.CreateTd(HtmlUI.Input("key", 20, null, SiteFun.HtmlEncode(old.Key))));
     sr.Append(HtmlUI.TrFinal());
     if (old.ID > 0)
     {
         sr.Append(HtmlUI.TrStart());
         sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(SiteFun.HtmlEncode(string.Format("<xsl:value-of select=\"/ui/myTag/{0}\" disable-output-escaping=\"yes\"/>", old.Key))));
         sr.Append(HtmlUI.TrFinal());
     }
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Intro")) + HtmlUI.CreateTd(HtmlUI.Input("intro", 50, null, SiteFun.HtmlEncode(old.Intro))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Content")) + HtmlUI.CreateTd(HtmlUI.Textarea("code", 15, 80, SiteFun.HtmlEncode(old.Code))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("DateTime")) + HtmlUI.CreateTd(HtmlUI.Input("publish", 20, null, old.Publish)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Priority")) + HtmlUI.CreateTd(HtmlUI.Input("priority", 5, null, old.Priority)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Virtue")) + HtmlUI.CreateTd(HtmlUI.CheckBoxInput(SiteDat.GetLan("Show"), "show", 1, old.Show)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(HtmlUI.SubmitButton() + HtmlUI.ResetButton()));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TableFinal());
     sr.Append(HtmlUI.FormFinal());
     sr.Append(AdminUI.AdminBoxFinal());
     return sr.ToString();
 }