public void insertarSector(EGalpones galpones) { DataTable Sector = new DataTable(); NpgsqlConnection conection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["Conexion2"].ConnectionString); try { NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("sectores.f_insertar_galpon", conection); dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; dataAdapter.SelectCommand.Parameters.Add("_nombre", NpgsqlDbType.Text).Value = galpones.Nombre; dataAdapter.SelectCommand.Parameters.Add("_propietario", NpgsqlDbType.Text).Value = galpones.Propietario; dataAdapter.SelectCommand.Parameters.Add("_direccion", NpgsqlDbType.Text).Value = galpones.Direccion; dataAdapter.SelectCommand.Parameters.Add("_telefono", NpgsqlDbType.Integer).Value = galpones.Telefono; conection.Open(); dataAdapter.Fill(Sector); } catch (Exception Ex) { throw Ex; } finally { if (conection != null) { conection.Close(); } } }
//////////////////////////////////insertar galpones////////////////////////////// public void insertarGalpones(EGalpones galpon) { using (var db = new Mapeo()) { db.galpon.Add(galpon); db.SaveChanges(); } }
protected void B_Guardar_Click(object sender, EventArgs e) { ClientScriptManager cm = this.ClientScript; EGalpones galpones = new EGalpones(); galpones.Nombre = TB_Nombre.Text; galpones.Propietario = TB_Propietario.Text; galpones.Direccion = TB_Direccion.Text; galpones.Telefono = int.Parse(TB_Telefono.Text); }
///////////////////////////////actualizar//////////////////////////////////////////// public void actualizarGalpones(EGalpones galpon) { using (var db = new Mapeo()) { EGalpones galpon2 = db.galpon.First(); galpon2.Nombre = galpon.Nombre; galpon2.Empleado = galpon.Empleado; galpon2.Direccion = galpon.Direccion; galpon2.Telefono = galpon.Telefono; galpon2.Num_ponedoras = galpon.Num_ponedoras; db.galpon.Attach(galpon2); var entry = db.Entry(galpon2); entry.State = EntityState.Modified; db.SaveChanges(); } }
protected void B_Guardar_Click(object sender, EventArgs e) { try { EGalpones galpon = new EGalpones(); galpon.Nombre = TB_Nombre.Text; galpon.Empleado = TB_Empleado.Text; galpon.Direccion = TB_Direccion.Text; galpon.Telefono = int.Parse(TB_Telefono.Text); galpon.Num_ponedoras = int.Parse(TB_NumPonedoras.Text); new DaoGalpones().insertarGalpones(galpon); Response.Redirect("CrearGalpon.aspx"); } catch (Exception ex) { { return; } } }