Ejemplo n.º 1
0
 public void MapProperties(System.Data.Common.DbDataReader dr)
 {
     ID              = dr.GetLong("ID");
     Invoice_ID      = dr.GetString("Invoice_ID");
     Payment_Type    = (DepositType)dr.GetByte("Payment_Type");
     Detail          = dr.GetString("Detail");
     Payment         = dr.GetDouble("Payment");
     Total_Payment   = dr.GetDouble("Total_Payment");
     Balance         = dr.GetDouble("Balance");
     Created_By      = dr.GetLong("Created_By");
     Updated_By      = dr.GetLong("Updated_By");
     Created_Date    = dr.GetDateTime("Created_Date");
     Updated_Date    = dr.GetDateTime("Updated_Date");
     Organization_ID = dr.GetLong("Organization_ID");
     IsActive        = dr.GetBoolean("IsActive");
     IsDeleted       = dr.GetBoolean("IsDeleted");
 }
        public void GetUsers()
        {
            string sql = "Select name, is_bot FROM users";

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = myConnection;
            cmd.CommandText = sql;

            using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string name   = reader.GetString(0);
                        bool   is_bot = reader.GetBoolean(1);
                        Console.WriteLine(name + " is bot - " + is_bot.ToString());
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private static Domain.IncomeGroupLimitGroup loadIncomeGroup(System.Data.Common.DbDataReader reader)
 {
     Domain.IncomeGroupLimitGroup income = new Domain.IncomeGroupLimitGroup();
     income.Limitation = new List <Domain.IncomeGroupLimit>();
     Domain.IncomeGroupLimit limit = null;
     while (reader.Read())
     {
         var currentId = reader.GetGuid(0);
         if (income.Id != currentId)
         {
             income.Id            = currentId;
             income.CompanyId     = reader.GetGuid(1);
             income.IncomeGroupId = reader.IsDBNull(2) ? (Guid?)null : reader.GetGuid(2);
             income.Remark        = reader.GetString(3);
             income.Limitation    = new List <Domain.IncomeGroupLimit>();
         }
         var currlimitId = reader.GetGuid(4);
         if (!income.Limitation.Any(it => it.Id == currlimitId))
         {
             limit               = new Domain.IncomeGroupLimit();
             limit.Id            = currlimitId;
             limit.IncomeId      = reader.GetGuid(5);
             limit.Type          = (Common.Enums.PeriodType)reader.GetByte(6);
             limit.Price         = reader.GetInt32(7);
             limit.Airlines      = reader.GetString(12);
             limit.IsOwnerPolicy = reader.GetBoolean(13);
             limit.Period        = new List <Domain.IncomeGroupPeriod>();
             income.Limitation.Add(limit);
         }
         Domain.IncomeGroupPeriod period = new Domain.IncomeGroupPeriod();
         period.DeductId    = reader.GetGuid(8);
         period.StartPeriod = reader.GetDecimal(9);
         period.EndPeriod   = reader.GetDecimal(10);
         period.Period      = reader.GetDecimal(11);
         limit.Period.Add(period);
     }
     return(income);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Generate CSV formatted output for the given reader.
        /// </summary>
        public string Generate(System.Data.Common.DbDataReader reader)
        {
            var builder = new StringBuilder();

            var schema   = reader.GetSchemaTable();
            var colcount = reader.FieldCount;
            var nullable = new bool[colcount];
            var datatype = new Type[colcount];
            var typename = new string[colcount];

            for (int c = 0; c < colcount; c++)
            {
                nullable[c] = true;
                datatype[c] = reader.GetFieldType(c);
                typename[c] = reader.GetDataTypeName(c);

                if (c == 0)
                {
                    if (this.Settings.AddLineNumbers)
                    {
                        if (this.Settings.QuotedStrings)
                        {
                            builder.Append(this.Settings.StringQuote);
                        }
                        builder.Append("Line");
                        if (this.Settings.QuotedStrings)
                        {
                            builder.Append(this.Settings.StringQuote);
                        }
                        builder.Append(this.Settings.FieldSeparator);
                    }
                }
                else
                {
                    builder.Append(this.Settings.FieldSeparator);
                }
                if (this.Settings.QuotedStrings)
                {
                    builder.Append(this.Settings.StringQuote);
                }
                builder.Append(reader.GetName(c));
                if (this.Settings.QuotedStrings)
                {
                    builder.Append(this.Settings.StringQuote);
                }
            }

            builder.Append(this.Settings.LineSeparator);

            var lineNumber = 0;

            while (reader.Read())
            {
                lineNumber++;

                for (int c = 0; c < colcount; c++)
                {
                    if (c == 0)
                    {
                        if (this.Settings.AddLineNumbers)
                        {
                            builder.Append(lineNumber);
                            builder.Append(this.Settings.FieldSeparator);
                        }
                    }
                    else
                    {
                        builder.Append(this.Settings.FieldSeparator);
                    }

                    if (nullable[c] && reader.IsDBNull(c))
                    {
                    }
                    else
                    {
                        if (datatype[c] == typeof(String))
                        {
                            if (this.Settings.QuotedStrings)
                            {
                                builder.Append(this.Settings.StringQuote);
                            }
                            builder.Append(ToCsvableString(reader.GetString(c)));
                            if (this.Settings.QuotedStrings)
                            {
                                builder.Append(this.Settings.StringQuote);
                            }
                        }
                        else if (datatype[c] == typeof(DateTime))
                        {
                            builder.Append(reader.GetDateTime(c).ToString(this.Settings.DateTimeFormat, this.Settings.FormatProvider));
                        }
                        else if (datatype[c] == typeof(Boolean))
                        {
                            builder.Append(reader.GetBoolean(c) ? this.Settings.BooleanTrue : this.Settings.BooleanFalse);
                        }
                        else
                        {
                            builder.AppendFormat(this.Settings.FormatProvider, "{0}", reader.GetValue(c));
                        }
                    }
                }

                builder.Append(this.Settings.LineSeparator);
            }

            return(builder.ToString());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a bool column. Slower then GetOrdinal + GetBoolean
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool GetBoolean(this System.Data.Common.DbDataReader reader, string name)
        {
            int ordinal = reader.GetOrdinal(name);

            return(reader.GetBoolean(ordinal));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets a bool column.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="ordinal">The column number</param>
 /// <returns></returns>
 public static bool?GetNBoolean(this System.Data.Common.DbDataReader reader, int ordinal)
 {
     return(reader.IsDBNull(ordinal) ? (bool?)null : reader.GetBoolean(ordinal));
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets a bool column. Slower then GetOrdinal + GetBool
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool?GetNBoolean(this System.Data.Common.DbDataReader reader, string name)
        {
            int ordinal = reader.GetOrdinal(name);

            return(reader.IsDBNull(ordinal) ? (bool?)null : reader.GetBoolean(ordinal));
        }