public ActionResult Create(tb_bit_usuario tb_bit_usuario)
        {
            if (ModelState.IsValid)
            {
                tb_bit_usuario.fec_alta = DateTime.Now;
                db.tb_bit_usuario.Add(tb_bit_usuario);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.fk_cve_area = new SelectList(db.tb_bit_cat_area, "pk_cve_area", "des_area", tb_bit_usuario.fk_cve_area);
            ViewBag.fk_cve_dga = new SelectList(db.tb_bit_cat_dga, "pk_cve_dga", "des_dga", tb_bit_usuario.fk_cve_dga);
            ViewBag.fk_cve_empresa = new SelectList(db.tb_bit_cat_empresa, "pk_cve_empresa", "des_empresa", tb_bit_usuario.fk_cve_empresa);
            ViewBag.fk_cve_piso = new SelectList(db.tb_bit_cat_piso, "pk_cve_piso", "des_piso", tb_bit_usuario.fk_cve_piso);
            ViewBag.fk_cve_regional = new SelectList(db.tb_bit_cat_regional, "pk_cve_regional", "des_regional", tb_bit_usuario.fk_cve_regional);
            return View(tb_bit_usuario);
        }
        private tb_bit_usuario_historico CreateHistorico(tb_bit_usuario tb_bit_usuario)
        {
            return new tb_bit_usuario_historico
            {
                ape_materno = tb_bit_usuario.ape_materno,
                ape_paterno = tb_bit_usuario.ape_paterno,
                cve_usuario = tb_bit_usuario.pk_cve_usuario,
                des_observacion = tb_bit_usuario.des_observacion,
                fk_cve_area = tb_bit_usuario.fk_cve_area,
                fk_cve_dga = tb_bit_usuario.fk_cve_dga,
                fk_cve_empresa = tb_bit_usuario.fk_cve_empresa,
                fk_cve_piso = tb_bit_usuario.fk_cve_piso,
                fk_cve_regional = tb_bit_usuario.fk_cve_regional,
                nom_user_name = tb_bit_usuario.nom_user_name,
                nom_usuario = tb_bit_usuario.nom_usuario,
                fecha_cambio = DateTime.Now

            };
        }
 public ActionResult Edit(tb_bit_usuario tb_bit_usuario)
 {
     if (ModelState.IsValid)
     {
         using (TransactionScope ts = new TransactionScope())
         {
             var historico = CreateHistorico((tb_bit_usuario)this.ControllerContext.HttpContext.Session["usuario_hist"]);
             db.tb_bit_usuario_historico.Add(historico);
             db.Entry(tb_bit_usuario).State = EntityState.Modified;
             db.SaveChanges();
             ts.Complete();
         }
         return RedirectToAction("Index");
     }
     ViewBag.fk_cve_area = new SelectList(db.tb_bit_cat_area, "pk_cve_area", "des_area", tb_bit_usuario.fk_cve_area);
     ViewBag.fk_cve_dga = new SelectList(db.tb_bit_cat_dga, "pk_cve_dga", "des_dga", tb_bit_usuario.fk_cve_dga);
     ViewBag.fk_cve_empresa = new SelectList(db.tb_bit_cat_empresa, "pk_cve_empresa", "des_empresa", tb_bit_usuario.fk_cve_empresa);
     ViewBag.fk_cve_piso = new SelectList(db.tb_bit_cat_piso, "pk_cve_piso", "des_piso", tb_bit_usuario.fk_cve_piso);
     ViewBag.fk_cve_regional = new SelectList(db.tb_bit_cat_regional, "pk_cve_regional", "des_regional", tb_bit_usuario.fk_cve_regional);
     return View(tb_bit_usuario);
 }