/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.PlatModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Plat set "); strSql.Append("PlatCode=PlatCode,"); strSql.Append("PlatName=PlatName"); strSql.Append(" where ID=ID"); SqlParameter[] parameters = { new SqlParameter("PlatCode", SqlDbType.NVarChar, 20), new SqlParameter("PlatName", SqlDbType.NVarChar, 20), new SqlParameter("ID", SqlDbType.Int, 4) }; parameters[0].Value = model.PlatCode; parameters[1].Value = model.PlatName; 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(Maticsoft.Model.PlatModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Plat("); strSql.Append("PlatCode,PlatName)"); strSql.Append(" values ("); strSql.Append("PlatCode,PlatName)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("PlatCode", SqlDbType.NVarChar, 20), new SqlParameter("PlatName", SqlDbType.NVarChar, 20) }; parameters[0].Value = model.PlatCode; parameters[1].Value = model.PlatName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PlatModel DataRowToModel(DataRow row) { Maticsoft.Model.PlatModel model = new Maticsoft.Model.PlatModel(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["PlatCode"] != null) { model.PlatCode = row["PlatCode"].ToString(); } if (row["PlatName"] != null) { model.PlatName = row["PlatName"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PlatModel GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,PlatCode,PlatName from Plat "); strSql.Append(" where ID=ID"); SqlParameter[] parameters = { new SqlParameter("ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Maticsoft.Model.PlatModel model = new Maticsoft.Model.PlatModel(); 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(Maticsoft.Model.PlatModel model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.PlatModel model) { return(dal.Add(model)); }