コード例 #1
0
 public ActionResult EditUser(Regi client)
 {
     if (ModelState.IsValid)
     {
         db.Entry(client).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("myAccount"));
     }
     return(View(client));
 }
コード例 #2
0
        public ActionResult Deletereg()
        {
            Regi re = db.reg.Find();

            if (re == null)
            {
                return(HttpNotFound());
            }
            return(View(re));
        }
コード例 #3
0
        public ActionResult UserInfo1(int id)
        {
            Regi rg = db.reg.Find(id);

            if (rg != null)
            {
                db.reg.Remove(rg);
                db.SaveChanges();
            }

            return(RedirectToAction("UserInfo"));
        }
コード例 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //lembrar de tratar os campos e duplicados
            //trate todos os erros aqui...

            if (!Page.IsValid)
            {
                LabelError.Visible = true;
                return;
            }

            using (var db = new DefaultConection())
            {
                Regi rg = new Regi
                {
                    cb = DropDownList1.SelectedValue,
                    cm = DropDownList2.SelectedValue,
                    cy = txtCarYear.Text,
                    m  = txtMilage.Text
                };
                db.Regis.Add(rg);
                db.SaveChanges();
                LabelSucesso.Visible = true;
                LabelSucesso.Text    = "Register Inserted";

                txtCarYear.Text             = "";
                txtMilage.Text              = "";
                DropDownList1.SelectedIndex = 0;
                DropDownList2.SelectedIndex = 0;
            }


            #region Apagar este Parte do Codigo
            //string constring = "Data Source=KARANAULAKH\\SQLEXPRESS;Initial Catalog=CARMODELS;Integrated Security=True";

            //SqlConnection connect = new SqlConnection(constring);
            //SqlCommand command = new SqlCommand("Insert into Regis values(@cb,@cm,@cy,@m)", connect);
            //command.Parameters.AddWithValue("@cb", DropDownList1.SelectedItem.Value);
            //command.Parameters.AddWithValue("@cm", DropDownList2.SelectedItem.Value);
            //command.Parameters.AddWithValue("@cy", txtCarYear.Text);
            //command.Parameters.AddWithValue("@m", txtMilage.Text);
            //connect.Open();
            //command.ExecuteNonQuery();
            //Label.Text = "successful";
            //DropDownList1.SelectedItem.Value = "";
            //DropDownList2.SelectedItem.Value = "";
            //txtCarYear.Text = "";
            //txtMilage.Text = "";
            //connect.Close();
            #endregion
        }
コード例 #5
0
        public ActionResult Deletecl()
        {
            String buy  = (string)(Session["log"]);
            var    item = db.reg.Where(v => v.UserName.Equals(buy));
            int    ID   = 0;

            foreach (var u in item)
            {
                ID = u.ID;
            }
            Regi r = db.reg.Find(ID);

            db.reg.Remove(r);
            db.SaveChanges();
            Session["log"] = null;
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public ActionResult Regis(String uname, String mail, String pword, String cpword, String cn, String ma)
        {
            Regi re = new Regi();

            if (Request.Form["submit"] != null)

            {
                try
                {
                    ViewBag.error      = 0;
                    re.UserName        = uname;
                    re.Email           = mail;
                    re.Password        = pword;
                    re.ConfirmPassword = cpword;
                    re.PhoneNumber     = cn;
                    re.MailAddress     = ma;
                    db.reg.Add(re);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    ViewBag.error = 1;
                    return(View());

                    StringBuilder sb = new StringBuilder();
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                    eve.Entry.Entity.GetType().Name,
                                                    eve.Entry.State));
                        foreach (var ve in eve.ValidationErrors)
                        {
                            sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                        ve.PropertyName,
                                                        ve.ErrorMessage));
                        }
                    }
                    throw new DbEntityValidationException(sb.ToString(), e);
                }
            }

            return(RedirectToAction("login"));
        }
コード例 #7
0
ファイル: LoginController.cs プロジェクト: itacki/NomiPro-WEB
        public ActionResult Registro(Regi Rel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (MomiproEntitiess entitiess = new MomiproEntitiess())
                    {
                        var Emp = new Empleados();
                        var ini = new iniciar_Sesion();

                        Emp.Nombre_Emple   = Rel.Nombre;
                        Emp.Apellido       = Rel.Apellido;
                        Emp.Telefono       = Rel.Telefono;
                        Emp.Tipo_Documento = Rel.TipoDocumento;
                        ini.Email          = Rel.Email;
                        ini.Contraseña     = Rel.Contrasena;
                        Emp.Correo         = ini.ID_login;
                        ViewBag.error      = Rel.TipoDocumento;
                        entitiess.Empleados.Add(Emp);
                        entitiess.SaveChanges();



                        return(Redirect("#"));
                    }
                }


                return(Redirect("/home/home"));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }