public bool actualizarCurso(ClCurso cur, string codigo) { ISession mySesions = SessionFactory.OpenSession; bool resp = false; using (mySesions) { using (ITransaction transaction = mySesions.BeginTransaction()) { try { IQuery query = mySesions.CreateQuery("FROM ClCurso WHERE CodCurso=: codigo").SetString("codigo", codigo); ClCurso clcur = query.List <ClCurso>()[0]; clcur.DescCurso = cur.DescCurso; clcur.CodCurso = cur.CodCurso; clcur.FechaCreacionCurso = cur.FechaCreacionCurso; mySesions.Update(clcur); transaction.Commit(); resp = true; return(resp); } catch (Exception ex) { throw ex; } finally { mySesions.Flush(); } } } }
protected async void Button1_Click(object sender, EventArgs e) { #region Insertar Curso DateTime fecha = DateTime.Now; ClCurso curso = new ClCurso(); curso.CodCurso = txtCodCurso.Text; curso.DescCurso = txtDescCurso.Text; curso.FechaCreacionCurso = Convert.ToString(fecha); string uri = "api/Curso"; var myContent = JsonConvert.SerializeObject(curso); 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 procesar la solicitud'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } limpiarCampos(); #endregion }
//Insertar un Curso public void InsertarCurso(ClCurso cur) { ISession mySesions = SessionFactory.OpenSession; using (mySesions) { using (ITransaction transaction = mySesions.BeginTransaction()) { try { mySesions.Save(cur); transaction.Commit(); } catch (Exception ex) { throw ex; } finally { mySesions.Flush(); } } } }
public bool UpdateCurso(ClCurso insA, string codigo)//actualizar curso { return(serv.actualizarCurso(insA, codigo)); }
public void PostinsertarCurso(ClCurso cur)//insertar un curso { serv.InsertarCurso(cur); }