/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.LabelCheck model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update LabelCheck set "); strSql.Append("Lab=@Lab"); strSql.Append(" where SN=@SN "); SqlParameter[] parameters = { new SqlParameter("@Lab", SqlDbType.VarChar, 200), new SqlParameter("@SN", SqlDbType.VarChar, 50) }; parameters[0].Value = model.Lab; parameters[1].Value = model.SN; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.LabelCheck model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into LabelCheck("); strSql.Append("SN,Lab)"); strSql.Append(" values ("); strSql.Append("@SN,@Lab)"); SqlParameter[] parameters = { new SqlParameter("@SN", SqlDbType.VarChar, 50), new SqlParameter("@Lab", SqlDbType.VarChar, 200) }; parameters[0].Value = model.SN; parameters[1].Value = model.Lab; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.LabelCheck DataRowToModel(DataRow row) { Maticsoft.Model.LabelCheck model = new Maticsoft.Model.LabelCheck(); if (row != null) { if (row["SN"] != null) { model.SN = row["SN"].ToString(); } if (row["Lab"] != null) { model.Lab = row["Lab"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.LabelCheck GetModel(string SN) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 SN,Lab from LabelCheck "); strSql.Append(" where SN=@SN "); SqlParameter[] parameters = { new SqlParameter("@SN", SqlDbType.VarChar, 50) }; parameters[0].Value = SN; Maticsoft.Model.LabelCheck model = new Maticsoft.Model.LabelCheck(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }