public ActionResult Execute(int Id) { try { Tdms_Info daInfo = new Tdms_Info(); if (!daInfo.SelectByPK(Id)) { return(FailResult("该记录不存在")); } string SqlContext = daInfo.SqlContext; if (string.IsNullOrEmpty(SqlContext)) { return(FailResult("sql语句为空,无法执行")); } MSQL sqlFacade = new MSQL(); int count; if (!sqlFacade.ExecuteSQL(SqlContext, out count)) { return(FailResult(sqlFacade.PromptInfo.MessageStack)); } if (count > 0 || count == 0) { return(FailResult("监控到" + count + "条非法数据!")); } return(SuccessResult()); } catch (Exception ex) { return(FailResult("执行SQL出现异常:" + ex.Message)); } }
public ActionResult Add(VInfoModel vModel) { if (vModel.ChannelId == 0) { return(FailResult("栏目分类不能为空!")); } try { MSQL infoFacade = new MSQL(); infoFacade.DAL.Title = vModel.Title; infoFacade.DAL.ChannelId = vModel.ChannelId; infoFacade.DAL.SqlContext = vModel.SqlContext; infoFacade.DAL.State = vModel.State; infoFacade.DAL.OperaotId = SysUser.UserId; infoFacade.DAL.Remark = vModel.Remark; if (!infoFacade.Add()) { return(FailResult(infoFacade.PromptInfo.MessageStack)); } return(SuccessResult()); } catch (Exception ex) { return(FailResult("SQL出现异常:" + ex.Message)); } }
public virtual object TableReady(string tableName, string recordColumnName, string conditions = "") { return(MSQL.Execute(@" CREATE TRIGGER IF NOT EXISTS Delete_HeavyData AFTER DELETE ON " + tableName + @" BEGIN DELETE FROM " + TableName + " WHERE FromTable = \"" + tableName + "\" AND FromRecord = CAST(OLD." + recordColumnName + " AS TEXT) " + conditions + ";END;", MiMFa_ExecuteType.ExecuteNonQuery)); }
public override object Create(string attachment = "") { base.Create(attachment); return(MSQL.Execute(@" CREATE TRIGGER IF NOT EXISTS Update_ID_INSERT AFTER INSERT ON " + TableName + @" BEGIN UPDATE " + TableName + @" SET ID = (SELECT COALESCE(MAX(ID),0) + 1 FROM " + TableName + @"); END;", MiMFa_ExecuteType.ExecuteNonQuery)); }
public ActionResult Update(int Id) { MSQL sql = new MSQL(Id); if (!sql.IsExist) { return(FailResult("会员不存在")); } VInfoModel model = new VInfoModel { Id = sql.DAL.Id, Title = sql.DAL.Title, ChannelId = sql.DAL.ChannelId, SqlContext = sql.DAL.SqlContext, State = sql.DAL.State, Remark = sql.DAL.Remark }; return(View(model)); }
public ActionResult Update(VInfoModel vModel) { try { MSQL sql = new MSQL(vModel.Id); sql.DAL.Title = vModel.Title; vModel.ChannelId = sql.DAL.ChannelId; sql.DAL.SqlContext = vModel.SqlContext; sql.DAL.State = vModel.State; sql.DAL.Remark = vModel.Remark; sql.DAL.OperaotId = SysUser.UserId; if (!sql.Update()) { return(FailResult(sql.PromptInfo.MessageStack)); } return(SuccessResult()); } catch (Exception ex) { return(FailResult("SQL出现异常:" + ex.Message)); } }