protected void Page_Load(object sender, EventArgs e) { Ajax.RegMethod(AddSite); cityList = CityDAO.Instance.GetCityList(); siteID = Utils.GetQueryInt("ID"); if (siteID > 0) { TuanSite tuanSite = TuanSiteDAO.Instance.GetModel(siteID); if (tuanSite != null) { txt_SiteName.Value = tuanSite.SiteName; txt_SiteUrl.Value = tuanSite.SiteUrl; txt_LogoUrl.Value = tuanSite.LogoUrl; txt_ApiUrl.Value = tuanSite.ApiUrl; txt_QQ.Value = tuanSite.QQ; cityID = tuanSite.CityID; apiTypeID = tuanSite.ApiTypeID; if (tuanSite.SiteType == 0) { rdo_SiteType_1.Checked = true; } else { rdo_SiteType_2.Checked = true; } } } }
/// <summary> /// 添加团购网站 /// </summary> public override int Add(TuanSite model) { string strSql = @"insert into TN_TuanSite(UserID,CityID,SiteUrl,LogoUrl,ApiUrl,SiteName,Description,OpenDate,CategoryID,TuanCount,CommentCount,ClickCount,Master,ContactPerson,Phone,Email,QQ,ApiTypeID,SiteType,Rank,Trust,IsVerify,AddDate,OrderID) values (@UserID,@CityID,@SiteUrl,@LogoUrl,@ApiUrl,@SiteName,@Description,@OpenDate,@CategoryID,@TuanCount,@CommentCount,@ClickCount,@Master,@ContactPerson,@Phone,@Email,@QQ,@ApiTypeID,@SiteType,@Rank,@Trust,@IsVerify,@AddDate,@OrderID)"; SqlParameter[] parms = { SqlHelper.CreateParameter <int>("@UserID", model.UserID, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@CityID", model.CityID, SqlDbType.Int, 4), SqlHelper.CreateParameter <string>("@SiteUrl", model.SiteUrl, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <string>("@LogoUrl", model.LogoUrl, SqlDbType.VarChar, 255), SqlHelper.CreateParameter <string>("@ApiUrl", model.ApiUrl, SqlDbType.VarChar, 255), SqlHelper.CreateParameter <string>("@SiteName", model.SiteName, SqlDbType.VarChar, 100), SqlHelper.CreateParameter <string>("@Description", model.Description, SqlDbType.VarChar, 1000), SqlHelper.CreateParameter <DateTime>("@OpenDate", model.OpenDate, SqlDbType.DateTime, 8), SqlHelper.CreateParameter <int>("@CategoryID", model.CategoryID, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@TuanCount", model.TuanCount, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@CommentCount", model.CommentCount, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@ClickCount", model.ClickCount, SqlDbType.Int, 4), SqlHelper.CreateParameter <string>("@Master", model.Master, SqlDbType.VarChar, 40), SqlHelper.CreateParameter <string>("@ContactPerson", model.ContactPerson, SqlDbType.VarChar, 40), SqlHelper.CreateParameter <string>("@Phone", model.Phone, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <string>("@Email", model.Email, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <string>("@QQ", model.QQ, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <byte>("@ApiTypeID", model.ApiTypeID, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@SiteType", model.SiteType, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@Rank", model.Rank, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@Trust", model.Trust, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@IsVerify", model.IsVerify, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <DateTime>("@AddDate", model.AddDate, SqlDbType.DateTime, 8), SqlHelper.CreateParameter <int>("@OrderID", model.OrderID, SqlDbType.Int, 4) }; return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSql, parms)); }
/// <summary> /// 更新团购网站 /// </summary> public override int Update(TuanSite model) { string strSql = "update TN_TuanSite set UserID=@UserID,CityID=@CityID,SiteUrl=@SiteUrl,LogoUrl=@LogoUrl,ApiUrl=@ApiUrl,SiteName=@SiteName,Description=@Description,OpenDate=@OpenDate,CategoryID=@CategoryID,TuanCount=@TuanCount,CommentCount=@CommentCount,ClickCount=@ClickCount,Master=@Master,ContactPerson=@ContactPerson,Phone=@Phone,Email=@Email,QQ=@QQ,ApiTypeID=@ApiTypeID,SiteType=@SiteType,Rank=@Rank,Trust=@Trust,IsVerify=@IsVerify,OrderID=@OrderID where SiteID=@SiteID"; SqlParameter[] parms = { SqlHelper.CreateParameter <int>("@SiteID", model.SiteID, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@UserID", model.UserID, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@CityID", model.CityID, SqlDbType.Int, 4), SqlHelper.CreateParameter <string>("@SiteUrl", model.SiteUrl, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <string>("@LogoUrl", model.LogoUrl, SqlDbType.VarChar, 255), SqlHelper.CreateParameter <string>("@ApiUrl", model.ApiUrl, SqlDbType.VarChar, 255), SqlHelper.CreateParameter <string>("@SiteName", model.SiteName, SqlDbType.VarChar, 100), SqlHelper.CreateParameter <string>("@Description", model.Description, SqlDbType.VarChar, 1000), SqlHelper.CreateParameter <DateTime>("@OpenDate", model.OpenDate, SqlDbType.DateTime, 8), SqlHelper.CreateParameter <int>("@CategoryID", model.CategoryID, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@TuanCount", model.TuanCount, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@CommentCount", model.CommentCount, SqlDbType.Int, 4), SqlHelper.CreateParameter <int>("@ClickCount", model.ClickCount, SqlDbType.Int, 4), SqlHelper.CreateParameter <string>("@Master", model.Master, SqlDbType.VarChar, 40), SqlHelper.CreateParameter <string>("@ContactPerson", model.ContactPerson, SqlDbType.VarChar, 40), SqlHelper.CreateParameter <string>("@Phone", model.Phone, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <string>("@Email", model.Email, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <string>("@QQ", model.QQ, SqlDbType.VarChar, 50), SqlHelper.CreateParameter <byte>("@ApiTypeID", model.ApiTypeID, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@SiteType", model.SiteType, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@Rank", model.Rank, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@Trust", model.Trust, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <byte>("@IsVerify", model.IsVerify, SqlDbType.TinyInt, 1), SqlHelper.CreateParameter <DateTime>("@AddDate", model.AddDate, SqlDbType.DateTime, 8), SqlHelper.CreateParameter <int>("@OrderID", model.OrderID, SqlDbType.Int, 4) }; return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSql, parms)); }
protected void btn_AddSite_Click(object sender, EventArgs e) { if (Session["User"] == null) { if (txt_UserName.Text == "") { JScript.ShowMessage(this, "请先登陆!"); return; } else { CheckUser(); } } TuanSite model = new TuanSite(); model.UserID = TryConvert.ToInt32(Session["User"]); model.CityID = Utils.GetFormInt("ddl_City"); model.SiteName = txt_SiteName.Value; model.SiteUrl = txt_SiteUrl.Value; if (model.SiteUrl.EndsWith("/")) { model.SiteUrl = model.SiteUrl.TrimEnd('/'); } model.LogoUrl = txt_LogoUrl.Value; model.ApiUrl = txt_ApiUrl.Value; model.QQ = txt_QQ.Value; model.SiteType = rdb_SiteType_1.Checked == true ? (byte)1 : (byte)0; model.Rank = TryConvert.ToByte(txt_Rank.Value); model.Trust = TryConvert.ToByte(txt_Trust.Value); model.Description = string.Empty; model.Master = string.Empty; model.ContactPerson = string.Empty; model.Phone = string.Empty; model.Email = string.Empty; model.OpenDate = DateTime.Now; model.AddDate = DateTime.Now; model.IsVerify = (byte)1; int ret = TuanSiteDAO.Instance.Add(model); if (ret > 0) { JScript.ShowMessage(this, "添加成功!"); } else { JScript.ShowMessage(this, "添加失败!"); } }
/// <summary> /// 获取团购网站API信息 /// </summary> public override TuanSite GetApiInfo(int siteID) { string strSql = "SELECT TOP 1 SiteUrl,ApiUrl,ApiTypeID FROM TN_TuanSite WHERE SiteID=" + siteID; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql)) { if (dr.Read()) { TuanSite tuanSite = new TuanSite(); tuanSite.SiteUrl = SqlHelper.GetString(dr["SiteUrl"]); tuanSite.ApiUrl = SqlHelper.GetString(dr["ApiUrl"]); tuanSite.ApiTypeID = SqlHelper.GetByte(dr["ApiTypeID"]); return(tuanSite); } return(null); } }
/// <summary> /// 返回团购网站实体 /// </summary> public override TuanSite GetModel(int siteID) { string strSql = "select top 1 SiteID,CityID,SiteUrl,LogoUrl,ApiUrl,SiteName,Description,OpenDate,CategoryID,TuanCount,CommentCount,ClickCount,Master,ContactPerson,Phone,Email,QQ,ApiTypeID,SiteType,Rank,Trust,IsVerify,AddDate from TN_TuanSite where SiteID=@SiteID"; SqlParameter[] parms = { SqlHelper.CreateParameter <int>("@SiteID", siteID, SqlDbType.Int, 4) }; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, parms)) { if (dr.Read()) { TuanSite tuanSite = new TuanSite(); tuanSite.SiteID = SqlHelper.GetInt(dr["SiteID"]); tuanSite.CityID = SqlHelper.GetInt(dr["CityID"]); tuanSite.SiteUrl = SqlHelper.GetString(dr["SiteUrl"]); tuanSite.LogoUrl = SqlHelper.GetString(dr["LogoUrl"]); tuanSite.ApiUrl = SqlHelper.GetString(dr["ApiUrl"]); tuanSite.SiteName = SqlHelper.GetString(dr["SiteName"]); tuanSite.Description = SqlHelper.GetString(dr["Description"]); tuanSite.OpenDate = SqlHelper.GetDateTime(dr["OpenDate"]); tuanSite.CategoryID = SqlHelper.GetInt(dr["CategoryID"]); tuanSite.TuanCount = SqlHelper.GetInt(dr["TuanCount"]); tuanSite.CommentCount = SqlHelper.GetInt(dr["CommentCount"]); tuanSite.ClickCount = SqlHelper.GetInt(dr["ClickCount"]); tuanSite.Master = SqlHelper.GetString(dr["Master"]); tuanSite.ContactPerson = SqlHelper.GetString(dr["ContactPerson"]); tuanSite.Phone = SqlHelper.GetString(dr["Phone"]); tuanSite.Email = SqlHelper.GetString(dr["Email"]); tuanSite.QQ = SqlHelper.GetString(dr["QQ"]); tuanSite.ApiTypeID = SqlHelper.GetByte(dr["ApiTypeID"]); tuanSite.SiteType = SqlHelper.GetByte(dr["SiteType"]); tuanSite.Rank = SqlHelper.GetByte(dr["Rank"]); tuanSite.Trust = SqlHelper.GetByte(dr["Trust"]); tuanSite.IsVerify = SqlHelper.GetByte(dr["IsVerify"]); tuanSite.AddDate = SqlHelper.GetDateTime(dr["AddDate"]); return(tuanSite); } return(null); } }
private void AddSite() { TuanSite model = new TuanSite(); model.SiteID = Utils.GetQueryInt("ID"); model.UserID = loginUser.UserID; model.CityID = Utils.GetFormInt("ddl_City"); model.SiteName = Utils.GetFormString("txt_SiteName"); model.SiteUrl = Utils.GetFormString("txt_SiteUrl"); if (model.SiteUrl.EndsWith("/")) { model.SiteUrl = model.SiteUrl.TrimEnd('/'); } model.LogoUrl = Utils.GetFormString("txt_LogoUrl"); model.ApiTypeID = (byte)Utils.GetFormInt("ddl_ApiTypeID"); model.ApiUrl = Utils.GetFormString("txt_ApiUrl"); model.QQ = Utils.GetFormString("txt_QQ"); model.SiteType = 1; //Utils.GetFormString("rdo_SiteType"); model.Rank = TryConvert.ToByte(Utils.GetFormInt("txt_Rank")); model.Trust = TryConvert.ToByte(Utils.GetFormInt("txt_Trust")); model.Description = string.Empty; model.Master = string.Empty; model.ContactPerson = string.Empty; model.Phone = string.Empty; model.Email = string.Empty; model.OpenDate = DateTime.Now; model.AddDate = DateTime.Now; model.IsVerify = 1; int result = 0; if (model.SiteID > 0) { result = TuanSiteDAO.Instance.Update(model); } else { result = TuanSiteDAO.Instance.Add(model); } Ajax.Message(result); }
/// <summary> /// 更新团购网站 /// </summary> public abstract int Update(TuanSite model);
/// <summary> /// 添加团购网站 /// </summary> public abstract int Add(TuanSite model);