public List <GeneralLedgerListViewModel> GetGeneralLedgerList(int StatementType) { List <GeneralLedgerListViewModel> ledgerList = new List <GeneralLedgerListViewModel>(); try { using (SqlConnection connection = DataAccess.CreateConnection()) { SqlCommand command = DataAccess.CreateCommand(connection); DataAccess.CreateStoredprocedure(command, "GetGeneralLedgerList_SP"); DataAccess.AddInParameter(command, "@StatementType", SqlDbType.Int, StatementType); SqlDataReader reader = DataAccess.ExecuteReader(command); if (reader != null) { while (reader.Read()) { GeneralLedgerListViewModel Obj = new GeneralLedgerListViewModel(); Obj.LedgerDate = reader["LedgerDate"] is DBNull ? "0000-00-00" : Convert.ToString(reader["LedgerDate"]); Obj.UserName = reader["UserName"] is DBNull ? string.Empty : Convert.ToString(reader["UserName"]); Obj.LedgerHead = reader["LedgerHead"] is DBNull ? string.Empty : Convert.ToString(reader["LedgerHead"]); Obj.PaymentMethod = reader["PaymentMethod"] is DBNull ? string.Empty : ((PaymentMethod)reader["PaymentMethod"]).ToString(); Obj.Notes = reader["UserName"] is DBNull ? string.Empty : Convert.ToString(reader["Notes"]); Obj.LedgerType = reader["LedgerType"] is DBNull ? string.Empty : Convert.ToString(reader["LedgerType"]); Obj.Amount = reader["Amount"] is DBNull ? 0 : Convert.ToDouble(reader["Amount"]); ledgerList.Add(Obj); } } reader.Close(); return(ledgerList); } } catch (Exception ex) { return(ledgerList); } }
public List <GeneralLedgerListViewModel> FilterGeneralLedgerList(string Query) { List <GeneralLedgerListViewModel> ledgerList = new List <GeneralLedgerListViewModel>(); try { using (SqlConnection connection = DataAccess.CreateConnection()) { SqlCommand command = new SqlCommand(Query, connection); //connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader != null) { while (reader.Read()) { GeneralLedgerListViewModel Obj = new GeneralLedgerListViewModel(); Obj.LedgerDate = reader["LedgerDate"] is DBNull ? "0000-00-00" : Convert.ToString(reader["LedgerDate"]); Obj.UserName = reader["UserName"] is DBNull ? string.Empty : Convert.ToString(reader["UserName"]); Obj.LedgerHead = reader["LedgerHead"] is DBNull ? string.Empty : Convert.ToString(reader["LedgerHead"]); Obj.PaymentMethod = reader["PaymentMethod"] is DBNull ? string.Empty : ((PaymentMethod)reader["PaymentMethod"]).ToString(); Obj.Notes = reader["UserName"] is DBNull ? string.Empty : Convert.ToString(reader["Notes"]); Obj.LedgerType = reader["LedgerType"] is DBNull ? string.Empty : Convert.ToString(reader["LedgerType"]); Obj.Amount = reader["Amount"] is DBNull ? 0 : Convert.ToDouble(reader["Amount"]); ledgerList.Add(Obj); } } reader.Close(); return(ledgerList); } } catch (Exception ex) { return(ledgerList); } }