//保存 protected void btnSave_Click(object sender, EventArgs e) { Spread.Model.Links model = new Spread.Model.Links(); Spread.BLL.Links bll = new Spread.BLL.Links(); model.Title = txtTitle.Text.Trim(); model.WebUrl = txtWebUrl.Text.Trim(); model.IsImage = 0; if (cbIsImage.Checked == true) { model.IsImage = 1; } model.ImgUrl = txtImgUrl.Text.Trim(); model.UserName = txtUserName.Text.Trim(); model.UserTel = txtUserTel.Text.Trim(); model.UserMail = txtUserMail.Text.Trim(); model.SortId = int.Parse(txtSortId.Text.Trim()); model.IsRed = 0; model.IsLock = 0; if (cblItem.Items[0].Selected == true) { model.IsRed = 1; } if (cblItem.Items[1].Selected == true) { model.IsLock = 1; } bll.Add(model); JscriptPrint("链接增加成功啦!", "Add.aspx", "Success"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Spread.Model.Links GetModel(int Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 Id,Title,UserName,UserTel,UserMail,WebUrl,ImgUrl,IsImage,IsRed,IsLock,SortId,AddTime from Links "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4)}; parameters[0].Value = Id; Spread.Model.Links model=new Spread.Model.Links(); DataSet ds=DbHelper.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["Id"].ToString()!="") { model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Title=ds.Tables[0].Rows[0]["Title"].ToString(); model.UserName=ds.Tables[0].Rows[0]["UserName"].ToString(); model.UserTel=ds.Tables[0].Rows[0]["UserTel"].ToString(); model.UserMail=ds.Tables[0].Rows[0]["UserMail"].ToString(); model.WebUrl=ds.Tables[0].Rows[0]["WebUrl"].ToString(); model.ImgUrl=ds.Tables[0].Rows[0]["ImgUrl"].ToString(); if(ds.Tables[0].Rows[0]["IsImage"].ToString()!="") { model.IsImage=int.Parse(ds.Tables[0].Rows[0]["IsImage"].ToString()); } if (ds.Tables[0].Rows[0]["IsRed"].ToString() != "") { model.IsRed = int.Parse(ds.Tables[0].Rows[0]["IsRed"].ToString()); } if(ds.Tables[0].Rows[0]["IsLock"].ToString()!="") { model.IsLock=int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString()); } if(ds.Tables[0].Rows[0]["SortId"].ToString()!="") { model.SortId=int.Parse(ds.Tables[0].Rows[0]["SortId"].ToString()); } if(ds.Tables[0].Rows[0]["AddTime"].ToString()!="") { model.AddTime=DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString()); } return model; } else { return null; } }