本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.GetFloat方法的具体用法?C# MySqlDataReader.GetFloat怎么用?C# MySqlDataReader.GetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlDataReader
的用法示例。
在下文中一共展示了MySqlDataReader.GetFloat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readerToKartaDTO
public static KartaDTO readerToKartaDTO(MySqlDataReader reader)
{
KartaDTO karta = new KartaDTO();
karta.Id = reader.GetInt32("idKarta");
karta.DatumProdaje = reader.GetDateTime("datumProdaje");
karta.Cijena = reader.GetFloat("cijenaKarta");
karta.BrojReda = reader.GetInt32("brojReda");
karta.BrojSjedista = reader.GetInt32("brojSjedista");
karta.Zaposleni = MySqlZaposleniDAO.readerToZaposleni(reader);
SalaDTO sala = MySqlSalaDAO.readerToSalaDTO(reader);
karta.Projekcija = MySqlProjekcijaDAO.readerToProjekcijaDTO(reader, sala);
karta.Status = MySqlStatusKartaDAO.readerToStatusKartaDTO(reader);
if (karta.Status.Naziv.Equals("rezervisana"))
{
karta.Rezervacija = MySqlRezervacijaDAO.readerToRezervacijaDTO(reader);
}
return karta;
}
示例2: button1_Click
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
MessageBox.Show("Необходимо указать тип помещения");
else
{
try
{
mconnect.Open();
//число помещений в базе
cmd.CommandText = "SELECT COUNT(*) FROM facility WHERE facility.usag = @typ";
cmd.Parameters["@typ"].Value = textBox1.Text;
double c = Convert.ToDouble(cmd.ExecuteScalar());
label6.Text = "Всего помещений: " + c.ToString();
//средняя температура по больнице
cmd.CommandText = "SELECT * FROM facility WHERE facility.usag = @typ";
float sumR = 0, sumS = 0;
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
sumR += rdr.GetFloat(2);
sumS += rdr.GetFloat(3);
}
rdr.Close();
label3.Text = "Средняя цена аренды: " + (sumR / c).ToString();
label4.Text = "Средняя цена продажи: " + (sumS / c).ToString();
//уровень спроса
double sp = 0;
cmd.CommandText = "SELECT COUNT(*) FROM RentDocument, facility WHERE RentDocument.Facility = facility.idfacility AND facility.usag = @typ";
sp += Convert.ToDouble(cmd.ExecuteScalar());
cmd.CommandText = "SELECT COUNT(*) FROM SaleDocument, facility WHERE SaleDocument.Facility = facility.idfacility AND facility.usag = @typ";
sp += Convert.ToDouble(cmd.ExecuteScalar());
label5.Text = "Уровень спроса: " + (sp / c).ToString() + "%";
//изменение цен
draw_axis(g);
p.Color = Color.Blue;
p.Width = 2;
Point preA = new Point();
Point preB = new Point();
Point A = new Point();
Point B = new Point();
preA.X = 39;
preA.Y = 275;
preB.X = 39;
preB.Y = 275;
cmd.CommandText = "SELECT RentPrice, SalePrice FROM facility WHERE facility.usag = @typ";
rdr = cmd.ExecuteReader();
int ax = Convert.ToInt32(387 / (c * 10));
while (rdr.Read())
{
float pr1 = rdr.GetFloat(0);
float pr2 = rdr.GetFloat(1);
A.X = ax + 50;
B.X = ax + 50;
A.Y = 275 - Convert.ToInt32(pr1 / (2920));
B.Y = 275 - Convert.ToInt32(pr2 / (2920)) - 10;
p.Color = Color.Blue;
g.DrawLine(p, preA.X, preA.Y, A.X, A.Y);
g.DrawString(pr1.ToString(), new System.Drawing.Font("Arial Black", 8, FontStyle.Regular, GraphicsUnit.Point), new SolidBrush(Color.Blue), new Point(A.X, A.Y - 15));
preA = A;
p.Color = Color.Red;
g.DrawLine(p, preB.X, preB.Y, B.X, B.Y);
g.DrawString(pr2.ToString(), new System.Drawing.Font("Arial Black", 8, FontStyle.Regular, GraphicsUnit.Point), new SolidBrush(Color.Red), new Point(B.X, B.Y - 15));
preB = B;
ax += 50;
}
rdr.Close();
img.Image = b1;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
if (mconnect != null)
mconnect.Close();
}
}
示例3: LoadFromReader
public void LoadFromReader(MySqlDataReader _reader)
{
m_id = _reader["id"].GetType() != typeof(System.DBNull) ? _reader.GetInt64("id") : 0;
mc_id = false;
m_entity_id = _reader["entity_id"].GetType() != typeof(System.DBNull) ? _reader.GetInt64("entity_id") : 0;
mc_entity_id = false;
m_proto_name = _reader["proto_name"].GetType() != typeof(System.DBNull) ? _reader.GetString("proto_name") : "";
mc_proto_name = false;
m_month = _reader["month"].GetType() != typeof(System.DBNull) ? _reader.GetByte("month") : (byte)0;
mc_month = false;
m_price = _reader["price"].GetType() != typeof(System.DBNull) ? _reader.GetFloat("price") : (double)0;
mc_price = false;
m_comment = _reader["comment"].GetType() != typeof(System.DBNull) ? _reader.GetString("comment") : "";
mc_comment = false;
}
示例4: LoadLine
private void LoadLine(MySqlDataReader rdr)
{
string temp = "";
if(!rdr.IsDBNull(0)) { line_no = rdr.GetInt32(0); ORDER_ARRAY[rowCount, CONST_LINE_NO] = line_no.ToString(); }
if (!rdr.IsDBNull(1)) { part_id = rdr.GetString(1); ORDER_ARRAY[rowCount, CONST_PARTID] = part_id; }
if (!rdr.IsDBNull(2)) { desc = rdr.GetString(2); ORDER_ARRAY[rowCount, CONST_DESC] = desc; }
if (!rdr.IsDBNull(3)) { ordered_qty = rdr.GetInt32(3); ORDER_ARRAY[rowCount, CONST_ORDERED] = ordered_qty.ToString(); }
if (!rdr.IsDBNull(4)) { unit_price = rdr.GetFloat(4); ORDER_ARRAY[rowCount, CONST_PRICE] = unit_price.ToString(); }
if (!rdr.IsDBNull(5)) { mod = rdr.GetChar(5); ORDER_ARRAY[rowCount, CONST_MOD] = mod.ToString(); }
if (!rdr.IsDBNull(6)) { gst = Math.Round(rdr.GetDouble(6), 2); ORDER_ARRAY[rowCount, CONST_GST] = gst.ToString(); }
if (!rdr.IsDBNull(7)) { pst = Math.Round(rdr.GetDouble(7), 2); ORDER_ARRAY[rowCount, CONST_PST] = pst.ToString(); }
if (!rdr.IsDBNull(8)) { notes = rdr.GetString(8); ORDER_ARRAY[rowCount, CONST_NOTES] = notes; }
bool cust = false;
if (mod == 'C')
cust = true;
DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
checkColumn.Name = "X";
checkColumn.HeaderText = "X";
checkColumn.Width = 50;
checkColumn.ReadOnly = false;
checkColumn.FillWeight = 10; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values
dgOrderForm.Rows.Add(line_no.ToString(), cust, part_id, "", desc, ordered_qty.ToString(), unit_price.ToString(), gst.ToString(), pst.ToString(), notes);
MAX_LINE = Convert.ToInt32(line_no);
}
示例5: QueryWeatherData
private void QueryWeatherData()
{
System.Text.EncodingProvider ppp;
ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);
// Query weather data from MySQL Server, update values in WeatherData - data parameters for display to screen (updatescreen()).
conn = null;
rdr = null;
try {
conn = new MySqlConnection(myConnectionString);
conn.Open();
cmd = new MySqlCommand(queryLastEntry, conn);
cmd2 = new MySqlCommand(queryDayMaxTemp, conn);
cmd3 = new MySqlCommand(queryDayMinTemp, conn);
cmd4 = new MySqlCommand(queryAnnualMaxTemp, conn);
cmd5 = new MySqlCommand(queryAnnualMinTemp, conn);
cmd6 = new MySqlCommand(queryPressureChangeThree, conn);
cmd7 = new MySqlCommand(queryPressureChangeSix, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
// Update screen with data from the most recent row of the weatherdata table only
data.TimeStamp = rdr.GetDateTime(0);
data.Altitude = rdr.GetFloat(1);
data.BarometricPressure = rdr.GetFloat(2);
data.CelsiusTemperature = rdr.GetFloat(3);
data.FahrenheitTemperature = rdr.GetFloat(4);
data.Humidity = rdr.GetFloat(5);
data.LightSensorVoltage = rdr.GetFloat(6);
LogToScreen("Last reading from board read to screen");
seaLevelPressure = getSeaLevelPressure(data.BarometricPressure, data.CelsiusTemperature, locationAlt);
}
rdr.Close();
rdr = cmd2.ExecuteReader();
while (rdr.Read())
{
data.DayMaxTempTime = rdr.GetDateTime(0);
data.DayMaxTemp = rdr.GetFloat(1);
LogToScreen("Maximum daily temperature queried and updated");
}
rdr.Close();
rdr = cmd3.ExecuteReader();
while (rdr.Read())
{
data.DayMinTempTime = rdr.GetDateTime(0);
data.DayMinTemp = rdr.GetFloat(1);
LogToScreen("Minimum daily temperature queried and updated");
}
rdr.Close();
rdr = cmd4.ExecuteReader();
while (rdr.Read())
{
data.AnnualMaxTempDate = rdr.GetDateTime(0);
data.AnnualMaxTemp = rdr.GetFloat(1);
LogToScreen("Maximum annual temperature queried and updated");
}
rdr.Close();
rdr = cmd5.ExecuteReader();
while (rdr.Read())
{
data.AnnualMinTempDate = rdr.GetDateTime(0);
data.AnnualMinTemp = rdr.GetFloat(1);
LogToScreen("Minimum annual temperature queried and updated");
}
rdr.Close();
rdr = cmd6.ExecuteReader();
while (rdr.Read())
{
data.PressThreeHrs = (rdr.GetFloat(1) - data.BarometricPressure);
LogToScreen("Pressure change over 3 hours queried and updated");
}
rdr.Close();
rdr = cmd7.ExecuteReader();
while (rdr.Read())
{
data.PressSixHrs = (rdr.GetFloat(1) - data.BarometricPressure);
LogToScreen("Pressure change over 3 hours queried and updated");
}
rdr.Close();
}
catch (Exception e)
{
LogToScreen("ERROR: Unable to successfully reach " + weatherUri + "!");
//.........这里部分代码省略.........
示例6: GetValue
// 取 dr 中某字段的数据并返回
public static object GetValue( DbColumn col, MySqlDataReader r, int idx )
{
switch( col.dataType )
{
case DbDataTypes.Boolean:
return r.GetBoolean( idx );
case DbDataTypes.Int8:
return r.GetSByte( idx );
case DbDataTypes.Int16:
return r.GetInt16( idx );
case DbDataTypes.Int32:
return r.GetInt32( idx );
case DbDataTypes.Int64:
return r.GetInt64( idx );
case DbDataTypes.UInt8:
return r.GetByte( idx );
case DbDataTypes.UInt16:
return r.GetUInt16( idx );
case DbDataTypes.UInt32:
return r.GetUInt32( idx );
case DbDataTypes.UInt64:
return r.GetUInt64( idx );
case DbDataTypes.Float:
return r.GetFloat( idx );
case DbDataTypes.Double:
return r.GetDouble( idx );
case DbDataTypes.DateTime:
return r.GetDateTime( idx );
case DbDataTypes.String:
return r.GetString( idx );
case DbDataTypes.Bytes:
var len = (int)r.GetBytes( idx, 0, null, 0, 0 );
var buf = new byte[ len ];
r.GetBytes( idx, 0, buf, 0, len );
return buf;
default:
throw new Exception( "unsupported DbType" );
}
}
示例7: FillValue
// 往 dr 填充 r 于 i 索引的值
public static void FillValue( DbRow dr, MySqlDataReader r, int i )
{
switch( dr.parent.columns[ i ].dataType )
{
case DbDataTypes.Boolean:
dr[ i ].Assign( r.GetBoolean( i ) ); break;
case DbDataTypes.Int8:
dr[ i ].Assign( r.GetSByte( i ) ); break;
case DbDataTypes.Int16:
dr[ i ].Assign( r.GetInt16( i ) ); break;
case DbDataTypes.Int32:
dr[ i ].Assign( r.GetInt32( i ) ); break;
case DbDataTypes.Int64:
dr[ i ].Assign( r.GetInt64( i ) ); break;
case DbDataTypes.UInt8:
dr[ i ].Assign( r.GetByte( i ) ); break;
case DbDataTypes.UInt16:
dr[ i ].Assign( r.GetUInt16( i ) ); break;
case DbDataTypes.UInt32:
dr[ i ].Assign( r.GetUInt32( i ) ); break;
case DbDataTypes.UInt64:
dr[ i ].Assign( r.GetUInt64( i ) ); break;
case DbDataTypes.Float:
dr[ i ].Assign( r.GetFloat( i ) ); break;
case DbDataTypes.Double:
dr[ i ].Assign( r.GetDouble( i ) ); break;
case DbDataTypes.DateTime:
dr[ i ].Assign( r.GetDateTime( i ) ); break;
case DbDataTypes.String:
dr[ i ].Assign( r.GetString( i ) ); break;
case DbDataTypes.Bytes:
var len = (int)r.GetBytes( i, 0, null, 0, 0 );
var buf = new byte[ len ];
r.GetBytes( i, 0, buf, 0, len );
dr[ i ].Assign( buf );
break;
default:
break;
}
}
示例8: SetProperty
public void SetProperty(object obj, SelectQueryFieldStore item,MySqlDataReader rdr)
{
var pinfo = obj.GetType().GetProperty(item.Property);
if (pinfo != null)
{
switch (item.Type)
{
case SelectQueryFieldStore.DataTypes.Int:
pinfo.SetValue(obj, rdr.GetInt32(item.Column), null);
break;
case SelectQueryFieldStore.DataTypes.Bool:
pinfo.SetValue(obj, Convert.ToBoolean(rdr.GetInt32(item.Column)), null);
break;
case SelectQueryFieldStore.DataTypes.Float:
pinfo.SetValue(obj, rdr.GetFloat(item.Column), null);
break;
case SelectQueryFieldStore.DataTypes.String:
pinfo.SetValue(obj, rdr.GetString(item.Column), null);
break;
case SelectQueryFieldStore.DataTypes.Long:
pinfo.SetValue(obj, rdr.GetInt64(item.Column), null);
break;
case SelectQueryFieldStore.DataTypes.Short:
pinfo.SetValue(obj, rdr.GetInt16(item.Column), null);
break;
default:
pinfo.SetValue(obj, rdr.GetString(item.Column), null);
break;
}
}
}