/// <summary> /// 更新一条数据 /// </summary> public bool Update(ProductSortMDL model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update productsort set "); strSql.Append("sortnum=@sortnum"); strSql.Append(" where productcode='@productcode'"); SQLiteParameter[] parameters = { new SQLiteParameter("@sortnum", model.SortNum), new SQLiteParameter("@productcode", model.ProductCode) }; int rows = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ProductSortMDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into productsort("); strSql.Append("productcode,sortnum)"); strSql.Append(" values ("); strSql.Append("@productcode,@sortnum)"); SQLiteParameter[] parameters = { new SQLiteParameter("@productcode", model.ProductCode), new SQLiteParameter("@sortnum", model.SortNum) }; int rows = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ProductSortMDL DataRowToModel(DataRow row) { ProductSortMDL model = new ProductSortMDL(); if (row != null) { if (row["productcode"] != null) { model.ProductCode = row["productcode"].ToString(); } if (row["sortnum"] != null && row["sortnum"].ToString() != "") { model.SortNum = int.Parse(row["sortnum"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public ProductSortMDL GetModel(string code) { StringBuilder strSql = new StringBuilder(); strSql.Append("select productcode,sortnum from productsort "); strSql.Append(" where productcode=@productcode"); SQLiteParameter[] parameters = { new SQLiteParameter("@productcode", code) }; ProductSortMDL model = new ProductSortMDL(); DataSet ds = SQLiteHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }