public List <CompanyDatumWithUid> GetForApi(int pageSize, ref int pageIndex, string searchText, out int totalCount) { if (pageSize < 5) { pageSize = 5; } int rowsOffset = pageIndex * pageSize; int tmpCount = 0; DoReadAll($"SELECT COUNT(*) AS CUS_COUNT FROM {TABLE}", (SqlDataReader reader) => { ConvertToInt(reader["CUS_COUNT"], out tmpCount); }); totalCount = tmpCount; string sql = $"SELECT * FROM {TABLE} " + $" WHERE {string.Join(" OR ", SEARCH_FIELDS.ConvertAll(o => $"{o} LIKE ?"))} " + $" ORDER BY {FIELD_NAME} OFFSET {rowsOffset} ROWS " + $" FETCH NEXT {pageSize} ROWS ONLY "; var list = new List <CompanyDatumWithUid>(); DoReadAll(sql, (SqlDataReader reader) => { CompanyDatumWithUid item = ConvertTo(reader); list.Add(item); }, SEARCH_FIELDS.ConvertAll(o => $"%{searchText}%").ToArray()); return(list); }
public void Patch([FromBody] string value) { CompanyDatumWithUid datum = Newtonsoft.Json.JsonConvert.DeserializeObject <CompanyDatumWithUid>(value); GlobalInstance.DB.RecordTable.Insert("Company Update", datum); GlobalInstance.DB.CompanyTable.Update(datum); }
public List <CompanyDatumWithUid> Get() { string sql = $"SELECT * FROM {TABLE}"; var list = new List <CompanyDatumWithUid>(); DoReadAll(sql, (SqlDataReader reader) => { CompanyDatumWithUid item = ConvertTo(reader); list.Add(item); }); return(list); }
public void Update(CompanyDatumWithUid datum) { DoExecuteNonQuery($"UPDATE {TABLE} SET {FIELD_NAME}=?, {FIELD_ADDRESS}=?, " + $"{FIELD_TELEPHONE}=? ,{FIELD_FAX}=? ,{FIELD_REMARK}=? WHERE {FIELD_UID}=?", datum.Name, datum.Address, datum.Telephone, datum.Fax, datum.Remark, datum.Uid); }