/// <summary> /// 得到一个对象实体 /// </summary> public AstroDiceMod GetModel(int SysNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SysNo, Question, Constellation, House, Star, TS, Pic, UserSysNo, Source from Apps.dbo.AstroDice"); strSql.Append(" where SysNo=@SysNo "); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int, 4) }; parameters[0].Value = SysNo; AstroDiceMod model = new AstroDiceMod(); DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "") { model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString()); } model.Question = ds.Tables[0].Rows[0]["Question"].ToString(); if (ds.Tables[0].Rows[0]["Constellation"].ToString() != "") { model.Constellation = int.Parse(ds.Tables[0].Rows[0]["Constellation"].ToString()); } if (ds.Tables[0].Rows[0]["House"].ToString() != "") { model.House = int.Parse(ds.Tables[0].Rows[0]["House"].ToString()); } if (ds.Tables[0].Rows[0]["Star"].ToString() != "") { model.Star = int.Parse(ds.Tables[0].Rows[0]["Star"].ToString()); } if (ds.Tables[0].Rows[0]["TS"].ToString() != "") { model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString()); } model.Pic = ds.Tables[0].Rows[0]["Pic"].ToString(); if (ds.Tables[0].Rows[0]["UserSysNo"].ToString() != "") { model.UserSysNo = int.Parse(ds.Tables[0].Rows[0]["UserSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["Source"].ToString() != "") { model.Source = int.Parse(ds.Tables[0].Rows[0]["Source"].ToString()); } return(model); } else { return(null); } }
protected void Button2_Click(object sender, EventArgs e) { try { AstroDiceMod model = new AstroDiceMod { House = ((((-(int.Parse(this.gong.Value) / 30) + 4) + 12) - 1) % 12) + 1, Constellation = ((((360 - ((int.Parse(this.gong.Value) - 90) - Convert.ToInt16(Math.Floor(decimal.Parse(this.xingzuo.Value))))) / 30) + 12) % 12) + 1, Question = this.flashtitle.Value }; Literal2.Text = stars[int.Parse(this.dice.Value)] + "<br />"; if (this.dice.Value == "10") { this.dice.Value = "15"; } else if (this.dice.Value == "11") { this.dice.Value = "32"; } model.Star = int.Parse(this.dice.Value) + 1; this.ViewState["Pic"] = model.Pic; AstroDiceBll.GetInstance().Add(model); this.dice.Value = model.Star.ToString(); this.gong.Value = model.House.ToString(); this.xingzuo.Value = model.Constellation.ToString(); Literal1.Text = PublicValue.GetAstroStar(model.Star) + " " + model.House + "宫 " + PublicValue.GetConstellation(model.Constellation); Literal2.Text += house[model.House - 1] + "<br />"; Literal2.Text += constellation[model.Constellation - 1]; string content = "#占星骰子# #" + Literal1.Text + "# “" + flashtitle.Value + "”,求占卜师解答!"; //string[] tmp = HiddenField1.Value.Split(new char[] { '|' }); //for (int i = 0; i < tmp.Length; i++) //{ // if (tmp[i] != "") // { // content += " @" + tmp[i]; // } //} content += " @蓝雪鳳兒 @青花 @一然 @采薇 @山有扶苏 @黄小鞋"; TextBox1.Text = content; Button1.PostBackUrl = "http://share.v.t.qq.com/index.php?c=share&a=index&url=" + Server.UrlEncode("http://astro.fashion.qq.com/app/astrodice.htm") + "&pic=" + Server.UrlEncode("http://app.ssqian.com/WebResources/DicePic/" + filename.Value + ".jpg") + "&appkey=801402959&title=" + Server.UrlEncode(content.Replace("@蓝雪鳳兒 @青花 @一然 @采薇 @山有扶苏 @黄小鞋", "@iamsnowsnow @bubuzhanxing @yiraneasy @susan1114 @god82953378 @yellowlittleshoes") + " 好玩好准的占星骰子,亲们也来试试:") + "&line1=&line2=&line3="; } catch { } }
// Methods protected void Button1_Click(object sender, EventArgs e) { try { AstroDiceMod model = new AstroDiceMod { House = ((((-(int.Parse(this.gong.Value) / 30) + 4) + 12) - 1) % 12) + 1, Constellation = ((((360 - ((int.Parse(this.gong.Value) - 90) - Convert.ToInt16(Math.Floor(decimal.Parse(this.xingzuo.Value))))) / 30) + 12) % 12) + 1, Question = this.flashtitle.Value }; if (this.dice.Value == "10") { this.dice.Value = "15"; } else if (this.dice.Value == "11") { this.dice.Value = "32"; } model.Star = int.Parse(this.dice.Value) + 1; model.TS = DateTime.Now; model.UserSysNo = QQWeiBoUserBll.GetInstance().GetRecordByName(this.wb_name).SysNo; model.Source = 1; model.Pic = ""; this.ViewState["Pic"] = model.Pic; AstroDiceBll.GetInstance().Add(model); this.LinkButton8.Text = PublicValue.GetAstroStar(model.Star) + " "; this.LinkButton9.Text = model.House + "宫 "; this.LinkButton10.Text = PublicValue.GetConstellation(model.Constellation); this.LinkButton8.Style["display"] = ""; this.LinkButton9.Style["display"] = ""; this.LinkButton10.Style["display"] = ""; this.dice.Value = model.Star.ToString(); this.gong.Value = model.House.ToString(); this.xingzuo.Value = model.Constellation.ToString(); this.LinkButton8_Click(this.LinkButton8, e); this.TextBox1.Text = string.Concat(new object[] { "#占星骰子# #", PublicValue.GetAstroStar(model.Star), " ", model.House, "宫 ", PublicValue.GetConstellation(model.Constellation), "# “", model.Question, "”,求占卜师解答!亲们也来试试吧! http://app.t.qq.com/app/play/801272340" }); } catch { } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(AstroDiceMod model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(AstroDiceMod model) { return dal.Add(model); }
protected void Button2_Click(object sender, EventArgs e) { try { AstroDiceMod model = new AstroDiceMod { House = ((((-(int.Parse(this.gong.Value) / 30) + 4) + 12) - 1) % 12) + 1, Constellation = ((((360 - ((int.Parse(this.gong.Value) - 90) - Convert.ToInt16(Math.Floor(decimal.Parse(this.xingzuo.Value))))) / 30) + 12) % 12) + 1, Question = this.flashtitle.Value }; Literal2.Text = stars[int.Parse(this.dice.Value)] + "<br />"; if (this.dice.Value == "10") { this.dice.Value = "15"; } else if (this.dice.Value == "11") { this.dice.Value = "32"; } model.Star = int.Parse(this.dice.Value) + 1; this.ViewState["Pic"] = model.Pic; AstroDiceBll.GetInstance().Add(model); this.dice.Value = model.Star.ToString(); this.gong.Value = model.House.ToString(); this.xingzuo.Value = model.Constellation.ToString(); Literal1.Text = PublicValue.GetAstroStar(model.Star) + " " + model.House + "宫 " + PublicValue.GetConstellation(model.Constellation); Literal2.Text += house[model.House-1]+ "<br />"; Literal2.Text += constellation[model.Constellation-1]; string content = "#占星骰子# #" + Literal1.Text + "# “" + flashtitle.Value + "”,求占卜师解答!"; //string[] tmp = HiddenField1.Value.Split(new char[] { '|' }); //for (int i = 0; i < tmp.Length; i++) //{ // if (tmp[i] != "") // { // content += " @" + tmp[i]; // } //} content += " @蓝雪鳳兒 @青花 @一然 @采薇 @山有扶苏 @黄小鞋"; TextBox1.Text = content; Button1.PostBackUrl = "http://share.v.t.qq.com/index.php?c=share&a=index&url=" + Server.UrlEncode("http://astro.fashion.qq.com/app/astrodice.htm") + "&pic=" + Server.UrlEncode("http://app.ssqian.com/WebResources/DicePic/" + filename.Value + ".jpg") + "&appkey=801402959&title=" + Server.UrlEncode(content.Replace("@蓝雪鳳兒 @青花 @一然 @采薇 @山有扶苏 @黄小鞋", "@iamsnowsnow @bubuzhanxing @yiraneasy @susan1114 @god82953378 @yellowlittleshoes") + " 好玩好准的占星骰子,亲们也来试试:") + "&line1=&line2=&line3="; } catch { } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(AstroDiceMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Apps.dbo.AstroDice("); strSql.Append("Question,Constellation,House,Star,TS,Pic,UserSysNo,Source)"); strSql.Append(" values ("); strSql.Append("@Question,@Constellation,@House,@Star,@TS,@Pic,@UserSysNo,@Source)"); strSql.Append(";select @@IDENTITY"); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@Question", SqlDbType.NVarChar, 600), new SqlParameter("@Constellation", SqlDbType.Int, 4), new SqlParameter("@House", SqlDbType.Int, 4), new SqlParameter("@Star", SqlDbType.Int, 4), new SqlParameter("@TS", SqlDbType.DateTime), new SqlParameter("@Pic", SqlDbType.VarChar, 100), new SqlParameter("@UserSysNo", SqlDbType.Int, 4), new SqlParameter("@Source", SqlDbType.Int, 4), }; if (model.Question != AppConst.StringNull) { parameters[0].Value = model.Question; } else { parameters[0].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[0]); if (model.Constellation != AppConst.IntNull) { parameters[1].Value = model.Constellation; } else { parameters[1].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[1]); if (model.House != AppConst.IntNull) { parameters[2].Value = model.House; } else { parameters[2].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[2]); if (model.Star != AppConst.IntNull) { parameters[3].Value = model.Star; } else { parameters[3].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[3]); if (model.TS != AppConst.DateTimeNull) { parameters[4].Value = model.TS; } else { parameters[4].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[4]); if (model.Pic != AppConst.StringNull) { parameters[5].Value = model.Pic; } else { parameters[5].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[5]); if (model.UserSysNo != AppConst.IntNull) { parameters[6].Value = model.UserSysNo; } else { parameters[6].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[6]); if (model.Source != AppConst.IntNull) { parameters[7].Value = model.Source; } else { parameters[7].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[7]); return(SqlHelper.ExecuteNonQuery(cmd, parameters)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(AstroDiceMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Apps.dbo.AstroDice set "); strSql.Append("Question=@Question,"); strSql.Append("Constellation=@Constellation,"); strSql.Append("House=@House,"); strSql.Append("Star=@Star,"); strSql.Append("TS=@TS,"); strSql.Append("Pic=@Pic,"); strSql.Append("UserSysNo=@UserSysNo,"); strSql.Append("Source=@Source"); strSql.Append(" where SysNo=@SysNo "); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int, 4), new SqlParameter("@Question", SqlDbType.NVarChar, 600), new SqlParameter("@Constellation", SqlDbType.Int, 4), new SqlParameter("@House", SqlDbType.Int, 4), new SqlParameter("@Star", SqlDbType.Int, 4), new SqlParameter("@TS", SqlDbType.DateTime), new SqlParameter("@Pic", SqlDbType.VarChar, 100), new SqlParameter("@UserSysNo", SqlDbType.Int, 4), new SqlParameter("@Source", SqlDbType.Int, 4) }; if (model.SysNo != AppConst.IntNull) { parameters[0].Value = model.SysNo; } else { parameters[0].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[0]); if (model.Question != AppConst.StringNull) { parameters[1].Value = model.Question; } else { parameters[1].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[1]); if (model.Constellation != AppConst.IntNull) { parameters[2].Value = model.Constellation; } else { parameters[2].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[2]); if (model.House != AppConst.IntNull) { parameters[3].Value = model.House; } else { parameters[3].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[3]); if (model.Star != AppConst.IntNull) { parameters[4].Value = model.Star; } else { parameters[4].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[4]); if (model.TS != AppConst.DateTimeNull) { parameters[5].Value = model.TS; } else { parameters[5].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[5]); if (model.Pic != AppConst.StringNull) { parameters[6].Value = model.Pic; } else { parameters[6].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[6]); if (model.UserSysNo != AppConst.IntNull) { parameters[7].Value = model.UserSysNo; } else { parameters[7].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[7]); if (model.Source != AppConst.IntNull) { parameters[8].Value = model.Source; } else { parameters[8].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[8]); return(SqlHelper.ExecuteNonQuery(cmd, parameters)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(AstroDiceMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Apps.dbo.AstroDice("); strSql.Append("Question,Constellation,House,Star,TS,Pic,UserSysNo,Source)"); strSql.Append(" values ("); strSql.Append("@Question,@Constellation,@House,@Star,@TS,@Pic,@UserSysNo,@Source)"); strSql.Append(";select @@IDENTITY"); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@Question",SqlDbType.NVarChar,600), new SqlParameter("@Constellation",SqlDbType.Int,4), new SqlParameter("@House",SqlDbType.Int,4), new SqlParameter("@Star",SqlDbType.Int,4), new SqlParameter("@TS",SqlDbType.DateTime), new SqlParameter("@Pic",SqlDbType.VarChar,100), new SqlParameter("@UserSysNo",SqlDbType.Int,4), new SqlParameter("@Source",SqlDbType.Int,4), }; if (model.Question != AppConst.StringNull) parameters[0].Value = model.Question; else parameters[0].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[0]); if (model.Constellation != AppConst.IntNull) parameters[1].Value = model.Constellation; else parameters[1].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[1]); if (model.House != AppConst.IntNull) parameters[2].Value = model.House; else parameters[2].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[2]); if (model.Star != AppConst.IntNull) parameters[3].Value = model.Star; else parameters[3].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[3]); if (model.TS != AppConst.DateTimeNull) parameters[4].Value = model.TS; else parameters[4].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[4]); if (model.Pic != AppConst.StringNull) parameters[5].Value = model.Pic; else parameters[5].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[5]); if (model.UserSysNo != AppConst.IntNull) parameters[6].Value = model.UserSysNo; else parameters[6].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[6]); if (model.Source != AppConst.IntNull) parameters[7].Value = model.Source; else parameters[7].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[7]); return SqlHelper.ExecuteNonQuery(cmd,parameters); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(AstroDiceMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Apps.dbo.AstroDice set "); strSql.Append("Question=@Question,"); strSql.Append("Constellation=@Constellation,"); strSql.Append("House=@House,"); strSql.Append("Star=@Star,"); strSql.Append("TS=@TS,"); strSql.Append("Pic=@Pic,"); strSql.Append("UserSysNo=@UserSysNo,"); strSql.Append("Source=@Source"); strSql.Append(" where SysNo=@SysNo "); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@SysNo",SqlDbType.Int,4), new SqlParameter("@Question",SqlDbType.NVarChar,600), new SqlParameter("@Constellation",SqlDbType.Int,4), new SqlParameter("@House",SqlDbType.Int,4), new SqlParameter("@Star",SqlDbType.Int,4), new SqlParameter("@TS",SqlDbType.DateTime), new SqlParameter("@Pic",SqlDbType.VarChar,100), new SqlParameter("@UserSysNo",SqlDbType.Int,4), new SqlParameter("@Source",SqlDbType.Int,4) }; if (model.SysNo != AppConst.IntNull) parameters[0].Value = model.SysNo; else parameters[0].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[0]); if (model.Question != AppConst.StringNull) parameters[1].Value = model.Question; else parameters[1].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[1]); if (model.Constellation != AppConst.IntNull) parameters[2].Value = model.Constellation; else parameters[2].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[2]); if (model.House != AppConst.IntNull) parameters[3].Value = model.House; else parameters[3].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[3]); if (model.Star != AppConst.IntNull) parameters[4].Value = model.Star; else parameters[4].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[4]); if (model.TS != AppConst.DateTimeNull) parameters[5].Value = model.TS; else parameters[5].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[5]); if (model.Pic != AppConst.StringNull) parameters[6].Value = model.Pic; else parameters[6].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[6]); if (model.UserSysNo != AppConst.IntNull) parameters[7].Value = model.UserSysNo; else parameters[7].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[7]); if (model.Source != AppConst.IntNull) parameters[8].Value = model.Source; else parameters[8].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[8]); return SqlHelper.ExecuteNonQuery(cmd,parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public AstroDiceMod GetModel(int SysNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SysNo, Question, Constellation, House, Star, TS, Pic, UserSysNo, Source from Apps.dbo.AstroDice"); strSql.Append(" where SysNo=@SysNo "); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int,4 ) }; parameters[0].Value = SysNo; AstroDiceMod model = new AstroDiceMod(); DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "") { model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString()); } model.Question = ds.Tables[0].Rows[0]["Question"].ToString(); if (ds.Tables[0].Rows[0]["Constellation"].ToString() != "") { model.Constellation = int.Parse(ds.Tables[0].Rows[0]["Constellation"].ToString()); } if (ds.Tables[0].Rows[0]["House"].ToString() != "") { model.House = int.Parse(ds.Tables[0].Rows[0]["House"].ToString()); } if (ds.Tables[0].Rows[0]["Star"].ToString() != "") { model.Star = int.Parse(ds.Tables[0].Rows[0]["Star"].ToString()); } if (ds.Tables[0].Rows[0]["TS"].ToString() != "") { model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString()); } model.Pic = ds.Tables[0].Rows[0]["Pic"].ToString(); if (ds.Tables[0].Rows[0]["UserSysNo"].ToString() != "") { model.UserSysNo = int.Parse(ds.Tables[0].Rows[0]["UserSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["Source"].ToString() != "") { model.Source = int.Parse(ds.Tables[0].Rows[0]["Source"].ToString()); } return model; } else { return null; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(AstroDiceMod model) { return(dal.Add(model)); }