protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["id"] == null) { Response.Write("<script>window.alert('您没有选择公告,无法传值');window.location=index.aspx;</script>"); } else { ViewState["BackUrl"] = Request.UrlReferrer.ToString(); string a = Request.QueryString["id"].ToString(); modnotices = bllnotices.GetModel(Convert.ToInt16(a)); N_ID.Text = modnotices.N_ID.ToString(); DataTable dt = bllnotices.GetList1(a).Tables[0]; if (dt.Rows.Count > 0) { Username.Text = dt.Rows[0]["Username"].ToString(); string date = dt.Rows[0]["N_time"].ToString(); date = date.Replace(" 0:00:00", ""); N_time.Text = date.ToString().Trim(); Text_title.Text = dt.Rows[0]["N_title"].ToString(); Text_text.Value = dt.Rows[0]["N_text"].ToString(); Text_text0.Value = dt.Rows[0]["N_intro"].ToString(); } } } }
public void dataload() { TtNum1.BLL.Notice bllnotic = new TtNum1.BLL.Notice(); TtNum1.Model.Notice molnotic = new TtNum1.Model.Notice(); molnotic = bllnotic.GetModel(int.Parse(Request["id"])); lblnotice_title.Text = molnotic.N_title; lblnotice_time.Text = molnotic.N_time.ToShortDateString(); lblnotice_text.Text = molnotic.N_text; }
/* */ /// <summary> /// 后台方法 /// </summary> /// <param name="username"></param> /// <returns></returns> public TtNum1.Model.Notice DataRowToModel_1(DataRow row) { TtNum1.Model.Notice model = new TtNum1.Model.Notice(); if (row != null) { if (row["User_ID"] != null && row["User_ID"].ToString() != "") { model.U_ID = int.Parse(row["User_ID"].ToString()); } } return model; }
protected void RadButton1_Click(object sender, EventArgs e) { if (text2.Value == "" || text4.Value == "" || text3.Value == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('公告内容填写不全!');</script>"); return; } string a = Session["ht_username"].ToString(); modnotices = bllnotices.GetModel_1(a); int b = Int32.Parse(modnotices.U_ID.ToString()); modnotices.N_title = text2.Value; modnotices.N_text = text3.Value; modnotices.N_time = DateTime.Now; modnotices.N_intro = text4.Value; bllnotices.Add(modnotices); Response.Write("<script language=javascript>alert('添加成功!')</script>"); Response.Write("<script language=javascript>window.location.href=('index.aspx')</script>"); }
public TtNum1.Model.Notice GetModel_1(string username) { StringBuilder strSql = new StringBuilder(); strSql.Append("select UserInfo.User_ID "); strSql.Append("from UserInfo where UserInfo.Username='******'; "); TtNum1.Model.Notice model = new TtNum1.Model.Notice(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { string a = ds.Tables[0].Rows[0]["User_ID"].ToString(); return DataRowToModel_1(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public TtNum1.Model.Notice GetModel(int N_ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" N_ID,N_title,U_ID,N_time,N_intro,N_text "); strSql.Append(" from Notice "); strSql.Append(" where N_ID="+N_ID+"" ); TtNum1.Model.Notice model=new TtNum1.Model.Notice(); DataSet ds=DbHelperSQL.Query(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["N_ID"]!=null && ds.Tables[0].Rows[0]["N_ID"].ToString()!="") { model.N_ID=int.Parse(ds.Tables[0].Rows[0]["N_ID"].ToString()); } if(ds.Tables[0].Rows[0]["N_title"]!=null && ds.Tables[0].Rows[0]["N_title"].ToString()!="") { model.N_title=ds.Tables[0].Rows[0]["N_title"].ToString(); } if(ds.Tables[0].Rows[0]["U_ID"]!=null && ds.Tables[0].Rows[0]["U_ID"].ToString()!="") { model.U_ID=int.Parse(ds.Tables[0].Rows[0]["U_ID"].ToString()); } if(ds.Tables[0].Rows[0]["N_time"]!=null && ds.Tables[0].Rows[0]["N_time"].ToString()!="") { model.N_time=DateTime.Parse(ds.Tables[0].Rows[0]["N_time"].ToString()); } if(ds.Tables[0].Rows[0]["N_intro"]!=null && ds.Tables[0].Rows[0]["N_intro"].ToString()!="") { model.N_intro=ds.Tables[0].Rows[0]["N_intro"].ToString(); } if(ds.Tables[0].Rows[0]["N_text"]!=null && ds.Tables[0].Rows[0]["N_text"].ToString()!="") { model.N_text=ds.Tables[0].Rows[0]["N_text"].ToString(); } return model; } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public TtNum1.Model.Notice DataRowToModel(DataRow row) { TtNum1.Model.Notice model=new TtNum1.Model.Notice(); if (row != null) { if(row["N_ID"]!=null && row["N_ID"].ToString()!="") { model.N_ID=int.Parse(row["N_ID"].ToString()); } if(row["N_title"]!=null) { model.N_title=row["N_title"].ToString(); } if(row["U_ID"]!=null && row["U_ID"].ToString()!="") { model.U_ID=int.Parse(row["U_ID"].ToString()); } if(row["N_time"]!=null && row["N_time"].ToString()!="") { model.N_time=DateTime.Parse(row["N_time"].ToString()); } if(row["N_text"]!=null) { model.N_text=row["N_text"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public TtNum1.Model.Notice GetModel(int N_ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" N_ID,N_title,U_ID,N_time,N_text "); strSql.Append(" from Notice "); strSql.Append(" where N_ID="+N_ID+"" ); TtNum1.Model.Notice model=new TtNum1.Model.Notice(); DataSet ds=DbHelperSQL.Query(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }