protected void BtnSave_Click(object sender, EventArgs e) { try { var dbr = new PetCheckDBEntities(); var date = DateTime.Parse(TxtRDate.Text); var time = TimeSpan.Parse(TxtRTime.Text); DateTime CDateTime = date + time; dbr.Cita.Add(new Cita() { Doctor = int.Parse(cmbRDoc.SelectedValue), Mascota = int.Parse(cmbRPet.SelectedValue), Servicio = int.Parse(cmbRServ.SelectedValue), Fecha = CDateTime }); dbr.SaveChanges(); Response.Redirect("~/Views/Agenda.aspx?Er=1"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Agenda.aspx?Er=2"); } }
protected void BtnEdit_Click(object sender, EventArgs e) { try { var i = int.Parse(Request.QueryString["Edit"]); Edit = db.Servicio.First(st => st.idServicio == i); Edit.Nombre = TxtEName.Text; Edit.Precio = int.Parse(TxtEPrice.Text); Edit.Descripcion = TxtEDescription.Text; db.SaveChanges(); Response.Redirect("~/Views/Servicios.aspx?Er=0"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Servicios.aspx?Er=2"); } }
protected void BtnEdit_Click(object sender, EventArgs e) { try { var i = int.Parse(Request.QueryString["Edit"]); Edit = db.Usuario.First(st => st.idUsuario == i); Edit.Nombre = TxtEName.Text; Edit.Telefono = int.Parse(TxtEPhone.Text); Edit.Direccion = TxtEAddress.Text; db.SaveChanges(); Response.Redirect("~/Views/Clientes.aspx?Er=0"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Clientes.aspx?Er=2"); } }
protected void BtnSave_Click(object sender, EventArgs e) { try { var dbr = new PetCheckDBEntities(); dbr.Usuario.Add(new Usuario() { Nombre = TxtRName.Text, Telefono = int.Parse(TxtRPhone.Text), Direccion = TxtRAddress.Text }); dbr.SaveChanges(); Response.Redirect("~/Views/Clientes.aspx?Er=1"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Clientes.aspx?Er=2"); } }
protected void BtnSave_Click(object sender, EventArgs e) { try { var dbr = new PetCheckDBEntities(); dbr.Servicio.Add(new Servicio() { Nombre = TxtRName.Text, Precio = int.Parse(TxtRPrice.Text), Descripcion = TxtRDescription.Text, Clinica = 1 }); dbr.SaveChanges(); Response.Redirect("~/Views/Servicios.aspx?Er=1"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Servicios.aspx?Er=2"); } }
protected void BtnEdit_Click(object sender, EventArgs e) { try { var i = int.Parse(Request.QueryString["Edit"]); Edit = db.Mascota.First(st => st.idMascota == i); Edit.Nombre = TxtEName.Text; Edit.Genero = CmbEGender.Text; Edit.Especie = TxtESpecies.Text; Edit.Raza = TxtERace.Text; Edit.Estatura = double.Parse(TxtETall.Text); Edit.Peso = double.Parse(TxtEWeight.Text); Edit.Fecha_Nacimiento = DateTime.Parse(TxtEDate.Text); db.SaveChanges(); Response.Redirect("~/Views/Mascotas.aspx?Er=0"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Mascotas.aspx?Er=2"); } }
protected void BtnCreate_Click(object sender, EventArgs e) { try { var dbr = new PetCheckDBEntities(); dbr.Usuario.Add(new Usuario() { Nombre = TxtRName.Text, Contraseña = Encrypter.ToHash(TxtRPws.Text), Alias = TxtRUser.Text, Tipo = false }); dbr.SaveChanges(); Response.Redirect("~/Views/Usuarios.aspx?Er=1"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Usuarios.aspx?Er=2"); } }
protected void BtnEdit_Click(object sender, EventArgs e) { try { var i = int.Parse(Request.QueryString["Edit"]); Edit = db.Usuario.First(st => st.idUsuario == i); Edit.Alias = TxtEUser.Text; Edit.Nombre = TxtEName.Text; if (main.Tipo == true || main.Alias == Edit.Alias) { Edit.Contraseña = Encrypter.ToHash(TxtEPwd.Text); } _ = CmbEType.SelectedIndex == 0 ? Edit.Tipo = true : Edit.Tipo = false; db.SaveChanges(); Response.Redirect("~/Views/Usuarios.aspx?Er=0"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Usuarios.aspx?Er=2"); } }
protected void BtnSave_Click(object sender, EventArgs e) { try { var dbr = new PetCheckDBEntities(); dbr.Mascota.Add(new Mascota() { Nombre = TxtRName.Text, Genero = CmbRGender.Text, Raza = TxtRRace.Text, Especie = TxtRSpecies.Text, Estatura = double.Parse(TxtRTall.Text), Peso = double.Parse(TxtRWeight.Text), Fecha_Nacimiento = DateTime.Parse(TxtRDate.Text) }); dbr.SaveChanges(); Response.Redirect("~/Views/Mascotas.aspx?Er=1"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Mascotas.aspx?Er=2"); } }
protected void BtnRegisterCita_Click(object sender, EventArgs e) { try { var dbr = new PetCheckDBEntities(); var id = int.Parse(Request.QueryString["Cita"]); var C = db.Cita.Where(st => st.idCita == id).First(); dbr.Consulta.Add(new Consulta() { Doctor = C.Doctor, Mascota = C.Mascota, Servicio = C.Servicio, Fecha = C.Fecha, Diagnostico = TxtCRDiag.Text }); dbr.SaveChanges(); Response.Redirect("~/Views/Consultas.aspx?Er=1"); } catch (DbEntityValidationException) { Response.Redirect("~/Views/Consultas.aspx?Er=2"); } }