public Listado() { InitializeComponent(); textBoxUser.Focus(); consulta = "select distinct descripcion from GESTION_DE_GATOS.TiposDoc"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxTipoDoc.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select nombre from GESTION_DE_GATOS.Hotel"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxHotel.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select descripcion from GESTION_DE_GATOS.Rol"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxRol.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); dateTimePicker1.Value = Home.fecha; }
public Alta() { InitializeComponent(); dir = 0; textBoxUser.Focus(); string consulta; consulta = "select distinct descripcion from GESTION_DE_GATOS.TiposDoc"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxTipoDoc.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select nombre from GESTION_DE_GATOS.Hotel where idHotel="+Login.HomeLogin.hotel; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxHotel.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select descripcion from GESTION_DE_GATOS.Rol where descripcion != 'ADMINISTRADOR GENERAL' and descripcion != 'GUEST'"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxRol.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); dateTimePicker1.Value = Home.fecha; }
public static void cargarListBox(ListBox unListBox, SqlDataReader reader) { while (reader.Read()) { unListBox.Items.Add(reader.GetSqlString(0)); } reader.Dispose(); }
public static void readVehiclesData() { string connectionString = "Server=localhost; Database=Vehicles; User Id=sa; Password=password"; System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString); sqlConnection.Open(); string sqlQuery = "SELECT TOP (1000) [VehicleID], [VIN], [SerialNumber], [VehicleNumber] FROM [Vehicles].[dbo].[Vehicle];"; System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(sqlQuery); command.Connection = sqlConnection; System.Data.SqlClient.SqlDataReader sqlreader = command.ExecuteReader(); while (sqlreader.Read()) { Console.WriteLine("{0}\t{1}\t{2}\t{3}", sqlreader.GetSqlString(0), sqlreader.GetSqlString(1), sqlreader.GetSqlString(2), sqlreader.GetSqlString(3)); } sqlreader.Close(); }
public static void cargarComboBox(ComboBox unCombo,SqlDataReader reader) { while (reader.Read()) { unCombo.Items.Add(reader.GetSqlString(0)); } reader.Dispose(); }
private void AltaDireccion_Load(object sender, EventArgs e) { string consulta = "select nombre from GESTION_DE_GATOS.Pais"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); textBox1.Focus(); }
public Baja() { InitializeComponent(); consulta = "select distinct descripcion from GESTION_DE_GATOS.TiposDoc"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); textBox1.Focus(); }
public ListadoDireccion(string nombreAbmPadre) { InitializeComponent(); abm = nombreAbmPadre; textBox1.Focus(); consulta = "select distinct nombre from GESTION_DE_GATOS.Pais"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); }
private void IntermediaUsuarioConRoles_Load(object sender, EventArgs e) { string consulta = "select distinct R.descripcion from GESTION_DE_GATOS.UserXRolXHotel U,GESTION_DE_GATOS.Rol R where U.rol=R.idRol and R.estado = 1 and U.usuario = " + Login.HomeLogin.idUsuario.ToString(); resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select distinct H.idHotel Id, H.nombre Nombre from GESTION_DE_GATOS.UserXRolXHotel U,GESTION_DE_GATOS.Hotel H where U.hotel=H.idHotel and U.usuario = " + Login.HomeLogin.idUsuario.ToString(); DataTable result = Home.BD.consulta(consulta); dataGridView1.DataSource = result; }
public Modificacion(decimal id,decimal ids,string username,string rol,string nombre,string apellido,string tel,string mail,string direccion,string nroDoc,string tipoDoc,string hotel,string fecha,string estado) { InitializeComponent(); iduser = id; idLoco = ids; dir = 0; textBoxUser.Focus(); string consulta; consulta = "select distinct descripcion from GESTION_DE_GATOS.TiposDoc"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxTipoDoc.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select nombre from GESTION_DE_GATOS.Hotel where idHotel=" + Login.HomeLogin.hotel; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxHotel.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select descripcion from GESTION_DE_GATOS.Rol"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxRol.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); textBoxUser.Text = username; comboBoxRol.Text = rol; textBoxNombre.Text = nombre; textBoxApellido.Text = apellido; textBoxTel.Text = tel; textBoxDir.Text = direccion; dir = Convert.ToDecimal(direccion); textBoxNroDoc.Text = nroDoc; textBoxMail.Text = mail; comboBoxTipoDoc.Text = tipoDoc; comboBoxHotel.Text = hotel; dateTimePicker1.Text = fecha; if (estado == "True") { checkBox2.Checked = true; } }
//private string StrMsg = ""; private void button1_Click(object sender, EventArgs e) { this.myConn = new SqlConnection(); this.myConn.ConnectionString = conn; this.myCmd = new SqlCommand(); this.myCmd.CommandType = System.Data.CommandType.Text; this.myCmd.Connection = myConn; myConn.Open(); myCmd.CommandText = this.txt_Query.Text; myCmd.ExecuteNonQuery(); this.myReader = myCmd.ExecuteReader(); this.myReader.Read(); this.txt_Result.Text = myReader.GetSqlString(0).ToString(); // this.txt_Result.Text = myReader.GetSqlDateTime(0).ToString(); }
public Modificacion_Direccion(decimal direccion) { InitializeComponent(); string consulta = "select nombre from GESTION_DE_GATOS.Pais"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); idDir = direccion; consulta = "select D.calle,D.numero,D.piso,D.depto,D.ciudad,P.nombre from GESTION_DE_GATOS.Direccion D,GESTION_DE_GATOS.Pais P where D.pais = P.idPais and D.idDir = " + direccion.ToString(); resultado = Home.BD.comando(consulta); if (resultado.Read()) { textBox1.Text = resultado.GetString(0); textBox2.Text = resultado.GetDecimal(1).ToString(); if(string.IsNullOrEmpty(resultado.GetValue(2).ToString())) { } else { textBox3.Text= resultado.GetDecimal(2).ToString(); } if (string.IsNullOrEmpty(resultado.GetValue(3).ToString())) { } else { textBox4.Text = resultado.GetString(3); } if (string.IsNullOrEmpty(resultado.GetValue(3).ToString())) { } else { textBox5.Text = resultado.GetString(4); } comboBox1.Text = resultado.GetString(5); } resultado.Close(); textBox1.Focus(); }
public Baja() { InitializeComponent(); consulta = "select distinct descripcion from GESTION_DE_GATOS.TipoHabitacion"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select nombre from GESTION_DE_GATOS.Hotel where idHotel = " + Login.HomeLogin.hotel; resultado = Home.BD.comando(consulta); if (resultado.Read()) { textBox6.Text = resultado.GetString(0); } resultado.Close(); textBox1.Focus(); }
public AltaCli() { InitializeComponent(); consulta = "select distinct nombre from GESTION_DE_GATOS.Hotel"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); dateTimePicker1.Value = Home.fecha; dateTimePicker2.Value = Home.fecha; tabla = new DataTable(); tabla.Columns.Add("Id"); DataColumn column = tabla.Columns["Id"]; column.Unique = true; tabla.Columns.Add("Precio"); bSource2 = new BindingSource(); bSource2.DataSource = tabla; //set the DataGridView DataSource dataGridView2.DataSource = bSource2; }
public Alta(string abmPadre) { InitializeComponent(); abm = abmPadre; dir = 0; textBoxNombre.Focus(); string consulta; consulta = "select distinct descripcion from GESTION_DE_GATOS.TiposDoc"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxTipoDoc.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select distinct nombre from GESTION_DE_GATOS.Pais"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); dateTimePicker1.Value = Home.fecha; }
public Modificacion(decimal id,string nombre,string apellido,string tipoDoc,string nroDoc,string mail,string telefono,string nacionalidad,string direccion,string fecha_nac,string Habilitado) { InitializeComponent(); textBoxNombre.Focus(); string consulta; iduser = id; consulta = "select distinct descripcion from GESTION_DE_GATOS.TiposDoc"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBoxTipoDoc.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select distinct nombre from GESTION_DE_GATOS.Pais"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); textBoxNombre.Text = nombre; textBoxApellido.Text = apellido; textBoxTel.Text = telefono; textBoxDir.Text = direccion; dir = Convert.ToDecimal(direccion); textBoxNroDoc.Text = nroDoc; textBoxMail.Text = mail; comboBoxTipoDoc.Text = tipoDoc; dateTimePicker1.Text = fecha_nac; comboBox1.Text = nacionalidad; if (Habilitado == "True") { checkBox2.Checked = true; } }
public Facturacion(string idEstadia) { InitializeComponent(); textBox1.Text = idEstadia; consulta = "select reserva from GESTION_DE_GATOS.Estadia where idEstadia = " + idEstadia; resultado = Home.BD.comando(consulta); resultado.Read(); textBox2.Text = resultado.GetDecimal(0).ToString(); resultado.Close(); consulta = "select distinct descripcion from GESTION_DE_GATOS.FormaDePago"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select ingreso,salida,dias_sobran,cantidadNoches,precioPorNoche from GESTION_DE_GATOS.Estadia where idEstadia = " + idEstadia; resultado = Home.BD.comando(consulta); resultado.Read(); DateTime ingreso = resultado.GetDateTime(0); DateTime salida = resultado.GetDateTime(1); decimal diasSobran = resultado.GetDecimal(2); decimal cantNoches = resultado.GetDecimal(3); decimal precio = resultado.GetDecimal(4); textBox4.Text = ingreso.ToShortDateString(); textBox5.Text = ingreso.AddDays(Convert.ToDouble(cantNoches+diasSobran)).ToShortDateString(); textBox6.Text = salida.ToShortDateString(); resultado.Close(); tablaDias = new DataTable(); tablaDias.Columns.Add("Fecha"); tablaDias.Columns.Add("Precio"); tablaDias.Columns.Add("Descripcion"); decimal auxcantnoches = cantNoches; decimal auxdiassobran = diasSobran; DataRow row = tablaDias.NewRow(); while (cantNoches >0) { row = tablaDias.NewRow(); row["Fecha"] = ingreso; row["Precio"] = precio; row["Descripcion"] = "SE ALOJO"; tablaDias.Rows.Add(row); ingreso = ingreso.AddDays(1); cantNoches--; } while (diasSobran > 0) { row = tablaDias.NewRow(); row["Fecha"] = ingreso; row["Precio"] = precio; row["Descripcion"] = "NO SE ALOJO"; tablaDias.Rows.Add(row); ingreso = ingreso.AddDays(1); diasSobran--; } bSource2 = new BindingSource(); bSource2.DataSource = tablaDias; //set the DataGridView DataSource dataGridView1.DataSource = bSource2; textBox7.Text = (precio * (auxdiassobran + auxcantnoches)).ToString(); //aca iria lo de los consumibles, que hay que utilizar itemFactura string query = "select I.cantidad Cantidad, I.descripcion Descripcion, I.monto Monto from GESTION_DE_GATOS.ItemFactura I,GESTION_DE_GATOS.Factura F where I.factura = F.numero and I.descripcion != 'Estadia' and F.estadia = "+idEstadia; SqlDataAdapter sAdapter = FrbaHotel.Home.BD.dameDataAdapter(query); consumibles = FrbaHotel.Home.BD.dameDataTable(sAdapter); //BindingSource to sync DataTable and DataGridView BindingSource bSource = new BindingSource(); //set the BindingSource DataSource bSource.DataSource = consumibles; //set the DataGridView DataSource dataGridView2.DataSource = bSource; consulta = "select C.precio from GESTION_DE_GATOS.ConsumibleXEstadia CE, GESTION_DE_GATOS.Consumibles C where CE.consumible = C.idConsumible and CE.estadia = " + idEstadia; resultado = Home.BD.comando(consulta); if (resultado.Read()==true) { resultado.Close(); consulta = "select sum(C.precio) from GESTION_DE_GATOS.ConsumibleXEstadia CE, GESTION_DE_GATOS.Consumibles C where CE.consumible = C.idConsumible and CE.estadia = " + idEstadia; resultado = Home.BD.comando(consulta); resultado.Read(); textBox9.Text = resultado.GetDecimal(0).ToString(); } else { textBox9.Text = 0.ToString(); } resultado.Close(); consulta = "select R.regimen from GESTION_DE_GATOS.Reserva R, GESTION_DE_GATOS.Estadia E where E.reserva= R.idReserva and E.idEstadia = " + idEstadia; resultado = Home.BD.comando(consulta); resultado.Read(); decimal regimen = resultado.GetDecimal(0); resultado.Close(); if (regimen == 3) { textBox8.Text = "-"+textBox9.Text; textBox3.Text = textBox7.Text; } else { textBox8.Text = 0.ToString(); decimal resu = Convert.ToDecimal(textBox7.Text) + Convert.ToDecimal(textBox9.Text); textBox3.Text = (resu).ToString(); } }
private void MainFuncionalidades_Load(object sender, EventArgs e) { string consulta = "select distinct F.denominacion from GESTION_DE_GATOS.UserXRolXHotel U,GESTION_DE_GATOS.FuncXRol FR, GESTION_DE_GATOS.Funcionalidad F,GESTION_DE_GATOS.Rol R where R.descripcion='" + Login.HomeLogin.rol + "' and R.idRol = U.rol and U.rol=FR.rol and FR.funcionalidad = F.idFuncionalidad and U.usuario = " + Login.HomeLogin.idUsuario.ToString() + " and U.hotel='" + Login.HomeLogin.hotel+"'"; resultado = Home.BD.comando(consulta); while (resultado.Read() == true) { comboBox1.Items.Add(resultado.GetSqlString(0)); } resultado.Close(); consulta = "select distinct H.nombre from GESTION_DE_GATOS.Hotel H where H.idHotel = " + Login.HomeLogin.hotel.ToString(); resultado = Home.BD.comando(consulta); resultado.Read(); listBox1.Items.Add(resultado.GetSqlString(0)); resultado.Close(); }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_CompanyNameWasUpdated = false; this.col_CompanyNameWasSet = false; this.col_CompanyName = System.Data.SqlTypes.SqlString.Null; this.col_ContactNameWasUpdated = false; this.col_ContactNameWasSet = false; this.col_ContactName = System.Data.SqlTypes.SqlString.Null; this.col_TitleIdWasUpdated = false; this.col_TitleIdWasSet = false; this.col_TitleId = System.Data.SqlTypes.SqlInt32.Null; this.col_AddressWasUpdated = false; this.col_AddressWasSet = false; this.col_Address = System.Data.SqlTypes.SqlString.Null; this.col_CityWasUpdated = false; this.col_CityWasSet = false; this.col_City = System.Data.SqlTypes.SqlString.Null; this.col_PostalCodeWasUpdated = false; this.col_PostalCodeWasSet = false; this.col_PostalCode = System.Data.SqlTypes.SqlString.Null; this.col_PhoneWasUpdated = false; this.col_PhoneWasSet = false; this.col_Phone = System.Data.SqlTypes.SqlString.Null; this.col_EmailWasUpdated = false; this.col_EmailWasSet = false; this.col_Email = System.Data.SqlTypes.SqlString.Null; this.col_WebAddressWasUpdated = false; this.col_WebAddressWasSet = false; this.col_WebAddress = System.Data.SqlTypes.SqlString.Null; this.col_FaxWasUpdated = false; this.col_FaxWasSet = false; this.col_Fax = System.Data.SqlTypes.SqlString.Null; this.col_ActiveWasUpdated = false; this.col_ActiveWasSet = false; this.col_Active = System.Data.SqlTypes.SqlBoolean.Null; bool alreadyOpened = false; Params.spS_Customers Param = new Params.spS_Customers(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_CustomerID.IsNull) { Param.Param_CustomerID = this.col_CustomerID; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_Customers Sp = new SPs.spS_Customers(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex)) { this.col_CompanyName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex)) { this.col_ContactName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex)) { this.col_TitleId = sqlDataReader.GetSqlInt32(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex)) { this.col_Address = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex)) { this.col_City = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex)) { this.col_PostalCode = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex)) { this.col_Phone = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex)) { this.col_Email = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex)) { this.col_WebAddress = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex)) { this.col_Fax = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex)) { this.col_Active = sqlDataReader.GetSqlBoolean(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Customer", "Refresh"); } }
public void GetStringTest () { cmd.CommandText = "Select type_varchar,10,convert(varchar,null)"; cmd.CommandText += "from string_family where id=1"; reader = cmd.ExecuteReader (); reader.Read (); // Test for standard exceptions GetMethodTests("String"); // Test if data is returned correctly Assert.AreEqual (stringRow["type_varchar"], reader.GetString(0), "#2 DataValidation Failed"); // Test for standard exceptions GetMethodTests("SqlString"); // Test if data is returned correctly Assert.AreEqual (stringRow["type_varchar"], reader.GetSqlString(0).Value, "#4 DataValidation Failed"); reader.Close(); }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_TitleWasUpdated = false; this.col_TitleWasSet = false; this.col_Title = System.Data.SqlTypes.SqlString.Null; bool alreadyOpened = false; Params.spS_Title Param = new Params.spS_Title(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_TitleId.IsNull) { Param.Param_TitleId = this.col_TitleId; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_Title Sp = new SPs.spS_Title(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_Title.Resultset1.Fields.Column_Title.ColumnIndex)) { this.col_Title = sqlDataReader.GetSqlString(SPs.spS_Title.Resultset1.Fields.Column_Title.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Title", "Refresh"); } }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_JobIdWasUpdated = false; this.col_JobIdWasSet = false; this.col_JobId = System.Data.SqlTypes.SqlInt32.Null; this.col_DescriptionWasUpdated = false; this.col_DescriptionWasSet = false; this.col_Description = System.Data.SqlTypes.SqlString.Null; this.col_JobPartTypeIdWasUpdated = false; this.col_JobPartTypeIdWasSet = false; this.col_JobPartTypeId = System.Data.SqlTypes.SqlInt32.Null; this.col_UnitsWasUpdated = false; this.col_UnitsWasSet = false; this.col_Units = System.Data.SqlTypes.SqlDecimal.Null; this.col_PricePerUnitWasUpdated = false; this.col_PricePerUnitWasSet = false; this.col_PricePerUnit = System.Data.SqlTypes.SqlMoney.Null; this.col_TotalPriceWasUpdated = false; this.col_TotalPriceWasSet = false; this.col_TotalPrice = System.Data.SqlTypes.SqlMoney.Null; bool alreadyOpened = false; Params.spS_JobPart Param = new Params.spS_JobPart(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_JobPartId.IsNull) { Param.Param_JobPartId = this.col_JobPartId; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_JobPart Sp = new SPs.spS_JobPart(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex)) { this.col_JobId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex)) { this.col_Description = sqlDataReader.GetSqlString(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex)) { this.col_JobPartTypeId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex)) { this.col_Units = sqlDataReader.GetSqlDecimal(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex)) { this.col_PricePerUnit = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex)) { this.col_TotalPrice = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPart_Record", "Refresh"); } }
private static MembershipEntry ConvertFromRow(SqlDataReader results, out string eTag, out int tableVersion, out string versionETag) { var entry = new MembershipEntry(); int port = results.GetInt32(PortIdx); int gen = results.GetInt32(GenerationIdx); entry.SiloAddress = SiloAddress.New(new IPEndPoint(IPAddress.Parse(results.GetString(AddressIdx)), port), gen); entry.HostName = results.GetString(HostNameIdx); entry.Status = (SiloStatus)results.GetInt32(StatusIdx); if (!results.GetSqlInt32(ProxyPortIdx).IsNull) entry.ProxyPort = results.GetInt32(ProxyPortIdx); if (!results.GetSqlBoolean(PrimaryIdx).IsNull) entry.IsPrimary = results.GetBoolean(PrimaryIdx); entry.RoleName = results.GetString(RoleNameIdx); entry.InstanceName = results.GetString(InstanceNameIdx); if (!results.GetSqlInt32(UpdateZoneIdx).IsNull) entry.UpdateZone = results.GetInt32(UpdateZoneIdx); if (!results.GetSqlInt32(FaultZoneIdx).IsNull) entry.FaultZone = results.GetInt32(FaultZoneIdx); if (!results.GetSqlDateTime(StartTimeIdx).IsNull) entry.StartTime = results.GetDateTime(StartTimeIdx); if (!results.GetSqlDateTime(IAmAliveTimeIdx).IsNull) entry.IAmAliveTime = results.GetDateTime(IAmAliveTimeIdx); eTag = results.GetString(ETagIdx); tableVersion = (int)results.GetInt64(VersionIdx); versionETag = results.GetString(VersionETagIdx); var suspectingSilosString = results.GetSqlString(SuspectingSilosIdx); var suspectingTimesString = results.GetSqlString(SuspectingTimesIdx); List<SiloAddress> suspectingSilos = new List<SiloAddress>(); List<DateTime> suspectingTimes = new List<DateTime>(); if (!suspectingSilosString.IsNull && !string.IsNullOrEmpty(suspectingSilosString.Value)) { string[] silos = suspectingSilosString.Value.Split('|'); foreach (string silo in silos) { suspectingSilos.Add(SiloAddress.FromParsableString(silo)); } } if (!suspectingTimesString.IsNull && !string.IsNullOrEmpty(suspectingTimesString.Value)) { string[] times = suspectingTimesString.Value.Split('|'); foreach (string time in times) { suspectingTimes.Add(TraceLogger.ParseDate(time)); } } if (suspectingSilos.Count != suspectingTimes.Count) throw new OrleansException(String.Format("SuspectingSilos.Length of {0} as read from SQL table is not eqaul to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count)); for (int i = 0; i < suspectingSilos.Count; i++) { entry.AddSuspector(suspectingSilos[i], suspectingTimes[i]); } return entry; }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_Pro_StrNameWasUpdated = false; this.col_Pro_StrNameWasSet = false; this.col_Pro_StrName = System.Data.SqlTypes.SqlString.Null; this.col_Pro_CurPriceWasUpdated = false; this.col_Pro_CurPriceWasSet = false; this.col_Pro_CurPrice = System.Data.SqlTypes.SqlMoney.Null; this.col_Pro_LngCategoryIDWasUpdated = false; this.col_Pro_LngCategoryIDWasSet = false; this.col_Pro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null; bool alreadyOpened = false; Params.spS_tblProduct Param = new Params.spS_tblProduct(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_Pro_GuidID.IsNull) { Param.Param_Pro_GuidID = this.col_Pro_GuidID; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_tblProduct Sp = new SPs.spS_tblProduct(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_StrName.ColumnIndex)) { this.col_Pro_StrName = sqlDataReader.GetSqlString(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_StrName.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_CurPrice.ColumnIndex)) { this.col_Pro_CurPrice = sqlDataReader.GetSqlMoney(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_CurPrice.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_LngCategoryID.ColumnIndex)) { this.col_Pro_LngCategoryID = sqlDataReader.GetSqlInt32(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_LngCategoryID.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Product", "Refresh"); } }