public async void ServicioInsertarNivelProgramado() { try { List <ClEstadoNivel> estado = new List <ClEstadoNivel>(); estado = await ServicioGetEstadoNivel(); DateTime fecha = DateTime.Now; ClNivel nivel = new ClNivel(); int activo = 0; var active = estado.Where(a => a.IdEstadoNivel == 1).Select(a => a.IdEstadoNivel).FirstOrDefault(); var inactive = estado.Where(a => a.IdEstadoNivel == 2).Select(a => a.IdEstadoNivel).FirstOrDefault(); if (RabActivo.Checked == true) { activo = Convert.ToInt32(active); } else { activo = Convert.ToInt32(inactive); } nivel.idEstadoNivel = activo; nivel.idTipoNivel = null; nivel.idCurso = Convert.ToInt32(cbxCursos.SelectedValue.ToString()); nivel.descNivel = ddlNivel.SelectedValue.ToString(); nivel.codNivel = txtcodNivel.Text.ToUpper(); nivel.nomNivel = txtNomNivel.Text.ToUpper(); string uri = "api/Niveles"; var myContent = JsonConvert.SerializeObject(nivel); var stringContent = new StringContent(myContent, UnicodeEncoding.UTF8, "application/json"); var client = new HttpClient(); client.BaseAddress = new Uri(url); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/jason")); HttpResponseMessage res = await client.PostAsync(uri, stringContent); if (res.IsSuccessStatusCode) { var empResponse = res.Content.ReadAsStringAsync().Result; string script = @"<script type='text/javascript'> alert('Añadido Correctamente'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } else { string script = @"<script type='text/javascript'> alert('No se pudo guardar'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } } catch (Exception ex) { throw ex; } }
protected void btnActualizar_Click(object sender, EventArgs e) { ClNivel nivel = new ClNivel(); nivel.idNivel = Convert.ToInt64(txtIdNivel.Text); nivel.idEstadoNivel = Convert.ToInt64(cbxEstadoNivel.SelectedValue.ToString()); nivel.idLibro = Convert.ToInt64(cbxLibros.SelectedValue.ToString()); nivel.idCurso = Convert.ToInt64(cbxCursos.SelectedValue.ToString()); nivel.codNivel = txtCodNivel.Text.ToUpper().Trim(); nivel.nomNivel = txtNomNivel.Text.ToUpper().Trim(); nivel.descNivel = cbxNivel.SelectedValue.ToString(); nivel.idTipoNivel = Convert.ToInt64(idTipoNivel.Value); nivel.costoNIvel = Convert.ToDouble(txtCostoNivel.Text); ServicioActualizarNivel(nivel); }
//Insertar un nivel public void InsertarNivel(ClNivel nivel) { ISession mySesions = SessionFactory.OpenSession; using (mySesions) { using (ITransaction transaction = mySesions.BeginTransaction()) { try { mySesions.Save(nivel); transaction.Commit(); } catch (Exception ex) { throw ex; } } } }
public bool actualizarNivel(ClNivel cniv, long idNivel) { ISession mySesions = SessionFactory.OpenSession; bool resp = false; using (mySesions) { using (ITransaction transaction = mySesions.BeginTransaction()) { try { IQuery query = mySesions.CreateQuery("from ClNivel WHERE idNivel=: idNivel").SetInt64("idNivel", idNivel); ClNivel niv = query.List <ClNivel>()[0]; niv.idEstadoNivel = cniv.idEstadoNivel; niv.idTipoNivel = cniv.idTipoNivel; niv.idLibro = cniv.idLibro; niv.idCurso = cniv.idCurso; niv.codNivel = cniv.codNivel; niv.nomNivel = cniv.nomNivel; niv.descNivel = cniv.descNivel; niv.costoNIvel = cniv.costoNIvel; mySesions.Update(niv); transaction.Commit(); resp = true; return(resp); } catch (Exception ex) { throw ex; } finally { mySesions.Flush(); } } } }
public async void ServicioActualizarNivel(ClNivel nivel) { try { string uri = "api/Niveles?idnivel=" + nivel.idNivel; var myContent = JsonConvert.SerializeObject(nivel); var stringContent = new StringContent(myContent, UnicodeEncoding.UTF8, "application/json"); var client = new HttpClient(); client.BaseAddress = new Uri(url); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/jason")); HttpResponseMessage res = await client.PutAsync(uri, stringContent); if (res.IsSuccessStatusCode) { var empResponse = res.Content.ReadAsStringAsync().Result; cargarGridNiveles(); } } catch (Exception ex) { throw ex; } }
public async void ServicioInsertarNivel() { try { List <ClEstadoNivel> estado = new List <ClEstadoNivel>(); estado = await ServicioGetEstadoNivel(); DateTime fecha = DateTime.Now; ClNivel nivel = new ClNivel(); long idNivel; ClNivelesProgramado nivelpro = new ClNivelesProgramado(); ClNivelesAutonomos nivelAuto = new ClNivelesAutonomos(); int activo = 0; var active = estado.Where(a => a.IdEstadoNivel == 1).Select(a => a.IdEstadoNivel).FirstOrDefault(); var inactive = estado.Where(a => a.IdEstadoNivel == 2).Select(a => a.IdEstadoNivel).FirstOrDefault(); if (RabActivo.Checked == true) { activo = Convert.ToInt32(active); } else { activo = Convert.ToInt32(inactive); } nivel.idEstadoNivel = activo; if (Convert.ToInt64(ddlLibros.SelectedValue.ToString()) != 0) { nivel.idLibro = Convert.ToInt64(ddlLibros.SelectedValue.ToString()); } else { nivel.idLibro = null; } if (Convert.ToInt64(cbxTipoNivel.SelectedValue.ToString()) != 0) { nivel.idTipoNivel = Convert.ToInt64(cbxTipoNivel.SelectedValue.ToString()); } else { nivel.idTipoNivel = null; } nivel.idCurso = Convert.ToInt32(cbxCursos.SelectedValue.ToString()); nivel.descNivel = ddlNivel.SelectedValue.ToString(); nivel.codNivel = txtcodNivel.Text.ToUpper(); nivel.nomNivel = txtNomNivel.Text.ToUpper(); nivel.costoNIvel = Convert.ToDouble(txtCostoNivel.Text); string uri = "api/Niveles"; var myContent = JsonConvert.SerializeObject(nivel); var stringContent = new StringContent(myContent, UnicodeEncoding.UTF8, "application/json"); var client = new HttpClient(); client.BaseAddress = new Uri(url); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/jason")); HttpResponseMessage res = await client.PostAsync(uri, stringContent); if (res.IsSuccessStatusCode) { var empResponse = res.Content.ReadAsStringAsync().Result; //Invocar servicio extraer ultimo id List <ClNivel> niveles = new List <ClNivel>(); niveles = await ServicioGetNiveles(); var id = niveles.OrderByDescending(x => x.idNivel).Select(x => x.idNivel).FirstOrDefault(); //Guardar Nivel Programado idNivel = Convert.ToInt64(id); if (Convert.ToInt32(cbxTipoNivel.SelectedValue.ToString()) == 1) { nivelpro.idNivel = idNivel; ServicioInsertarNivelProgramado(nivelpro); string script = "confirm();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "script", script, true); }//guardar nivel autonomo else if (Convert.ToInt32(cbxTipoNivel.SelectedValue.ToString()) == 2) { nivelAuto.idNivel = idNivel; ServicioInsertarNivelAutonomo(nivelAuto); string script = "confirm();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "script", script, true); } } else { string script = @"<script type='text/javascript'> alert('No se pudo guardar'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } limpiarCampos(); } catch (Exception ex) { throw ex; } }
public bool UpdateNivel(ClNivel insA, long idnivel)//actualizar nivel { return(serv.actualizarNivel(insA, idnivel)); }
public void PostinsertarNivel(ClNivel niv)//insertar un nivel { serv.InsertarNivel(niv); }