public string GetModelNameListByURL(string URL) { string ModuleNameList = ""; StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from T_Module "); strSql.Append(" where DEL=0 AND FileName = '" + URL + "'"); DigiPower.Onlinecol.Standard.Model.T_Module_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Module_MDL(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString()); model.ModuleName = ds.Tables[0].Rows[0]["ModuleName"].ToString(); if (ModuleNameList == "") { ModuleNameList = model.ModuleName; } else { ModuleNameList = model.ModuleName + " -> " + ModuleNameList; } GetModelByURL(ref ModuleNameList, model.ParentID.ToString()); } return(ModuleNameList); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { BLL.T_Module_BLL bll = new DigiPower.Onlinecol.Standard.BLL.T_Module_BLL(); Model.T_Module_MDL Newmodel = bll.GetModel(Common.ConvertEx.ToInt(ID)); if (Newmodel == null) { Newmodel = new DigiPower.Onlinecol.Standard.Model.T_Module_MDL(); } Newmodel = (Model.T_Module_MDL)Comm.GetValueToObject(Newmodel, this.tbl); Newmodel.RightListID = chkMenuRight.getSelectValue; if (Newmodel != null) { switch ((CommonEnum.PageState)ViewState["ps"]) { case CommonEnum.PageState.ADD: int moduleID = bll.Add(Newmodel); PublicModel.writeLog(SystemSet.EumLogType.AddData.ToString(), string.Concat("T_Module;key=", moduleID, ";ModuleName=", Newmodel.ModuleName, ";BH=", Newmodel.BH)); break; case CommonEnum.PageState.EDIT: bll.Update(Newmodel); PublicModel.writeLog(SystemSet.EumLogType.UpdData.ToString(), string.Concat("T_Module;key=", Newmodel.ModuleID, ";ModuleName=", Newmodel.ModuleName, ";BH=", Newmodel.BH)); break; } } Common.MessageBox.CloseLayerOpenWeb(this.Page); }
/// <summary> /// 绑定页面 /// </summary> /// <param name="ID"></param> private void BindPage(string ID) { Model.T_Module_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Module_MDL(); BLL.T_Module_BLL bll = new DigiPower.Onlinecol.Standard.BLL.T_Module_BLL(); model = bll.GetModel(Convert.ToInt32(ID)); if (model != null) { DigiPower.Onlinecol.Standard.Web.Comm.SetValueToPage(model, this.tbl); chkMenuRight.setSelectValue = model.RightListID; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(DigiPower.Onlinecol.Standard.Model.T_Module_MDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Module set "); strSql.Append("ParentID=@ParentID,"); strSql.Append("BH=@BH,"); strSql.Append("ModuleName=@ModuleName,"); strSql.Append("PictureIndex=@PictureIndex,"); strSql.Append("SelectedIndex=@SelectedIndex,"); strSql.Append("FileName=@FileName,"); strSql.Append("IfVisible=@IfVisible,"); strSql.Append("OrderIndex=@OrderIndex,"); strSql.Append("Description=@Description,"); strSql.Append("Del=@Del,"); strSql.Append("RightListID=@RightListID, "); strSql.Append("IfInsidePage=@IfInsidePage "); strSql.Append(" where ModuleID=@ModuleID "); SqlParameter[] parameters = { new SqlParameter("@ModuleID", SqlDbType.Int, 8), new SqlParameter("@ParentID", SqlDbType.Int, 8), new SqlParameter("@BH", SqlDbType.NVarChar, 20), new SqlParameter("@ModuleName", SqlDbType.NVarChar, 50), new SqlParameter("@PictureIndex", SqlDbType.SmallInt, 2), new SqlParameter("@SelectedIndex", SqlDbType.SmallInt, 2), new SqlParameter("@FileName", SqlDbType.NVarChar, 255), new SqlParameter("@IfVisible", SqlDbType.Bit, 1), new SqlParameter("@OrderIndex", SqlDbType.SmallInt, 2), new SqlParameter("@Description", SqlDbType.NVarChar, 255), new SqlParameter("@Del", SqlDbType.Bit, 1), new SqlParameter("@RightListID", SqlDbType.NVarChar, 500), new SqlParameter("@IfInsidePage", SqlDbType.Bit, 1) }; parameters[0].Value = model.ModuleID; parameters[1].Value = model.ParentID; parameters[2].Value = model.BH; parameters[3].Value = model.ModuleName; parameters[4].Value = model.PictureIndex; parameters[5].Value = model.SelectedIndex; parameters[6].Value = model.FileName; parameters[7].Value = model.IfVisible; parameters[8].Value = model.OrderIndex; parameters[9].Value = model.Description; parameters[10].Value = model.Del; parameters[11].Value = model.RightListID; parameters[12].Value = model.IfInsidePage; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DigiPower.Onlinecol.Standard.Model.T_Module_MDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Module("); strSql.Append("ParentID,BH,ModuleName,PictureIndex,SelectedIndex,FileName,IfVisible,OrderIndex,Description,Del,RightListID,IfInsidePage)"); strSql.Append(" values ("); strSql.Append("@ParentID,@BH,@ModuleName,@PictureIndex,@SelectedIndex,@FileName,@IfVisible,@OrderIndex,@Description,@Del,@RightListID,@IfInsidePage)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ParentID", SqlDbType.Int, 8), new SqlParameter("@BH", SqlDbType.NVarChar, 20), new SqlParameter("@ModuleName", SqlDbType.NVarChar, 50), new SqlParameter("@PictureIndex", SqlDbType.SmallInt, 2), new SqlParameter("@SelectedIndex", SqlDbType.SmallInt, 2), new SqlParameter("@FileName", SqlDbType.NVarChar, 255), new SqlParameter("@IfVisible", SqlDbType.Bit, 1), new SqlParameter("@OrderIndex", SqlDbType.SmallInt, 2), new SqlParameter("@Description", SqlDbType.NVarChar, 255), new SqlParameter("@Del", SqlDbType.Bit, 1), new SqlParameter("@RightListID", SqlDbType.NVarChar, 500), new SqlParameter("@IfInsidePage", SqlDbType.Bit, 1) }; parameters[0].Value = model.ParentID; parameters[1].Value = model.BH; parameters[2].Value = model.ModuleName; parameters[3].Value = model.PictureIndex; parameters[4].Value = model.SelectedIndex; parameters[5].Value = model.FileName; parameters[6].Value = model.IfVisible; parameters[7].Value = model.OrderIndex; parameters[8].Value = model.Description; parameters[9].Value = model.Del; parameters[10].Value = model.RightListID; parameters[11].Value = model.IfInsidePage; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
public string GetModelIDByURL(string URL) { string ModuleID = ""; StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from T_Module "); strSql.Append(" where Del=0 AND FileName like '%" + URL + "%'"); DigiPower.Onlinecol.Standard.Model.T_Module_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Module_MDL(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ModuleID = ds.Tables[0].Rows[0]["ModuleID"].ToString(); } return(ModuleID); }
private void GetModelByURL(ref string ModuleNameList, string ModuleID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from T_Module "); strSql.Append(" where DEL=0 AND ModuleID= " + ModuleID + ""); DigiPower.Onlinecol.Standard.Model.T_Module_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Module_MDL(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString()); model.ModuleName = ds.Tables[0].Rows[0]["ModuleName"].ToString(); ModuleNameList = model.ModuleName + " -> " + ModuleNameList; GetModelByURL(ref ModuleNameList, model.ParentID.ToString()); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DigiPower.Onlinecol.Standard.Model.T_Module_MDL GetModel(int ModuleID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ModuleID,ParentID,BH,ModuleName,PictureIndex,SelectedIndex,FileName,IfVisible,OrderIndex,Description,Del,RightListID,IfInsidePage from T_Module "); strSql.Append(" where ModuleID=@ModuleID "); SqlParameter[] parameters = { new SqlParameter("@ModuleID", SqlDbType.Int, 8) }; parameters[0].Value = ModuleID; DigiPower.Onlinecol.Standard.Model.T_Module_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Module_MDL(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ModuleID"].ToString() != "") { model.ModuleID = int.Parse(ds.Tables[0].Rows[0]["ModuleID"].ToString()); } if (ds.Tables[0].Rows[0]["ParentID"].ToString() != "") { model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString()); } model.BH = ds.Tables[0].Rows[0]["BH"].ToString(); model.ModuleName = ds.Tables[0].Rows[0]["ModuleName"].ToString(); if (ds.Tables[0].Rows[0]["PictureIndex"].ToString() != "") { model.PictureIndex = int.Parse(ds.Tables[0].Rows[0]["PictureIndex"].ToString()); } if (ds.Tables[0].Rows[0]["SelectedIndex"].ToString() != "") { model.SelectedIndex = int.Parse(ds.Tables[0].Rows[0]["SelectedIndex"].ToString()); } model.FileName = ds.Tables[0].Rows[0]["FileName"].ToString(); if (ds.Tables[0].Rows[0]["IfVisible"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IfVisible"].ToString() == "1") || (ds.Tables[0].Rows[0]["IfVisible"].ToString().ToLower() == "true")) { model.IfVisible = true; } else { model.IfVisible = false; } } if (ds.Tables[0].Rows[0]["OrderIndex"].ToString() != "") { model.OrderIndex = int.Parse(ds.Tables[0].Rows[0]["OrderIndex"].ToString()); } model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); if (ds.Tables[0].Rows[0]["Del"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Del"].ToString() == "1") || (ds.Tables[0].Rows[0]["Del"].ToString().ToLower() == "true")) { model.Del = true; } else { model.Del = false; } } model.RightListID = ds.Tables[0].Rows[0]["RightListID"].ToString(); if (ds.Tables[0].Rows[0]["Del"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IfInsidePage"].ToString() == "1") || (ds.Tables[0].Rows[0]["IfInsidePage"].ToString().ToLower() == "true")) { model.IfInsidePage = true; } else { model.IfInsidePage = false; } } return(model); } else { return(null); } }