/// <summary> /// 更新一条数据 /// </summary> public bool Update(DBCommon.Model.DBBranch model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BranchInfo set "); strSql.Append("Name=@Name,"); strSql.Append("ParentBranchID=@ParentBranchID,"); strSql.Append("MasterID=@MasterID"); strSql.Append(" where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@Name", DbType.String, 2147483647), new SQLiteParameter("@ParentBranchID", DbType.String, 2147483647), new SQLiteParameter("@MasterID", DbType.String, 2147483647), new SQLiteParameter("@ID", DbType.String, 2147483647) }; parameters[0].Value = model.Name; parameters[1].Value = model.ParentBranchID; parameters[2].Value = model.MasterID; parameters[3].Value = model.ID; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DBCommon.Model.DBBranch model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BranchInfo("); strSql.Append("ID,Name,ParentBranchID,MasterID)"); strSql.Append(" values ("); strSql.Append("@ID,@Name,@ParentBranchID,@MasterID)"); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.String, 2147483647), new SQLiteParameter("@Name", DbType.String, 2147483647), new SQLiteParameter("@ParentBranchID", DbType.String, 2147483647), new SQLiteParameter("@MasterID", DbType.String, 2147483647) }; parameters[0].Value = model.ID; parameters[1].Value = model.Name; parameters[2].Value = model.ParentBranchID; parameters[3].Value = model.MasterID; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBCommon.Model.DBBranch DataRowToModel(DataRow row) { DBCommon.Model.DBBranch model = new DBCommon.Model.DBBranch(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["ParentBranchID"] != null) { model.ParentBranchID = row["ParentBranchID"].ToString(); } if (row["MasterID"] != null) { model.MasterID = row["MasterID"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public DBCommon.Model.DBBranch GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,Name,ParentBranchID,MasterID from BranchInfo "); strSql.Append(" where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.String, 2147483647) }; parameters[0].Value = ID; DBCommon.Model.DBBranch model = new DBCommon.Model.DBBranch(); DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }