Пример #1
0
        public ActionResult Create([Bind(Include = "employeeID,firstName,lastName,employeeEmail")] employeedata employeedata)
        {
            int    xConvertID;
            string UserID;
            var    Temp_UserID = db2.employeedatas.Max(x => x.employeeID);

            if (Temp_UserID == null)
            {
                UserID = "100001";
                employeedata.employeeID = UserID;
            }
            else
            {
                Int32.TryParse(Temp_UserID, out xConvertID);
                xConvertID = xConvertID + 1;
                UserID     = xConvertID.ToString();
                employeedata.employeeID = UserID;
            }

            if (ModelState.IsValid)
            {
                db2.employeedatas.Add(employeedata);
                db2.SaveChanges();
                string message = "Your Employee ID is: " + UserID;
                var    result  = System.Windows.Forms.MessageBox.Show(message);

                return(RedirectToAction("View_Employees"));
            }

            return(View(employeedata));
        }
 public ActionResult UserRegistration(Registration user)//Authenticate the user
 {
     using (UserEntities2 dbmodel = new UserEntities2())
     {
         var z = dbmodel.Registrations.Any(x => x.Email == user.Email);
         var m = dbmodel.Registrations.Any(x => x.Username == user.Username);
         if (m == true || z == true)
         {
             ViewBag.DuplicateMessage = "true";
             return(View("UserRegistration", user));
         }
         dbmodel.Registrations.Add(user);
         dbmodel.SaveChanges();
     }
     ModelState.Clear();
     ViewBag.SuccessMessage = "true";
     return(View("UserRegistration", new Registration()));
 }