/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.AccessTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AccessTable set "); strSql.Append("TableName=@TableName,"); strSql.Append("TableAdress=@TableAdress"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@TableName", SqlDbType.NVarChar, 50), new SqlParameter("@TableAdress", SqlDbType.NVarChar, 50), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.TableName; parameters[1].Value = model.TableAdress; parameters[2].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.AccessTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AccessTable("); strSql.Append("TableName,TableAdress)"); strSql.Append(" values ("); strSql.Append("@TableName,@TableAdress)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TableName", SqlDbType.NVarChar, 50), new SqlParameter("@TableAdress", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.TableName; parameters[1].Value = model.TableAdress; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public override ActionResult Info(int id) { bool result = false; Model.AccessTable model = bll.GetModel(id); if (model != null) { result = true; } if (result) { return(this.Json(new { result = 1, data = model }, JsonRequestBehavior.AllowGet)); } else { return(this.Json(new { result = 0, msg = "请求条目不存在" })); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.AccessTable DataRowToModel(DataRow row) { Model.AccessTable model = new Model.AccessTable(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["TableName"] != null) { model.TableName = row["TableName"].ToString(); } if (row["TableAdress"] != null) { model.TableAdress = row["TableAdress"].ToString(); } } return(model); }
public ActionResult Update(Model.AccessTable model) { bool result = false; HTNResp.BLL.Program bllProgram = new BLL.Program(); HTNResp.BLL.EvalGuid bllEvalGuid = new BLL.EvalGuid(); if (!String.IsNullOrEmpty(model.TableName) && String.IsNullOrEmpty(bllProgram.testContent(model.TableAdress)) && String.IsNullOrEmpty(bllProgram.testContent(model.TableName))) { result = bll.Update(model); } if (result) { return(this.Json(new { result = 1, data = "" })); } else { return(this.Json(new { result = 0, msg = "修改失败" })); } }
public override ActionResult Delete(int id) { bool result = false; Model.AccessTable model = bll.GetModel(id); if (model != null) { //model.Status = null; if (bll.Update(model)) { result = true; } } if (result) { return(this.Json(new { result = 1, data = "" })); } else { return(this.Json(new { result = 0, msg = "没有这条数据" })); } }
public ActionResult Create(Model.AccessTable model) { bool result = false; //model.ID = 1; HTNResp.BLL.Program bllProgram = new BLL.Program(); HTNResp.BLL.EvalGuid bllEvalGuid = new BLL.EvalGuid(); if (!String.IsNullOrEmpty(model.TableName) && String.IsNullOrEmpty(bllProgram.testContent(model.TableName)) && model.TableAdress != null) { if (bll.Add(model) != 0) { result = true; } } if (result) { return(this.Json(new { result = 1, data = "" })); } else { return(this.Json(new { result = 0, msg = "新建失败" })); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.AccessTable GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,TableName,TableAdress from AccessTable "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Model.AccessTable model = new Model.AccessTable(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.AccessTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.AccessTable model) { return(dal.Add(model)); }