/// <summary> /// 对象实体绑定数据 /// </summary> public static myPortal.Model.saMenuInfo ReaderBind(IDataReader dataReader) { myPortal.Model.saMenuInfo model = new myPortal.Model.saMenuInfo(); object ojb; ojb = dataReader["iIden"]; if (ojb != null && ojb != DBNull.Value) { model.iIden = (int)ojb; } model.sName = dataReader["sName"].ToString(); ojb = dataReader["iParent"]; if (ojb != null && ojb != DBNull.Value) { model.iParent = (int)ojb; } ojb = dataReader["iSort"]; if (ojb != null && ojb != DBNull.Value) { model.iSort = (int)ojb; } model.sUrl = dataReader["sUrl"].ToString(); ojb = dataReader["iLevel"]; if (ojb != null && ojb != DBNull.Value) { model.iLevel = (int)ojb; } ojb = dataReader["iOpenMode"]; if (ojb != null && ojb != DBNull.Value) { model.iOpenMode = (int)ojb; } return model; }
protected void buttonOK_Click(object sender, EventArgs e) { if (this.CheckInput()) { try { int iMenuId = 0; int.TryParse(Request["iMenuId"], out iMenuId); int.TryParse(txtParentId.Value.Trim(), out iParentId); var menu = new saMenuInfo(); menu.iParent = iParentId; menu.iSort = int.Parse(this.txtSort.Text); menu.sName = this.txtMenuName.Text.Trim(); menu.sUrl = this.txtURL.Text.ToStringEx(); menu.iLevel = int.Parse(this.ddlLevel.SelectedValue); menu.iOpenMode = int.Parse(this.ddlOpenMode.SelectedValue); menu.iCreator = this.iUserID; if (this.IsModifyAction) { menu.iIden = iMenuId; saMenu.Current.UpdateMenu(menu); Response.Clear(); ClientScript.RegisterStartupScript(this.GetType(), string.Empty, "<script type=\"text/javascript\">alert('菜单信息处理成功!');location.href='MenuManage.aspx?iParentId=" + iParentId + "';</script>"); } else { menu.iIden = IdenGenerator.Current.NewIden(saMenuInfo.sTableName); saMenu.Current.CreateMenu(menu); Response.Clear(); ClientScript.RegisterStartupScript(this.GetType(), string.Empty, "<script type=\"text/javascript\">alert('菜单信息处理成功!');location.href='MenuManage.aspx?iParentId=" + iParentId + "';</script>"); } } catch (Exception ex) { hasError = true; errorMsg = ex.Message; throw ex; } } else { hasError = true; } }
public void Create(saMenuInfo menu) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into saMenu("); strSql.Append("iIden,sName,iParent,iSort,sUrl,iLevel,iOpenMode,iCreator)"); strSql.Append(" values ("); strSql.Append("@iIden,@sName,@iParent,@iSort,@sUrl,@iLevel,@iOpenMode,@iCreator)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "iIden", DbType.Int32, menu.iIden); db.AddInParameter(dbCommand, "sName", DbType.String, menu.sName); db.AddInParameter(dbCommand, "iParent", DbType.Int32, menu.iParent); db.AddInParameter(dbCommand, "iSort", DbType.Int32, menu.iSort); db.AddInParameter(dbCommand, "sUrl", DbType.String, menu.sUrl); db.AddInParameter(dbCommand, "iLevel", DbType.Int32, menu.iLevel); db.AddInParameter(dbCommand, "iOpenMode", DbType.Int32, menu.iOpenMode); db.AddInParameter(dbCommand, "iCreator", DbType.Int32, menu.iCreator); db.ExecuteNonQuery(dbCommand); }
public void Update(saMenuInfo menu) { StringBuilder strSql = new StringBuilder(); strSql.Append("update saMenu set "); strSql.Append("sName=@sName,"); strSql.Append("iParent=@iParent,"); strSql.Append("iSort=@iSort,"); strSql.Append("sUrl=@sUrl,"); strSql.Append("iLevel=@iLevel,"); strSql.Append("iOpenMode=@iOpenMode"); strSql.Append(" where iIden=@iIden "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "iIden", DbType.Int32, menu.iIden); db.AddInParameter(dbCommand, "sName", DbType.String, menu.sName); db.AddInParameter(dbCommand, "iParent", DbType.Int32, menu.iParent); db.AddInParameter(dbCommand, "iSort", DbType.Int32, menu.iSort); db.AddInParameter(dbCommand, "sUrl", DbType.String, menu.sUrl); db.AddInParameter(dbCommand, "iLevel", DbType.Int32, menu.iLevel); db.AddInParameter(dbCommand, "iOpenMode", DbType.Int32, menu.iOpenMode); db.ExecuteNonQuery(dbCommand); }
public void CreateMenu(saMenuInfo menu) { dal.Create(menu); }
public void UpdateMenu(saMenuInfo menu) { dal.Update(menu); }