public static DBtblHouseBankingCollection GetAllItem() { string key = SETTINGS_ALL_KEY; object obj2 = dtpCache.Get(key); if ((obj2 != null)) { return((DBtblHouseBankingCollection)obj2); } DBtblHouseBankingCollection ItemCollection = new DBtblHouseBankingCollection(); Database db = SqlHelper.CreateConnection(SqlHelper.MyConnection); DbCommand dbCommand = db.GetStoredProcCommand("tblHouseBanking_GetAll"); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBtblHouseBanking item = GetItemFromReader(dataReader); ItemCollection.Add(item); } } if (AllowCache) { dtpCache.Max(key, ItemCollection); } return(ItemCollection); }
public static string GetJson(DBtblHouseBankingCollection itemCollection) { StringBuilder builder = new StringBuilder(); if (itemCollection.Count > 0) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); using (JsonWriter jsonWriter = new JsonTextWriter(sw)) { jsonWriter.Formatting = Formatting.Indented; jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName("results"); jsonWriter.WriteStartArray(); itemCollection.ForEach(delegate(DBtblHouseBanking objItem) { jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName("HouseCode"); jsonWriter.WriteValue(objItem.HouseCode.ToString()); jsonWriter.WritePropertyName("HPrice"); jsonWriter.WriteValue(objItem.HPrice.ToString()); jsonWriter.WritePropertyName("HLength"); jsonWriter.WriteValue(objItem.HLength.ToString()); jsonWriter.WritePropertyName("HWidth"); jsonWriter.WriteValue(objItem.HWidth.ToString()); jsonWriter.WritePropertyName("BRate"); jsonWriter.WriteValue(objItem.BRate.ToString()); jsonWriter.WritePropertyName("BYear"); jsonWriter.WriteValue(objItem.BYear.ToString()); jsonWriter.WritePropertyName("BMonth"); jsonWriter.WriteValue(objItem.BMonth.ToString()); jsonWriter.WritePropertyName("CreatedUser"); jsonWriter.WriteValue(objItem.CreatedUser.ToString()); jsonWriter.WritePropertyName("CreatedDate"); jsonWriter.WriteValue(objItem.CreatedDate.ToString()); jsonWriter.WriteEndObject(); }); jsonWriter.WriteEndArray(); jsonWriter.WriteEndObject(); builder.AppendLine(sw.ToString()); } } else { // builder.AppendLine(@"{""results"":[{""id"":""-1"",""myvalue"":""" + MainFunction.ngonngu("gl.nodata") + @"""}]}"); } return(builder.ToString()); }
public static DBtblHouseBankingCollection GetItemPagging(int page, int rec, string strSearch, out int TotalRecords) { TotalRecords = 0; DBtblHouseBankingCollection ItemCollection = new DBtblHouseBankingCollection(); Database db = SqlHelper.CreateConnection(SqlHelper.MyConnection); DbCommand dbCommand = db.GetStoredProcCommand("tblHouseBanking_Paging"); db.AddInParameter(dbCommand, "Page", DbType.Int32, page); db.AddInParameter(dbCommand, "RecsPerPage", DbType.Int32, rec); db.AddInParameter(dbCommand, "SearchValue", DbType.String, strSearch); db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBtblHouseBanking item = GetItemFromReader(dataReader); ItemCollection.Add(item); } } TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords")); return(ItemCollection); }