/// <summary> /// 更新一条数据 /// </summary> public bool Update(hm.Model.ed_media model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ed_media set "); strSql.Append("mediaType=@mediaType,"); strSql.Append("nodeId=@nodeId,"); strSql.Append("title=@title,"); strSql.Append("picSmall=@picSmall,"); strSql.Append("picBig=@picBig,"); strSql.Append("mediaUrl=@mediaUrl,"); strSql.Append("remark=@remark,"); strSql.Append("isRecommend=@isRecommend,"); strSql.Append("addTime=@addTime,"); strSql.Append("status=@status"); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@mediaType", OleDbType.Integer, 4), new OleDbParameter("@nodeId", OleDbType.Integer, 4), new OleDbParameter("@title", OleDbType.VarChar, 255), new OleDbParameter("@picSmall", OleDbType.VarChar, 255), new OleDbParameter("@picBig", OleDbType.VarChar, 255), new OleDbParameter("@mediaUrl", OleDbType.VarChar, 255), new OleDbParameter("@remark", OleDbType.VarChar, 0), new OleDbParameter("@isRecommend", OleDbType.Integer, 4), new OleDbParameter("@addTime", OleDbType.Date), new OleDbParameter("@status", OleDbType.Integer, 4), new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = model.mediaType; parameters[1].Value = model.nodeId; parameters[2].Value = model.title; parameters[3].Value = model.picSmall; parameters[4].Value = model.picBig; parameters[5].Value = model.mediaUrl; parameters[6].Value = model.remark; parameters[7].Value = model.isRecommend; parameters[8].Value = model.addTime; parameters[9].Value = model.status; parameters[10].Value = model.ID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(hm.Model.ed_media model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ed_media("); strSql.Append("nodeId,mediaType,title,picSmall,picBig,mediaUrl,remark,isRecommend,addTime,status)"); strSql.Append(" values ("); strSql.Append("@nodeId,@mediaType,@title,@picSmall,@picBig,@mediaUrl,@remark,@isRecommend,@addTime,@status)"); OleDbParameter[] parameters = { new OleDbParameter("@nodeId", OleDbType.Integer, 4), new OleDbParameter("@mediaType", OleDbType.Integer, 4), new OleDbParameter("@title", OleDbType.VarChar, 255), new OleDbParameter("@picSmall", OleDbType.VarChar, 255), new OleDbParameter("@picBig", OleDbType.VarChar, 255), new OleDbParameter("@mediaUrl", OleDbType.VarChar, 255), new OleDbParameter("@remark", OleDbType.VarChar, 0), new OleDbParameter("@isRecommend", OleDbType.Integer, 4), new OleDbParameter("@addTime", OleDbType.Date), new OleDbParameter("@status", OleDbType.Integer, 4) }; parameters[0].Value = model.nodeId; parameters[1].Value = model.mediaType; parameters[2].Value = model.title; parameters[3].Value = model.picSmall; parameters[4].Value = model.picBig; parameters[5].Value = model.mediaUrl; parameters[6].Value = model.remark; parameters[7].Value = model.isRecommend; parameters[8].Value = model.addTime; parameters[9].Value = model.status; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(int siId) { hm.BLL.ed_media bll = new hm.BLL.ed_media(); hm.Model.ed_media model = bll.GetModel(siId); this.lblId.Text = model.ID.ToString(); txtTitle.Text = model.title; image1.ImageUrl = model.picSmall; lblPicBig.Text = model.picBig; txtRemark.Text = model.remark; lblFile.Text = model.mediaUrl; if (model.isRecommend.Value == 1) { cbRecommend.Checked = true; } Model.ed_node modelNode = nBll.GetModel(model.nodeId.Value); litId.Text = modelNode.ID.ToString(); litName.Text = modelNode.title; }
/// <summary> /// 得到一个对象实体 /// </summary> public hm.Model.ed_media GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,mediaType,nodeId,title,picSmall,picBig,mediaUrl,remark,isRecommend,addTime,status from ed_media "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = ID; hm.Model.ed_media model = new hm.Model.ed_media(); DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["mediaType"] != null && ds.Tables[0].Rows[0]["mediaType"].ToString() != "") { model.mediaType = int.Parse(ds.Tables[0].Rows[0]["mediaType"].ToString()); } if (ds.Tables[0].Rows[0]["nodeId"] != null && ds.Tables[0].Rows[0]["nodeId"].ToString() != "") { model.nodeId = int.Parse(ds.Tables[0].Rows[0]["nodeId"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["picSmall"] != null && ds.Tables[0].Rows[0]["picSmall"].ToString() != "") { model.picSmall = ds.Tables[0].Rows[0]["picSmall"].ToString(); } if (ds.Tables[0].Rows[0]["picBig"] != null && ds.Tables[0].Rows[0]["picBig"].ToString() != "") { model.picBig = ds.Tables[0].Rows[0]["picBig"].ToString(); } if (ds.Tables[0].Rows[0]["mediaUrl"] != null && ds.Tables[0].Rows[0]["mediaUrl"].ToString() != "") { model.mediaUrl = ds.Tables[0].Rows[0]["mediaUrl"].ToString(); } if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "") { model.remark = ds.Tables[0].Rows[0]["remark"].ToString(); } if (ds.Tables[0].Rows[0]["isRecommend"] != null && ds.Tables[0].Rows[0]["isRecommend"].ToString() != "") { model.isRecommend = int.Parse(ds.Tables[0].Rows[0]["isRecommend"].ToString()); } if (ds.Tables[0].Rows[0]["addTime"] != null && ds.Tables[0].Rows[0]["addTime"].ToString() != "") { model.addTime = DateTime.Parse(ds.Tables[0].Rows[0]["addTime"].ToString()); } if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } return(model); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { hm.BLL.ed_media bll = new hm.BLL.ed_media(); string strErr = ""; if (this.txtTitle.Text.Trim().Length == 0) { strErr += "标题不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int nodeId = int.Parse(litId.Text); int mediaTypeId = 1; string title = txtTitle.Text; string remark = this.txtRemark.Text; string spic = image1.ImageUrl, bpic = lblPicBig.Text, url = lblFile.Text; int recommend = 0; if (flPic.HasFile) { string msg = Common.CommonHelper.Imageupload(flPic, "product"); if (msg.Split('|')[0].Equals("1")) { bpic = msg.Split('|')[1]; spic = msg.Split('|')[2]; } } if (flUrl.HasFile) { string[] allowExtension = { ".jpg", ".png", ".gif", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt", ".rar", ".zip", ".7z", ".flv" }; string msg = Common.CommonHelper.Fileupload(flPic, "fujian", allowExtension, 10); if (msg.Split('|')[0].Equals("1")) { url = msg.Split('|')[1]; } } if (cbRecommend.Checked) { recommend = 1; } hm.Model.ed_media model = bll.GetModel(int.Parse(lblId.Text)); model.nodeId = nodeId; model.mediaType = mediaTypeId; model.title = title; model.remark = remark; model.picBig = bpic; model.picSmall = spic; model.mediaUrl = url; model.isRecommend = recommend; model.addTime = DateTime.Now; model.status = StatusHelper.Product_Status_Normal; bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "../media/list.aspx?id=" + model.nodeId); }