/// <summary> /// 保存模块信息 /// </summary> protected void mt_btn_save_Click(object sender, EventArgs e) { if (txt_MTName.Text.Trim() != "" || txt_MTorder.Text.Trim() != "" || Smart.Utility.TypeParse.IsUnsign(txt_MTorder.Text.Trim())) { Entity.BASE_MODULETYPE model = new Entity.BASE_MODULETYPE(); model.ModuleTypeName = txt_MTName.Text.Trim(); model.ModuleTypeDescription = txt_MTDescription.Text.Trim(); model.ModuleTypeOrder = int.Parse(txt_MTorder.Text.Trim()); model.ModuleTypeSuperiorID = int.Parse(txt_MTPID.SelectedValue); switch (bll.CreateModuleType(model)) { case 1: txt_MTName.Text = ""; txt_MTDescription.Text = ""; txt_MTorder.Text = ""; Smart.Utility.JScript.Extjs("alert('添加成功!');window.parent.location.href='ModulesPage.aspx';"); break; case 2: strinfo.InnerHtml = Smart.Utility.JScript.errinfo("标识已存在,请更换后重试!"); strinfo.Visible = true; break; default: strinfo.InnerHtml = Smart.Utility.JScript.errinfo("添加操作失败!"); strinfo.Visible = true; break; } } }
protected void GetModuleType(int id) { Entity.BASE_MODULETYPE model = new Entity.BASE_MODULETYPE(); model = bll.GetModuleTypeModel(id); MT_ID.Text = model.ModuleTypeID.ToString(); txt_MTName.Text = model.ModuleTypeName; txt_MTorder.Text = model.ModuleTypeOrder.ToString(); txt_MTDescription.Text = model.ModuleTypeDescription; txt_MTPID.SelectedValue = model.ModuleTypeSuperiorID.ToString(); }
/// <summary> /// 增加一个模块分类 /// </summary> /// <param name="model">模块分类实体类</param> /// <returns></returns> public int CreateModuleType(Entity.BASE_MODULETYPE model) { if (!ModuleTypeExists(model.ModuleTypeName)) { return(dal.CreateModuleType(model)); } else { return(2); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entity.BASE_MODULETYPE GetEntity(int ModuleTypeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ModuleTypeID, ModuleTypeName, ModuleTypeOrder, ModuleTypeDescription, ModuleTypeDepth, ModuleTypeSuperiorID, ModuleTypeCount "); strSql.Append(" from Base_ModuleType "); strSql.Append(" where ModuleTypeID=@ModuleTypeID"); SqlParameter[] parameters = { new SqlParameter("@ModuleTypeID", SqlDbType.Int, 4) }; parameters[0].Value = ModuleTypeID; Entity.BASE_MODULETYPE entity = new Entity.BASE_MODULETYPE(); DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ModuleTypeID"].ToString() != "") { entity.ModuleTypeID = int.Parse(ds.Tables[0].Rows[0]["ModuleTypeID"].ToString()); } entity.ModuleTypeName = ds.Tables[0].Rows[0]["ModuleTypeName"].ToString(); if (ds.Tables[0].Rows[0]["ModuleTypeOrder"].ToString() != "") { entity.ModuleTypeOrder = int.Parse(ds.Tables[0].Rows[0]["ModuleTypeOrder"].ToString()); } entity.ModuleTypeDescription = ds.Tables[0].Rows[0]["ModuleTypeDescription"].ToString(); if (ds.Tables[0].Rows[0]["ModuleTypeDepth"].ToString() != "") { entity.ModuleTypeDepth = int.Parse(ds.Tables[0].Rows[0]["ModuleTypeDepth"].ToString()); } if (ds.Tables[0].Rows[0]["ModuleTypeSuperiorID"].ToString() != "") { entity.ModuleTypeSuperiorID = int.Parse(ds.Tables[0].Rows[0]["ModuleTypeSuperiorID"].ToString()); } if (ds.Tables[0].Rows[0]["ModuleTypeCount"].ToString() != "") { entity.ModuleTypeCount = int.Parse(ds.Tables[0].Rows[0]["ModuleTypeCount"].ToString()); } return(entity); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Entity.BASE_MODULETYPE entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Base_ModuleType set "); strSql.Append(" ModuleTypeName = @ModuleTypeName , "); strSql.Append(" ModuleTypeOrder = @ModuleTypeOrder , "); strSql.Append(" ModuleTypeDescription = @ModuleTypeDescription , "); strSql.Append(" ModuleTypeDepth = @ModuleTypeDepth , "); strSql.Append(" ModuleTypeSuperiorID = @ModuleTypeSuperiorID , "); strSql.Append(" ModuleTypeCount = @ModuleTypeCount "); strSql.Append(" where ModuleTypeID=@ModuleTypeID "); SqlParameter[] parameters = { new SqlParameter("@ModuleTypeID", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeName", SqlDbType.NVarChar, 30), new SqlParameter("@ModuleTypeOrder", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeDescription", SqlDbType.NVarChar, 50), new SqlParameter("@ModuleTypeDepth", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeSuperiorID", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeCount", SqlDbType.Int, 4) }; parameters[6].Value = entity.ModuleTypeID; parameters[7].Value = entity.ModuleTypeName; parameters[8].Value = entity.ModuleTypeOrder; parameters[9].Value = entity.ModuleTypeDescription; parameters[10].Value = entity.ModuleTypeDepth; parameters[11].Value = entity.ModuleTypeSuperiorID; parameters[12].Value = entity.ModuleTypeCount; int rows = SqlServerHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新模块分类信息 /// </summary> protected void mt_btn_update_Click(object sender, EventArgs e) { Entity.BASE_MODULETYPE model = new Entity.BASE_MODULETYPE(); model.ModuleTypeID = int.Parse(MT_ID.Text); model.ModuleTypeName = txt_MTName.Text.Trim(); model.ModuleTypeSuperiorID = int.Parse(txt_MTPID.SelectedValue); model.ModuleTypeDescription = txt_MTDescription.Text.Trim(); model.ModuleTypeOrder = int.Parse(txt_MTorder.Text.Trim()); if (bll.UpdateModuleType(model)) { Smart.Utility.JScript.Extjs("alert('更新成功!');window.parent.location.href='ModulesPage.aspx';"); } else { strinfo.InnerHtml = Smart.Utility.JScript.errinfo("更新操作失败!"); strinfo.Visible = true; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Entity.BASE_MODULETYPE entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Base_ModuleType("); strSql.Append("ModuleTypeName,ModuleTypeOrder,ModuleTypeDescription,ModuleTypeDepth,ModuleTypeSuperiorID,ModuleTypeCount"); strSql.Append(") values ("); strSql.Append("@ModuleTypeName,@ModuleTypeOrder,@ModuleTypeDescription,@ModuleTypeDepth,@ModuleTypeSuperiorID,@ModuleTypeCount"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ModuleTypeName", SqlDbType.NVarChar, 30), new SqlParameter("@ModuleTypeOrder", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeDescription", SqlDbType.NVarChar, 50), new SqlParameter("@ModuleTypeDepth", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeSuperiorID", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeCount", SqlDbType.Int, 4) }; parameters[0].Value = entity.ModuleTypeName; parameters[1].Value = entity.ModuleTypeOrder; parameters[2].Value = entity.ModuleTypeDescription; parameters[3].Value = entity.ModuleTypeDepth; parameters[4].Value = entity.ModuleTypeSuperiorID; parameters[5].Value = entity.ModuleTypeCount; object obj = SqlServerHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">模块分类实体类</param> /// <returns></returns> public bool UpdateModuleType(Entity.BASE_MODULETYPE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Base_ModuleType set "); strSql.Append("ModuleTypeName=@ModuleTypeName,"); strSql.Append("ModuleTypeOrder=@ModuleTypeOrder,"); strSql.Append("ModuleTypeSuperiorID=@ModuleTypeSuperiorID,"); strSql.Append("ModuleTypeDepth=@ModuleTypeDepth,"); strSql.Append("ModuleTypeDescription=@ModuleTypeDescription"); strSql.Append(" where ModuleTypeID=@ModuleTypeID"); SqlParameter[] parameters = { new SqlParameter("@ModuleTypeID", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeName", SqlDbType.NVarChar, 30), new SqlParameter("@ModuleTypeOrder", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeSuperiorID", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeDepth", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeDescription", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.ModuleTypeID; parameters[1].Value = model.ModuleTypeName; parameters[2].Value = model.ModuleTypeOrder; parameters[3].Value = model.ModuleTypeSuperiorID; parameters[4].Value = GetModuleDepth(model.ModuleTypeSuperiorID) + 1;//更新级别深度 parameters[5].Value = model.ModuleTypeDescription; if (SqlServerHelper.ExecuteSql(strSql.ToString(), parameters) >= 1) { return(true); } else { return(false); } }
/// <summary> /// 增加一个模块分类 /// </summary> /// <param name="model">模块分类实体类</param> /// <returns></returns> public int CreateModuleType(Entity.BASE_MODULETYPE model) { int ret = 0; if (!ModuleTypeExists(model.ModuleTypeName)) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Base_ModuleType("); strSql.Append("ModuleTypeName,ModuleTypeOrder,ModuleTypeSuperiorID,ModuleTypeDepth,ModuleTypeDescription)"); strSql.Append(" values ("); strSql.Append("@ModuleTypeName,@ModuleTypeOrder,@ModuleTypeSuperiorID,@ModuleTypeDepth,@ModuleTypeDescription)"); SqlParameter[] parameters = { new SqlParameter("@ModuleTypeName", SqlDbType.NVarChar, 30), new SqlParameter("@ModuleTypeOrder", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeSuperiorID", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeDepth", SqlDbType.Int, 4), new SqlParameter("@ModuleTypeDescription", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.ModuleTypeName; parameters[1].Value = model.ModuleTypeOrder; parameters[2].Value = model.ModuleTypeSuperiorID; parameters[3].Value = GetModuleDepth(model.ModuleTypeSuperiorID) + 1;//更新级别深度 parameters[4].Value = model.ModuleTypeDescription; if (SqlServerHelper.ExecuteSql(strSql.ToString(), parameters) >= 1) { ret = 1; } } else { ret = 2; } return(ret); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">模块分类实体类</param> /// <returns></returns> public bool UpdateModuleType(Entity.BASE_MODULETYPE model) { return(dal.UpdateModuleType(model)); }