public bool Insertar() { ConexionDB cdb = new ConexionDB(); string sql = "INSERT INTO Estudiantes(Matricula, Nombres, Apellidos, Direccion, Genero, FechaNacimiento, Email, Telefono, Celular) " + "VALUES ('" + Matricula + "','" + Nombres + "','" + Apellidos + "','" + Direccion + "', " + Genero + " ,'" + FechaNacimiento + "','" + Email + "','" + Telefono + "','" + Celular + "')"; return cdb.EjecutarComando(sql); }
public void Modificar(string matricula) { ConexionDB cdb = new ConexionDB(); string sql = "UPDATE Estudiantes SET Nombres = '" + Nombres + "', Apellidos = '" + Apellidos + "', Direccion = '" + Direccion + "', Genero = " + Genero + ", FechaNacimiento = '" + FechaNacimiento + "', Email = '" + Email + "', Telefono = '" + Telefono + "', Celular = '" + Celular + "' WHERE Matricula = " + matricula; cdb.EjecutarComando(sql); }
public void Buscar(string matricula) { ConexionDB cdb = new ConexionDB(); string sql = "SELECT Matricula, Nombres, Apellidos, Direccion, Genero, FechaNacimiento, Email, Telefono, Celular From Estudiantes Where Matricula = " + matricula; DataTable dt = new DataTable(); dt = cdb.getReader(sql); if (dt.Rows.Count > 0) { Matricula = (string)dt.Rows[0]["Matricula"]; Nombres = (string)dt.Rows[0]["Nombres"]; Apellidos = (string)dt.Rows[0]["Apellidos"]; Direccion = (string)dt.Rows[0]["Direccion"]; Genero = (byte)dt.Rows[0]["Genero"]; FechaNacimiento = (DateTime)dt.Rows[0]["FechaNacimiento"]; Email = (string)dt.Rows[0]["Email"]; Telefono = (string)dt.Rows[0]["Telefono"]; Celular = (string)dt.Rows[0]["Celular"]; } }
public override bool Editar() { ConexionDB Conexion = new ConexionDB(); bool Retorno = false; try { Retorno = Conexion.Ejecutar(String.Format("Update Ventas set Fecha='{0}', Monto={1} where VentaId= {2}", this.Fecha, this.Monto, this.VentaId)); if (Retorno) { Conexion.Ejecutar(String.Format("Delete from VentasDetalle Where VentaId= {0}", this.VentaId)); foreach (VentasDetalle var in this.Detalle) { Conexion.Ejecutar(string.Format("Insert into VentasDetalle(VentaId, ArticuloId, Cantidad, Precio) Values ({0},{1},{2},{3})", this.VentaId, var.ArticuloId, var.Cantidad, var.Precio)); } } } catch (Exception ex) { throw ex; } return(Retorno); }
public string Grabar_Lote_Control_Acceso(string jsonLote) { var jsonRes = string.Empty; try { ConexionDB cn = new ConexionDB("dbo.WS_CTL_ACC_Grabar_Lote"); cn.AsignarParametro("@json", jsonLote); var dr = cn.EjecutarConsulta(); if (dr.Read()) { jsonRes = dr[0].ToString(); dr.Close(); dr.Dispose(); } dr = null; } catch (Exception ex) { jsonRes = "{'resultado':'No fue posible guardar el Lote.','detalle':'" + ex.Message + "'}"; } return(jsonRes); }
public override bool Editar() { ConexionDB Conexion = new ConexionDB(); bool Retorno = false; try { Retorno = Conexion.Ejecutar(String.Format("Update Solicitudes set Fecha='{0}', Razon='{1}', Total= {2} where MaterialId= {3}", this.Razon, this.SolicitudlId)); if (Retorno) { Conexion.Ejecutar(String.Format("Delete from SolicitudesDetalle Where SolicitudlId= {0}", this.SolicitudlId)); foreach (SolicitudesDetalle var in this.Detalle) { Conexion.Ejecutar(string.Format("Insert into SolicitudesDetalle(SolicitudId, MaterialId Material, Cantidad) Values ({0},{1},'{2}', {3})", this.SolicitudlId, var.MaterialId, var.Material, var.Cantidad)); } } } catch (Exception ex) { throw ex; } return(Retorno); }
public static DataSet Datos(string StoreProcedure, SqlParameter[] Parametros) { SqlConnection objconexion; SqlCommand cmd; objconexion = Conexion.OpenConexion(); cmd = new SqlCommand(StoreProcedure, objconexion); cmd.CommandType = CommandType.StoredProcedure; foreach (var item in Parametros) { cmd.Parameters.Add(item).Value = item.Value; } SqlDataAdapter DataAdapter = new SqlDataAdapter(cmd); DataSet DS = new DataSet(); DataAdapter.Fill(DS, "Result"); ConexionDB.CloseConexion(cmd); return(DS); }
public AdministrarFactura() { InitializeComponent(); dataGridViewBuscarFactura.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGray; dataGridViewBuscarFactura.ColumnHeadersDefaultCellStyle.Font = new Font(" Microsoft Sans Serif", 8.25F, FontStyle.Bold); dataGridViewBuscarFactura.EnableHeadersVisualStyles = false; SQLParametros parametros = new SQLParametros(); DataTable empresas; if (ConexionDB.Procedure("obtenerEmpresas", parametros.get(), out empresas)) { comboBoxEmpresa.DisplayMember = "nombreEmpresa"; comboBoxEmpresa.ValueMember = "idEmpresa"; comboBoxEmpresa.DataSource = empresas; comboBoxEmpresa.Update(); comboBoxEmpresa.SelectedIndex = -1; comboBoxEmpresa.SelectedValue = -1; } }
public Boolean validarEmailUnico() { String query; if (!string.IsNullOrEmpty(txtCliente_Email.Text)) { ConexionDB bd = new ConexionDB(); query = this.armarQuery(); DataTable resultado = bd.Select(query); if (resultado.Rows.Count > 0) { labelEmail.Text = "Ya existe un Cliente con el Mail: " + txtCliente_Email.Text; labelEmail.ForeColor = System.Drawing.Color.Red; return(true); } return(false); } else { return(true); } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { ConexionDB conn = new ConexionDB(); conn.OpenConection(); SqlDataReader dr = conn.DataReader("Select Id_usuario, nombre From usuario where usuario = '" + UserName.Text + "' and password = '******'"); if (dr.HasRows) { dr.Read(); HttpContext.Current.Session["UserId"] = dr["Id_usuario"].ToString(); HttpContext.Current.Session["UserName"] = dr["Nombre"].ToString(); conn.CloseConnection(); IdentityHelper.RedirectToReturnUrl("~/default", Response); } else { conn.CloseConnection(); FailureText.Text = "Usuario o password invalidos."; ErrorMessage.Visible = true; } } }
public Boolean validarRegimen() { String query; if (!string.IsNullOrEmpty(textRegimen.Text)) { ConexionDB bd = new ConexionDB(); query = this.armarQuery(); DataTable resultado = bd.Select(query); if (resultado.Rows.Count > 0) { labelRegimen.Text = "Ya existe Este Regimen: " + textRegimen.Text; labelRegimen.ForeColor = System.Drawing.Color.Red; return(true); } return(false); } else { return(true); } }
public override bool Editar() { ConexionDB Conexion = new ConexionDB(); bool Retorno = false; try { Retorno = Conexion.Ejecutar(String.Format("Update Eventos set TipoEventoId={0}, NombreEvento='{1}', FechaEvento='{2}', LugarEvento='{3}', Imagen='{4}' where EventoId= {5}", this.TipoEventoId, this.NombreEvento, this.FechaEvento, this.LugarEvento, this.Imagen, this.EventoId)); if (Retorno) { Conexion.Ejecutar(String.Format("Delete from EventosDetalle Where EventoId= {0}", this.EventoId)); foreach (EventosDetalleClass var in this.Detalle) { Conexion.Ejecutar(string.Format("Insert into EventosDetalle(EventoId, DescTicket, CantDisponible, PrecioTicket) Values ({0},'{1}',{2},{3})", this.EventoId, var.DescTicket, var.CantDisponible, var.PrecioTicket)); } } } catch (Exception ex) { throw ex; } return(Retorno); }
public override bool Buscar(int IdBuscado) { bool retorno = false; DataTable dt = new DataTable(); ConexionDB Conexion = new ConexionDB(); try { dt = Conexion.ObtenerDatos(string.Format("select * from Paises where PaisId = {0} ", IdBuscado)); if (dt.Rows.Count > 0) { this.Descripcion = dt.Rows[0]["Descripcion"].ToString(); retorno = true; } } catch (Exception) { retorno = false; } return(retorno); }
public override bool Editar() { ConexionDB Conexion = new ConexionDB(); bool Retorno = false; try { Retorno = Conexion.Ejecutar(String.Format("Update Ventas set UsuarioId={0}, Fecha='{1}', Descripcion='{2}', Total={3} where VentaId= {4}", this.UsuarioId, this.Fecha, this.Descripcion, this.Total, this.VentaId)); if (Retorno) { Conexion.Ejecutar(String.Format("Delete from VentasDetalle Where VentaId= {0}", this.VentaId)); foreach (VentasDetalleClass var in this.Detalle) { Conexion.Ejecutar(string.Format("Insert into VentasDetalle(VentaId, EventoId, Ticket, Cantidad) Values ({0}, {1}, {2}, {3})", this.VentaId, var.EventoId, var.Ticket, var.Cantidad)); } } } catch (Exception ex) { throw ex; } return(Retorno); }
public Boolean validarEmailUnico() { String query; if (!string.IsNullOrEmpty(txtCliente_NroID.Text) && !string.IsNullOrEmpty(cmbCliente_TipoID.Text)) { ConexionDB bd = new ConexionDB(); query = this.armarQuery(); DataTable resultado = bd.Select(query); if (resultado.Rows.Count > 0) { labelID.Text = "Ya existe un Cliente Tipo de id: " + cmbCliente_TipoID.Text + " y Número de identificación: " + txtCliente_NroID.Text; labelID.ForeColor = System.Drawing.Color.Red; return(true); } return(false); } else { return(true); } }
public override bool Buscar(int IdBuscado) { ConexionDB Conexion = new ConexionDB(); DataTable dt = new DataTable(); try { dt = Conexion.ObtenerDatos("Select * from Usuarios Where UsuarioId=" + IdBuscado); if (dt.Rows.Count > 0) { this.UsuarioId = (int)dt.Rows[0]["UsuarioId"]; this.Nombres = dt.Rows[0]["Nombres"].ToString(); this.Apellidos = dt.Rows[0]["Apellidos"].ToString(); this.Telefono = dt.Rows[0]["Telefono"].ToString(); this.Email = dt.Rows[0]["Email"].ToString(); this.Direccion = dt.Rows[0]["Direccion"].ToString(); this.NombreUsuario = dt.Rows[0]["NombreUsuario"].ToString(); this.Contrasenia = dt.Rows[0]["Contrasenia"].ToString(); } } catch (Exception ex) { throw ex; } return(dt.Rows.Count > 0); }
public Persona extraerSolicitante(String cedua) { SqlConnection cnn = new SqlConnection(); ConexionDB c = new ConexionDB(); cnn = c.conectar; SqlDataReader read; query = "SELECT p.IDPERSONA,p.CI_PER,p.NOMBREPERSONA,p.APELLIDOPERSONA,p.CORREOPERSONA,p.TELEFONOPERSONA FROM CATALOGOESTUDIANTE ca, PERSONA p WHERE ca.IDPERSONA NOT IN (SELECT IDPERSONA FROM ESTUDIANTE) AND ca.IDPERSONA NOT IN (SELECT IDPERSONA FROM SOLICITUD) AND p.IDPERSONA=ca.IDPERSONA AND p.CI_PER='" + cedua + "'"; SqlCommand cmd = new SqlCommand(query, cnn); using (cmd) { read = cmd.ExecuteReader(); while (read.Read()) { Persona pro = new Persona(Convert.ToInt16(read[0]), Convert.ToString(read[1]), Convert.ToString(read[2]), Convert.ToString(read[3]), Convert.ToString(read[4]), Convert.ToString(read[5])); return(pro); } } return(null); }
public void ComprarProducto(int Precio, int Cantidad, string Nombre_cliente, string Nombre_productos) { try { //Conexiones -- Capa Dominio ConexionDB CDB = new ConexionDB(); CDB.conexiones(); conexion.Open(); //Clases -- Capa Dominio Cliente cliente = new Cliente(Nombre_cliente); Productos productos = new Productos(Nombre_productos, Cantidad); ; //Precio Total int Total = Precio * Cantidad; //Ingresar datos a la Base de datos string InsertarC = "Insert into Compra (Nombre_Cliente ,Nombre_Producto ,Cantidad ,Precio, Total) Values(@NombreC,@NombreP, @cantidad, @precio, @total)"; SqlCommand CMD4 = new SqlCommand(InsertarC, conexion); CMD4.Parameters.AddWithValue("@NombreC", cliente.Nombre); CMD4.Parameters.AddWithValue("@NombreP", productos.Nombre); CMD4.Parameters.AddWithValue("@cantidad", productos.Cantidad); CMD4.Parameters.AddWithValue("@precio", Precio); CMD4.Parameters.AddWithValue("@total", Total); CMD4.ExecuteNonQuery(); MessageBox.Show("Compra realizda con exito"); } catch (Exception TiposdeDatosErroneos) { MessageBox.Show($"{TiposdeDatosErroneos}\n\nComplete los campos de forma correcta"); } finally { conexion.Close(); } }
private void ActulizarResultados() { SQLParametros parametros = new SQLParametros(); parametros.add("@dni", textBoxDni.Text); if (comboBoxEmpresa.SelectedValue == null) { comboBoxEmpresa.Text = ""; parametros.add("@id_empresa", comboBoxEmpresa.Text); } else { parametros.add("@id_empresa", comboBoxEmpresa.SelectedValue.ToString()); } parametros.add("@nroFactura", textBoxNroFactura.Text); DataTable facturasEncontradas; if (ConexionDB.Procedure("buscarFactura", parametros.get(), out facturasEncontradas)) { dataGridViewBuscarFactura.DataSource = facturasEncontradas; dataGridViewBuscarFactura.Columns[0].Visible = false; dataGridViewBuscarFactura.Columns[1].Visible = false; dataGridViewBuscarFactura.Columns[2].Visible = false; } dataGridViewBuscarFactura.AutoResizeColumns(); dataGridViewBuscarFactura.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridViewBuscarFactura.RowHeadersVisible = false; dataGridViewBuscarFactura.AllowUserToAddRows = false; comboBoxEmpresa.SelectedIndex = -1; }
private void dataGridViewRoles_CellMouseClick(object sender, DataGridViewCellEventArgs e) { String LinkLabel = ""; LinkLabel = dataGridViewRoles.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); if (e.RowIndex != -1) { if (LinkLabel.Equals("Dar Baja")) { string rol = dataGridViewRoles.Rows[e.RowIndex].Cells["ColumnRol"].Value.ToString(); DialogResult dialogResult = MessageBox.Show(String.Format("Se eliminará el rol: {0}. Confirma?", rol), "Atento", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { string update = String.Format("UPDATE [AVENGERS].[ROL] SET [ID_ESTADO] = 2 WHERE [NOMBRE] = '{0}'", rol); ConexionDB dbUp = new ConexionDB(); string resultadoUp = dbUp.InsertUpdateDelete(update); if (resultadoUp == "OK") { MessageBox.Show(String.Format("Se eliminó el rol: ", rol)); } } else if (dialogResult == DialogResult.No) { } } if (LinkLabel.Equals("Modificar")) { string nombreRol = dataGridViewRoles.Rows[e.RowIndex].Cells["ColumnRol"].Value.ToString(); Rol rol = new Rol(nombreRol); AbmRol.Modificar modificarRol = new Modificar(rol); modificarRol.Show(); } } }
public Boolean EditarUsuario(string userName, string password, DateTime fechaIngreso, string tipoUsuario, Equipo equipo, Persona persona, int psdUsuarioId) { ConexionDB conexion = new ConexionDB(); bool resultado = true; string strUpdate = string.Empty; try { strUpdate = " UPDATE PSD_USUARIO " + " SET USERNAME = @P_USERNAME, " + " FECHA_INGRESO = @P_FECHA_INGRESO, " + " TIPO_USUARIO_CODIGO_ID = @P_TIPO_USUARIO_CODIGO_ID, " + " PSD_EQUIPO_ID = @P_PSD_EQUIPO_ID, " + " PSD_PERSONA_ID = @P_PSD_PERSONA_ID, " + " WHERE PSD_USUARIO_ID = @P_PSD_USUARIO_ID "; Utils utils = new Utils(); utils.LimpiarSqlParameterCollection(); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_USERNAME", userName)); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_PASSWORD", password)); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_FECHA_INGRESO", fechaIngreso)); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_TIPO_USUARIO_CODIGO_ID", tipoUsuario)); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_PSD_EQUIPO_ID", equipo.Id)); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_PSD_PERSONA_ID", persona.Id)); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_PSD_USUARIO_ID", psdUsuarioId)); conexion.setDatosBD(strUpdate, utils.ParameterCollection); } catch (Exception) { throw; } return(resultado); }
private void buttonGuardar_Click(object sender, EventArgs e) { if (validar()) { string listaItems = ""; string aux = ""; SQLParametros parametros = new SQLParametros(); foreach (DataGridViewRow r in dataGridViewItems.Rows) { if (r.Cells["Nombre"].Value.ToString() == "") { aux = "empty"; } else { aux = r.Cells["Nombre"].Value.ToString(); } listaItems = listaItems + aux + "*" + r.Cells["Monto"].Value + "*" + r.Cells["Cantidad"].Value + "*"; } parametros.add("@dni", Convert.ToDecimal(textBoxDni.Text)); parametros.add("@id_empresa", comboBoxEmpresa.SelectedValue); parametros.add("@nroFactura", Convert.ToDecimal(textBoxNroFactura.Text)); parametros.add("@fechaAlta", dateTimePickerFechaAlta.Value); parametros.add("@fechaVto", dateTimePickerFechaVto.Value); parametros.add("@listaItems", listaItems); parametros.add("@estado", checkBoxEstado.Text); parametros.add("@total", Convert.ToDecimal(textBoxTotal.Text)); if (ConexionDB.Procedure("modificarFactura", parametros.get())) { MessageBox.Show("La factura " + textBoxNroFactura.Text + " se ha modificado"); } } }
//public bool RegistraCliente(MaestroClientes model) //{ // DataICDigitalDataContext db = new DataICDigitalDataContext(); // db.MaestroClientes.InsertOnSubmit(model); // db.SubmitChanges(); // return true; //} public DataSet Select_ListadoDocumentos() { ConexionDB Conn = new ConexionDB(); DataSet ObjDsListaClient = new DataSet(); SqlConnection ObjConexion = new SqlConnection(Conn.ObtenerConexion_PrestamosCompactoWEB()); SqlDataAdapter daListaClient = default(SqlDataAdapter); ObjConexion.Open(); SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = ObjConexion; SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.CommandText = "spConsultaTipoDocumento"; daListaClient = new SqlDataAdapter(SqlCmd); daListaClient.Fill(ObjDsListaClient, "Select_ListadoDocumentos"); ObjConexion.Close(); return(ObjDsListaClient); }
public List <string> Consultar_Campos(string StoreProcedure, SqlParameter[] Parametros) { List <string> Lista = new List <string>(); objconexion = Conexion.OpenConexion(); cmd = new SqlCommand(StoreProcedure, objconexion); cmd.CommandType = CommandType.StoredProcedure; foreach (var item in Parametros) { cmd.Parameters.Add(item).Value = item.Value; } SqlDataReader Reader; Reader = cmd.ExecuteReader(); while (Reader.Read()) { string campo = Reader["NombreCampo"].ToString(); Lista.Add(campo); } ConexionDB.CloseConexion(cmd); return(Lista); }
public List <Actividad> extraerActividades(int idEstudiante) { List <Actividad> retorno = new List <Actividad>(); SqlConnection cnn = new SqlConnection(); ConexionDB c = new ConexionDB(); cnn = c.conectar; SqlDataReader read; String query = "SELECT * FROM ACTIVIDAD WHERE IDPERSONA =" + idEstudiante + ""; SqlCommand cmd = new SqlCommand(query, cnn); using (cmd) { read = cmd.ExecuteReader(); while (read.Read()) { Actividad enviar = new Actividad(Convert.ToInt16(read[0]), Convert.ToInt16(read[1]), Convert.ToInt16(read[2]), Convert.ToString(read[3]), Convert.ToInt16(read[4]), Convert.ToString(read[5])); retorno.Add(enviar); } } return(retorno); }
private void ActulizarResultados() { SQLParametros parametros = new SQLParametros(); parametros.add("@nombre", textBoxNombre.Text); parametros.add("@cuit", textBoxApellido.Text); if (comboBoxRubro.SelectedValue == null) { comboBoxRubro.Text = ""; parametros.add("@id_rubro", comboBoxRubro.Text); } else { parametros.add("@id_rubro", comboBoxRubro.SelectedValue.ToString()); } DataTable empresasEncontradas; if (ConexionDB.Procedure("buscarEmpresa", parametros.get(), out empresasEncontradas)) { dataGridViewBuscarEmpresa.DataSource = empresasEncontradas; dataGridViewBuscarEmpresa.Columns[0].Visible = false; dataGridViewBuscarEmpresa.Columns[1].Visible = false; } dataGridViewBuscarEmpresa.AutoResizeColumns(); dataGridViewBuscarEmpresa.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridViewBuscarEmpresa.RowHeadersVisible = false; dataGridViewBuscarEmpresa.AllowUserToAddRows = false; comboBoxRubro.SelectedIndex = -1; }
public List <Persona> extraerMaestrosDisponibles() { List <Persona> retorno = new List <Persona>(); SqlConnection cnn = new SqlConnection(); ConexionDB c = new ConexionDB(); cnn = c.conectar; SqlDataReader read; query = " SELECT P.IDPERSONA,P.CI_PER,P.NOMBREPERSONA,P.APELLIDOPERSONA,P.CORREOPERSONA,P.TELEFONOPERSONA FROM CATALOGOPROFESOR ca, PERSONA p WHERE ca.IDPERSONA NOT IN(SELECT IDPERSONA FROM MAESTRO) AND ca.IDPERSONA=p.IDPERSONA;"; SqlCommand cmd = new SqlCommand(query, cnn); using (cmd) { read = cmd.ExecuteReader(); while (read.Read()) { Persona pro = new Persona(Convert.ToInt16(read[0]), Convert.ToString(read[1]), Convert.ToString(read[2]), Convert.ToString(read[3]), Convert.ToString(read[4]), Convert.ToString(read[5])); retorno.Add(pro); } } return(retorno); }
public string ObtenerTipoUsuario(string userName) { ConexionDB conexion = new ConexionDB(); Utils utils = new Utils(); string resultado = string.Empty; string strSelect = string.Empty; try { strSelect = " SELECT TIPO_USUARIO FROM PSD_USUARIO WHERE USERNAME = @P_USERNAME"; utils.LimpiarSqlParameterCollection(); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@P_USERNAME", userName)); resultado = (conexion.getDatosBD(strSelect, utils.ParameterCollection).Rows[0][0].ToString()); } catch (Exception e) { Console.WriteLine(e.Message); } return(resultado); }
public List <Proyecto> extraerProyecto() { SqlConnection cnn; ConexionDB c = new ConexionDB(); string query; cnn = c.conectar; List <Proyecto> retorno = new List <Proyecto>(); using (cnn) { query = "SELECT * FROM PROYECTO"; SqlCommand cmd = new SqlCommand(query, cnn); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { Proyecto pro = new Proyecto(Convert.ToInt32(read[0]), Convert.ToString(read[1]), Convert.ToDateTime(read[2]), Convert.ToString(read[3]), Convert.ToInt16(read[4]), Convert.ToDateTime(read[5]), Convert.ToInt16(read[6]), Convert.ToString(read[7])); retorno.Add(pro); } } return(retorno); }
public Proyecto nomProyecto(int idProyecto) { SqlConnection cnn; ConexionDB c = new ConexionDB(); string query; cnn = c.conectar; Proyecto retornor = new Proyecto(); using (cnn) { query = "SELECT * FROM PROYECTO WHERE IDPROYECTO=" + idProyecto + ""; SqlCommand cmd = new SqlCommand(query, cnn); SqlDataReader read = cmd.ExecuteReader(); if (read.Read()) { Proyecto pro = new Proyecto(Convert.ToInt32(read[0]), Convert.ToString(read[1]), Convert.ToDateTime(read[2]), Convert.ToString(read[3]), Convert.ToInt16(read[4]), Convert.ToDateTime(read[5]), Convert.ToInt16(read[6]), Convert.ToString(read[7])); return(pro); } return(null); } }
private void ActulizarResultados() { SQLParametros parametros = new SQLParametros(); parametros.add("@nombre", textBoxNombre.Text); parametros.add("@apellido", textBoxApellido.Text); parametros.add("@dni", textBoxDni.Text); DataTable clientesEncontrados; if (ConexionDB.Procedure("buscarCliente", parametros.get(), out clientesEncontrados)) { dataGridViewBuscarCliente.DataSource = clientesEncontrados; dataGridViewBuscarCliente.Columns[0].Visible = false; } dataGridViewBuscarCliente.AutoResizeColumns(); dataGridViewBuscarCliente.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridViewBuscarCliente.RowHeadersVisible = false; dataGridViewBuscarCliente.AllowUserToAddRows = false; }
public LoginRolHotel() { InitializeComponent(); ConexionDB bd = new ConexionDB(); DataTable resultadoRoles = bd.Select(consultaRoles); if (resultadoRoles != null) { comboBoxRoles.ValueMember = resultadoRoles.Columns["ID_ROL"].ToString(); comboBoxRoles.DisplayMember = resultadoRoles.Columns["NOMBREROL"].ToString(); comboBoxRoles.DataSource = resultadoRoles; } ConexionDB bdHotel = new ConexionDB(); DataTable resultadoHoteles = bdHotel.Select(consultaHoteles); if (resultadoHoteles != null) { comboBoxHoteles.ValueMember = resultadoHoteles.Columns["ID_HOTEL"].ToString(); comboBoxHoteles.DisplayMember = resultadoHoteles.Columns["NOMBREHOTEL"].ToString(); comboBoxHoteles.DataSource = resultadoHoteles; } }
public Boolean EliminarUsuario(int psdUsuarioId) { ConexionDB conexion = new ConexionDB(); bool resultado = true; string strDelete = string.Empty; try { strDelete = " DELETE FROM PSD_USUARIO WHERE PSD_USUARIO_ID = @PSD_USUARIO_ID "; Utils utils = new Utils(); utils.LimpiarSqlParameterCollection(); utils.ParameterCollection.Add(new System.Data.SqlClient.SqlParameter("@PSD_USUARIO_ID", psdUsuarioId)); conexion.setDatosBD(strDelete, utils.ParameterCollection); } catch (Exception) { throw; } return(resultado); }
public bool Eliminar(string matricula) { ConexionDB cdb = new ConexionDB(); string sql = "DELETE Estudiantes WHERE Matricula =" + matricula; return cdb.EjecutarComando(sql); }
public DataTable getEstudiantes() { ConexionDB cdb = new ConexionDB(); string sql = "SELECT Matricula, Nombres, Apellidos From Estudiantes"; return cdb.getData(sql); }