Beispiel #1
0
        public JsonResult GuardarLaboratorio(laboratorio laboratorio)
        {
            var respuesta = new ResponseModel
            {
                Respuesta = true, Redirect = "", Error = ""
            };

            if (ModelState.IsValid)
            {
                try
                {
                    laboratorio.estado = true;
                    db.laboratorio.Add(laboratorio);
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    VerificacionDuplicado verif = new VerificacionDuplicado();
                    bool rpta = verif.VerificarLaboratorio(laboratorio.nombre_laboratorio);
                    respuesta.Respuesta = false;
                    if (rpta)
                    {
                        respuesta.Error = "Ya existe un laboratorio con ese nombre";
                    }
                    else
                    {
                        respuesta.Error = "Hubo un problema al guardar";
                    }
                }
            }
            return(Json(respuesta));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "id_laboratorio,nombre_laboratorio,descripcion_laboratorio,estado")] laboratorio laboratorio)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    laboratorio.estado = true;
                    db.laboratorio.Add(laboratorio);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    VerificacionDuplicado verif = new VerificacionDuplicado();
                    bool rpta;
                    rpta = verif.VerificarLaboratorio(laboratorio.nombre_laboratorio);
                    if (rpta == true)
                    {
                        ModelState.AddModelError("errorLaboratorio", "Ya existe una Laboratorio con este nombre, agruegue uno diferente");
                    }
                    else
                    {
                        ModelState.AddModelError("errorLaboratorio", "Ocurrio un error al guadar");
                    }
                }
            }

            return(View(laboratorio));
        }
Beispiel #3
0
        public ActionResult Changestate(int id)
        {
            int ID      = id;
            var obtener = new laboratorio();

            try
            {
                obtener = db.laboratorio.Where(x => x.id_laboratorio == ID).SingleOrDefault();
                if (obtener != null)
                {
                    if (obtener.estado == true)
                    {
                        obtener.estado          = false;
                        db.Entry(obtener).State = EntityState.Modified;
                    }
                    else
                    {
                        obtener.estado          = true;
                        db.Entry(obtener).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                //throw;
            }

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public ActionResult Edit([Bind(Include = "id_laboratorio,nombre_laboratorio,descripcion_laboratorio,estado")] laboratorio laboratorio)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var model = db.laboratorio.Where(x => x.id_laboratorio == laboratorio.id_laboratorio).SingleOrDefault();
                    model.nombre_laboratorio      = laboratorio.nombre_laboratorio;
                    model.descripcion_laboratorio = laboratorio.descripcion_laboratorio;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    VerificacionDuplicado verif = new VerificacionDuplicado();
                    bool rpta;
                    rpta = verif.VerificarLaboratorio(laboratorio.nombre_laboratorio);
                    if (rpta == true)
                    {
                        ModelState.AddModelError("errorLaboratorio", "Ya existe una Laboratorio con este nombre, agruegue uno diferente");
                    }
                    else
                    {
                        ModelState.AddModelError("errorLaboratorio", "Ocurrio un error al actualizar");
                    }
                }
            }
            return(View(laboratorio));
        }
Beispiel #5
0
 public void mostrarlab()
 {
     laboratorio c = new laboratorio();
     DataSet ds = new DataSet();
     ds = c.buscar();
     foreach (DataRow reg in ds.Tables[0].Rows)
         cbolab.Items.Add(reg[1].ToString().Trim());
 }
Beispiel #6
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            laboratorio c = new laboratorio();

            c.Codigo = int.Parse(txtcodigo.Text);
            c.eliminar();
            btnBuscar_Click(sender, new EventArgs());
        }
Beispiel #7
0
 public string retornar_id_lab(string s)
 {
     laboratorio c = new laboratorio();
     DataSet ds = new DataSet();
     ds = c.buscarPorNombre(cbolab.Text);
     DataRow reg = ds.Tables[0].Rows[0];
     string x = reg[0].ToString();
     return x;
 }
Beispiel #8
0
        private void Laboratorio_Update_Load(object sender, EventArgs e)
        {
            dataSalones();
            dataHorarios();
            dataCatedraticos();

            laboratorio Model = controladorLaboratorio.buscarLaboratorio(reference);

            Txt_nombre.Text = Model.descripcion_laboratorio.ToString();
        }
Beispiel #9
0
        // GET: Laboratorios/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            laboratorio laboratorio = db.laboratorio.Find(id);

            if (laboratorio == null)
            {
                return(HttpNotFound());
            }
            return(View(laboratorio));
        }
Beispiel #10
0
        //Metodo para guardar un nuevo laboratorio
        public void guardarlaboratorio(string nombre_laboratorio, int dpi_catedratico, int id_horario, int id_salon)
        {
            using (ModelAsignacion db = new ModelAsignacion())
            {
                laboratorio laboratorioNuevo = new laboratorio();

                laboratorioNuevo.descripcion_laboratorio     = nombre_laboratorio;
                laboratorioNuevo.CATEDRATICO_dpi_catedratico = dpi_catedratico;
                laboratorioNuevo.HORARIO_id_horario          = id_horario;
                laboratorioNuevo.SALON_id_salon = id_salon;

                db.laboratorio.Add(laboratorioNuevo);
                db.SaveChanges();
            }
        }
Beispiel #11
0
 public bool VerificarLaboratorio(string par)
 {
     using (Farmacia_FarmalivioEntities contex = new Farmacia_FarmalivioEntities())
     {
         var varCat = new laboratorio();
         varCat = contex.laboratorio.Where(x => x.nombre_laboratorio == par).SingleOrDefault();
         if (varCat != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Beispiel #12
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     if (radioButton.Checked)
     {
         laboratorio c  = new laboratorio();
         DataSet     ds = new DataSet();
         ds = c.buscarPorNombre(txtBuscar.Text);
         dglab.DataSource = ds;
         dglab.DataMember = "tc";
     }
     if (radioButton1.Checked)
     {
         laboratorio c  = new laboratorio();
         DataSet     ds = new DataSet();
         ds = c.buscarPorCodigo(txtBuscar.Text);
         dglab.DataSource = ds;
         dglab.DataMember = "tc";
     }
 }
Beispiel #13
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (verificarVacio())
     {
         MessageBox.Show("Registre un Laboratorio");
     }
     else
     {
         laboratorio c = new laboratorio();
         c.Nombre    = txtNombre.Text;
         c.Direccion = txtDireccion.Text;
         c.Telefono  = txtTelefono.Text;
         c.Email     = txtEmail.Text;
         c.Web       = txtWeb.Text;
         c.guardar();
         Limpiar();
         MessageBox.Show("Registro del Cliente Correctamente");
         btnBuscar_Click(sender, new EventArgs());
     }
 }
Beispiel #14
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (verificarVacio())
            {
                MessageBox.Show("No hay ningun Laboratorio a Modificar");
            }
            else
            {
                laboratorio c = new laboratorio();
                c.Codigo    = int.Parse(txtcodigo.Text);
                c.Nombre    = txtNombre.Text;
                c.Direccion = txtDireccion.Text;
                c.Telefono  = txtTelefono.Text;
                c.Email     = txtEmail.Text;
                c.modificar();

                MessageBox.Show("Modificacion Correcta");
                btnBuscar_Click(sender, new EventArgs());
            }
            Limpiar();
        }