/// <summary> /// 增加一条数据 /// </summary> public bool Add(HTNResp.Model.ControlContent model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ControlContent("); strSql.Append("ControlName,Title,Remark,ControlType)"); strSql.Append(" values ("); strSql.Append("@ControlName,@Title,@Remark,@ControlType)"); SqlParameter[] parameters = { new SqlParameter("@ControlName", SqlDbType.NVarChar, 50), new SqlParameter("@Title", SqlDbType.NVarChar, 50), new SqlParameter("@Remark", SqlDbType.NVarChar, -1), new SqlParameter("@ControlType", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.ControlName; parameters[1].Value = model.Title; parameters[2].Value = model.Remark; parameters[3].Value = model.ControlType; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public ActionResult Add(HTNResp.Model.ControlContent model) { bool result = false; if ((model.ControlType == "input" || model.ControlType == "checkbox") && !bll.Exists(model.ControlName)) { if (bll.Add(model)) { result = true; } } if (result) { return(this.Json(new { result = 1, data = "" })); } else { return(this.Json(new { result = 0, msg = "增加失败" })); } }
/// <summary> /// 得到一个对象实体 /// </summary> public HTNResp.Model.ControlContent DataRowToModel(DataRow row) { HTNResp.Model.ControlContent model = new HTNResp.Model.ControlContent(); if (row != null) { if (row["ControlName"] != null) { model.ControlName = row["ControlName"].ToString(); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["ControlType"] != null) { model.ControlType = row["ControlType"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public HTNResp.Model.ControlContent GetModel(string ControlName) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ControlName,Title,Remark,ControlType from ControlContent "); strSql.Append(" where ControlName=@ControlName "); SqlParameter[] parameters = { new SqlParameter("@ControlName", SqlDbType.NVarChar, 50) }; parameters[0].Value = ControlName; HTNResp.Model.ControlContent model = new HTNResp.Model.ControlContent(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }