protected void btnSave_Click(object sender, EventArgs e) { USER_SHARE_FUNMENUMODEL usfModel = null; bool isEdit = FmId > 0 && ActionType.Equals("edit"); bool isSuccess = false; //日志记录 USER_SHARE_LOGMODEL logModel = new USER_SHARE_LOGMODEL(); logModel.LOGID = CommonBusiness.GetSeqID("S_USER_SHARE_LOG"); logModel.OPERATEDATE = DateTime.Now; logModel.OPERATORID = AccountId; logModel.PROJECTID = ProjectId; logModel.COMPANYID = CompanyId; int nProjectId = ValidatorHelper.ToInt(Enc.Decrypt(Request.QueryString["projectid"], UrlEncKey), 0); //新增 if (!isEdit) { usfModel = new USER_SHARE_FUNMENUMODEL(); usfModel.FMID = CommonBusiness.GetSeqID("S_USER_SHARE_FUNMENU"); usfModel.PROJECTID = nProjectId; usfModel.FMPARENTID = FmId > 0 ? FmId : 0; logModel.OPERATETYPE = int.Parse(ShareEnum.LogType.AddProjectFunMenu.ToString("d")); logModel.OPERATECONTENT = "新增项目功能菜单,项目ID:" + usfModel.PROJECTID + ",菜单名称:" + txtFMName.Text.Trim(); } //修改 else { usfModel = ProjectFunBusiness.GetModel(FmId); logModel.OPERATETYPE = int.Parse(ShareEnum.LogType.EditProjectFunMenu.ToString("d")); logModel.OPERATECONTENT = "修改项目功能菜单,菜单ID:" + FmId + ",修改后菜单名称:" + txtFMName.Text.Trim(); } usfModel.FMNAME = txtFMName.Text.Trim(); usfModel.FMPAGEURL = txtFMPageUrl.Text.Trim(); usfModel.FMSORTNUM = ValidatorHelper.ToInt(txtFMSortNum.Text, 0); usfModel.FMDESC = txtFMDesc.Text.Trim(); if (!isEdit) { isSuccess = ProjectFunBusiness.AddProjectFun(usfModel, logModel); } else { isSuccess = ProjectFunBusiness.UpdateProjectFun(usfModel, logModel); } Alert((isEdit ? "修改" : "新增") + "功能菜单" + (isSuccess ? "成功" : "失败,请重试") + "!"); //刷新父页面 ExecStartScript(string.Format("parent.location='ProjectFunManage.aspx?pid={0}&s={1}';", Request.QueryString["projectid"], new Random(10000).Next())); }
private void LoadInfo(int nFmId) { USER_SHARE_FUNMENUMODEL usfModel = ProjectFunBusiness.GetModel(nFmId); if (usfModel != null) { txtFMName.Text = usfModel.FMNAME; txtFMDesc.Text = CommonMethod.FinalString(usfModel.FMDESC); txtFMPageUrl.Text = CommonMethod.FinalString(usfModel.FMPAGEURL); txtFMSortNum.Text = usfModel.FMSORTNUM.ToString(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public static USER_SHARE_FUNMENUMODEL GetModel(int FMID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select FMID,PROJECTID,FMNAME,FMPAGEURL,FMPARENTID,FMSORTNUM,FMSTEP,FMISLAST,FMDESC,FMSTATUS from USER_SHARE_FUNMENU "); strSql.Append(" where FMID=:FMID "); ParamList param = new ParamList(); param["FMID"] = FMID; USER_SHARE_FUNMENUMODEL model = null; DataTable dt = StaticConnectionProvider.ExecuteDataTable(strSql.ToString(), param); if (dt != null && dt.Rows.Count > 0) { model = ReaderBind(dt.Rows[0]); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public static bool UpdateProjectFun(USER_SHARE_FUNMENUMODEL model, USER_SHARE_LOGMODEL log) { bool blResult = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update USER_SHARE_FUNMENU set "); strSql.Append("PROJECTID=:PROJECTID,"); strSql.Append("FMNAME=:FMNAME,"); strSql.Append("FMPAGEURL=:FMPAGEURL,"); strSql.Append("FMPARENTID=:FMPARENTID,"); strSql.Append("FMSORTNUM=:FMSORTNUM,"); strSql.Append("FMSTEP=:FMSTEP,"); strSql.Append("FMISLAST=:FMISLAST,"); strSql.Append("FMDESC=:FMDESC,"); strSql.Append("FMSTATUS=:FMSTATUS"); strSql.Append(" where FMID=:FMID "); ParamList param = new ParamList(); param["FMID"] = model.FMID; param["PROJECTID"] = model.PROJECTID; param["FMNAME"] = model.FMNAME; param["FMPAGEURL"] = model.FMPAGEURL; param["FMPARENTID"] = model.FMPARENTID; param["FMSORTNUM"] = model.FMSORTNUM; param["FMSTEP"] = model.FMSTEP; param["FMISLAST"] = model.FMISLAST; param["FMDESC"] = model.FMDESC; param["FMSTATUS"] = model.FMSTATUS; IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider(); try { using (connection) { connection.BeginTranscation(); //增加项目信息 connection.ExecuteNonQuery(strSql.ToString(), param); param.Clear(); //链接地址改动,更新公司菜单表的链接地址 strSql = new StringBuilder("UPDATE USER_SHARE_COMPANYFUN SET CFPAGEURL=:CFPAGEURL WHERE CFPAGEURL!=:CFPAGEURL AND FMID=:FMID "); param["FMID"] = model.FMID; param["CFPAGEURL"] = model.FMPAGEURL; connection.ExecuteNonQuery(strSql.ToString(), param); param.Clear(); //操作日志 strSql = new StringBuilder(); strSql.Append("insert into USER_SHARE_LOG("); strSql.Append("LOGID,OPERATETYPE,OPERATORID,PROJECTID,COMPANYID,OPERATECONTENT,OPERATEDATE)"); strSql.Append(" values ("); strSql.Append(":LOGID,:OPERATETYPE,:OPERATORID,:PROJECTID,:COMPANYID,:OPERATECONTENT,:OPERATEDATE)"); param["LOGID"] = log.LOGID; param["OPERATETYPE"] = log.OPERATETYPE; param["OPERATORID"] = log.OPERATORID; param["PROJECTID"] = log.PROJECTID; param["COMPANYID"] = log.COMPANYID; param["OPERATECONTENT"] = log.OPERATECONTENT; param["OPERATEDATE"] = log.OPERATEDATE; connection.ExecuteNonQuery(strSql.ToString(), param); connection.CommitTranscation(); blResult = true; } } catch (Exception ex) { connection.RollbackTranscation(); LogHelper.WriteErr("修改项目功能菜单时出现异常,Id:" + model.FMID, ex); } return(blResult); }
/// <summary> /// 增加一条数据 /// </summary> public static bool AddProjectFun(USER_SHARE_FUNMENUMODEL model, USER_SHARE_LOGMODEL log) { bool blResult = false; StringBuilder strSql = new StringBuilder(); strSql.Append("insert into USER_SHARE_FUNMENU("); strSql.Append("FMID,PROJECTID,FMNAME,FMPAGEURL,FMPARENTID,FMSORTNUM,FMSTEP,FMISLAST,FMDESC,FMSTATUS)"); strSql.Append(" values ("); strSql.Append(":FMID,:PROJECTID,:FMNAME,:FMPAGEURL,:FMPARENTID,:FMSORTNUM,:FMSTEP,:FMISLAST,:FMDESC,:FMSTATUS)"); ParamList param = new ParamList(); param["FMID"] = model.FMID; param["PROJECTID"] = model.PROJECTID; param["FMNAME"] = model.FMNAME; param["FMPAGEURL"] = model.FMPAGEURL; param["FMPARENTID"] = model.FMPARENTID; param["FMSORTNUM"] = model.FMSORTNUM; param["FMSTEP"] = model.FMSTEP; param["FMISLAST"] = model.FMISLAST; param["FMDESC"] = model.FMDESC; param["FMSTATUS"] = model.FMSTATUS; IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider(); try { using (connection) { connection.BeginTranscation(); //增加项目信息 connection.ExecuteNonQuery(strSql.ToString(), param); param.Clear(); //操作日志 strSql = new StringBuilder(); strSql.Append("insert into USER_SHARE_LOG("); strSql.Append("LOGID,OPERATETYPE,OPERATORID,PROJECTID,COMPANYID,OPERATECONTENT,OPERATEDATE)"); strSql.Append(" values ("); strSql.Append(":LOGID,:OPERATETYPE,:OPERATORID,:PROJECTID,:COMPANYID,:OPERATECONTENT,:OPERATEDATE)"); param["LOGID"] = log.LOGID; param["OPERATETYPE"] = log.OPERATETYPE; param["OPERATORID"] = log.OPERATORID; param["PROJECTID"] = log.PROJECTID; param["COMPANYID"] = log.COMPANYID; param["OPERATECONTENT"] = log.OPERATECONTENT; param["OPERATEDATE"] = log.OPERATEDATE; connection.ExecuteNonQuery(strSql.ToString(), param); connection.CommitTranscation(); blResult = true; } } catch (Exception ex) { connection.RollbackTranscation(); LogHelper.WriteErr("新增项目功能菜单时出现异常,项目Id:" + model.PROJECTID, ex); } return(blResult); }