コード例 #1
0
ファイル: MainForm.cs プロジェクト: aymanprocessor/HopeCity
        private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Loginn loginn = new Loginn();

            loginn.Show();
            Hide();
        }
コード例 #2
0
        public ActionResult Login(Loginn log)
        {
            var result = db.Loginns.Where(a => a.login == log.login && a.senha == log.senha).ToList();

            if (result.Count() > 0)
            {
                Session["idLogin"] = result[0].idLogin;
                FormsAuthentication.SetAuthCookie(result[0].login, false);

                //If admin
                if (result[0].idNivelAcesso == 1)
                {
                    return(RedirectToAction("../Admin/index"));
                }
                //If Funcionario
                if (result[0].idNivelAcesso == 2)
                {
                    return(RedirectToAction("../Func/index"));
                }
            }
            else
            {
                ViewBag.Message = "Erro, Usuario ou senha incorreto";
            }
            return(View(log));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "idLogin,idFuncionario,login,senha,idNivelAcesso")] Loginn loginn)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loginn).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idFuncionario = new SelectList(db.Funcionarios, "idFuncionario", "nome", loginn.idFuncionario);
     ViewBag.idNivelAcesso = new SelectList(db.nivelAcessoes, "idNivelAcesso", "tipoAcesso", loginn.idNivelAcesso);
     return(View(loginn));
 }
コード例 #4
0
        // GET: Loginn/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Loginn loginn = db.Loginns.Find(id);

            if (loginn == null)
            {
                return(HttpNotFound());
            }
            return(View(loginn));
        }
コード例 #5
0
 public JsonResult Login(Loginn Data)
 {
     Engine.VerifyCredentials(ref Data);
     if (Data != null)
     {
         Session["controlNumber"] = Data.noControl;
         Session["level"]         = Data.Permiso;
         return(Json(new { status = HttpStatusCode.OK }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { status = HttpStatusCode.BadRequest, message = "Usuario o contraseña incorrectos" }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #6
0
       /* public IActionResult Price()
        {
            IEnumerable<Product> products3 = ShowAllProducts();
            return View("Price", products3);
        }*/

        public IActionResult SetLogin(string l, string p, string t, string n)
        {
            Loginn user = new Loginn();
            user.Login = l;
            user.Password = p;
            Login = l;
            Password = p;
            connection = String.Format("Host=localhost;Port=5434;Database=new_pryanick;Username={0};Password={1}", Login, Password);
            conn2 = new NpgsqlConnection(connection);
            TelNo = t;
            BakerFullName = n;
            StaffNo = FindStaffNo();
            return View("Index", user);
        }
コード例 #7
0
        // GET: Loginn/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Loginn loginn = db.Loginns.Find(id);

            if (loginn == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idFuncionario = new SelectList(db.Funcionarios, "idFuncionario", "nome", loginn.idFuncionario);
            ViewBag.idNivelAcesso = new SelectList(db.nivelAcessoes, "idNivelAcesso", "tipoAcesso", loginn.idNivelAcesso);
            return(View(loginn));
        }
コード例 #8
0
        public ActionResult detailsDeleteConfirmed(int id)
        {
            Loginn loginn = db.Loginns.Find(id);

            if (loginn.login.Equals("jw"))
            {
                ViewBag.Message = "Este login não pode ser apagado";
            }
            else
            {
                db.Loginns.Remove(loginn);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(loginn));
        }
コード例 #9
0
        public bool Check_is_admin(Loginn user)
        {
            string Login    = user.Login;
            string Password = user.Password;

            if (Login == "manager_ad" && Password == "julia") //проверяем является ли он админом?
            {
                conn.Open();                                  //если да, то подключаем его к базе new_pryanick
                connToAccounts = true;
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
        /// <summary>
        /// Guardar datos de inscripcion
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public string Finish(InscriptionData Data)
        {
            if (ValidateData(Data))
            {
                Loginn NewLogin = new Loginn();
                NewLogin.noControl   = Convert.ToString(setControlNumber(Data));
                NewLogin.Constraseña = Data.Password;
                NewLogin.Permiso     = "3";

                db.Loginn.Add(NewLogin);
                db.SaveChanges();

                Alumno Alu = new Alumno
                {
                    idCarrera = Convert.ToInt32(Data.CareerOption1),
                    noControl = NewLogin.noControl,
                    Semestre  = "0",

                    ApellidoP       = Data.LastNameP,
                    ApellidoM       = Data.LastNameM,
                    Nombre          = Data.Name,
                    Sexo            = Data.Gender ? "M" : "H",
                    Nacionalidad    = Data.Nationality,
                    Estado          = Data.State,
                    Municipio       = Data.Municipality,
                    Direccion       = Data.Address,
                    Colonia         = Data.Suburb,
                    CP              = Convert.ToString(Data.PostalCode),
                    Telefono        = Data.PhoneNumber,
                    Correo          = Data.Email,
                    FechaNacimiento = "",
                    Preparatoria    = "",
                    NombrePadre     = "",
                    NombreMadre     = ""
                };
                db.Alumno.Add(Alu);
                db.SaveChanges();

                return(Alu.noControl);
            }
            else
            {
                return(null);
            }
        }
コード例 #11
0
 public IActionResult Check_login(Loginn user)
 {
     if (ModelState.IsValid)
     {
         if (Check_is_admin(user))
         {
             conn.Close();
             return(View("~/Views/Admin/Index.cshtml"));
         }
         else
         {
             return(Check_in_base(user));
         }
     }
     else
     {
         return(View("SignIn"));
     }
 }
コード例 #12
0
        public string verificaLogin(string loginwpf, string senhawpf)
        {
            Loginn log = new Loginn();

            log.login = loginwpf;
            log.senha = senhawpf;

            var result = db.Loginns.Where(l => l.login == log.login && l.senha == log.senha).ToList();

            if (result.Count() > 0)
            {
                if (result[0].idNivelAcesso == 1)
                {
                    return("true");
                }
                return("false");
            }
            return("false");
        }
コード例 #13
0
        private void Submit()
        {
            Loginn login = new Loginn()
            {
                UserName = userName,
                Password = password
            };
            DataTable dt = loginManage.CheckDataFound(login);

            if (dt.Rows.Count > 0)
            {
                int userId = Convert.ToInt32(dt.Rows[0]["Id"].ToString());
                this.Hide();
                Home home = new Home(userId);
                home.ShowDialog();
            }
            else
            {
                MessageBox.Show("Data is not found");
            }
        }
コード例 #14
0
        public IActionResult Check_in_base(Loginn s)
        {
            bool          find     = false;
            NpgsqlCommand command1 = new NpgsqlCommand(@"select us.""Login"",us.""Password"", us.""RoleName"",us.""TelNo"",us.""FirstName"" || ' ' || us.""LastName""
            from ""UsersAccounts2"" as us");

            command1.Connection = conn;
            conn.Open();
            NpgsqlDataReader dataReader_1;
            string           login    = "";
            string           password = "";
            string           role     = "";
            string           TelNo    = "";
            string           fullname = "";

            dataReader_1 = command1.ExecuteReader();
            while (dataReader_1.Read())
            {
                login    = string.Format("{0}", dataReader_1[0].ToString().Trim());
                password = string.Format("{0}", dataReader_1[1].ToString().Trim());
                role     = string.Format("{0}", dataReader_1[2].ToString().Trim());
                TelNo    = string.Format("{0}", dataReader_1[3].ToString().Trim());
                fullname = string.Format("{0}", dataReader_1[4].ToString().Trim());
                if (password == MakeMd5Hash(s.Password) && login == s.Login)
                {
                    find = true; break;
                }
            }
            conn.Close();
            conn2.Open();

            string        d = String.Format(@"select ""IsFired"" from ""Staff"" where ""TelNo""='{0}'", TelNo);
            NpgsqlCommand c = new NpgsqlCommand(d);

            c.Connection = conn2;
            NpgsqlDataReader dataReader_3;

            dataReader_3 = c.ExecuteReader();
            bool find2 = true;

            while (dataReader_3.Read())
            {
                if (string.Format("{0}", dataReader_3[0].ToString().Trim()) == "False")
                {
                    find2 = false;
                }
            }
            conn2.Close();

            if (find == true && find2 == false)
            {
                if (role == "Пекарь" || role == "Кондитер")
                {
                    return(RedirectToAction("SetLogin", "Baker", new { l = s.Login, p = s.Password, t = TelNo, n = fullname }));
                    //return View("~/Views/Baker/Index.cshtml",s);
                }
                else if (role == "Владелец")
                {
                    return(RedirectToAction("SetLogin", "Owner", new { l = s.Login, p = s.Password, t = TelNo, n = fullname }));
                }
                else if (role == "Продавец")
                {
                    return(RedirectToAction("SetLogin", "Seller", new { l = s.Login, p = s.Password, t = TelNo, n = fullname }));
                    //return View("~/Views/Seller/Index.cshtml", s);
                }

                return(View("SignIn"));
            }
            else
            {
                ViewBag.Message = "* Введенные данные некорректны! ";
                return(View("SignIn"));
            }
        }
コード例 #15
0
 public bool createUser(InscriptionData Data)
 {
     try
     {
         Loginn Login = new Loginn {
             Constraseña = Data.Password
         };
         if (Data.Level == 3)
         {
             Login.Permiso   = "3";
             Login.noControl = IEngine.setControlNumber(Data);
             db.Loginn.Add(Login);
             db.SaveChanges();
             Alumno New = new Alumno
             {
                 ApellidoP       = Data.LastNameP,
                 ApellidoM       = Data.LastNameM,
                 Nombre          = Data.Name,
                 Estado          = Data.State,
                 Sexo            = Data.Gender ? "M" : "H",
                 Municipio       = Data.Municipality,
                 Direccion       = Data.Address,
                 Colonia         = Data.Suburb,
                 CP              = Convert.ToString(Data.PostalCode),
                 Telefono        = Data.PhoneNumber,
                 Correo          = Data.Email,
                 Nacionalidad    = "Mexicano",
                 FechaNacimiento = "",
                 Preparatoria    = "",
                 NombrePadre     = "",
                 NombreMadre     = "",
                 Semestre        = "0",
                 noControl       = Login.noControl,
                 idCarrera       = Convert.ToInt32(Data.CareerOption1)
             };
             db.Alumno.Add(New);
         }
         else
         {
             Login.Permiso   = "2";
             Login.noControl = IEngine.setControlNumber(Data);
             db.Loginn.Add(Login);
             db.SaveChanges();
             Maestro New = new Maestro {
                 NumEconomico    = Login.noControl,
                 ApellidoP       = Data.LastNameP,
                 ApellidoM       = Data.LastNameM,
                 Nombre          = Data.Name,
                 Estado          = Data.State,
                 Sexo            = Data.Gender ? "M" : "H",
                 Municipio       = Data.Municipality,
                 Direccion       = Data.Address,
                 Colonia         = Data.Suburb,
                 CP              = Convert.ToString(Data.PostalCode),
                 Telefono        = Data.PhoneNumber,
                 Correo          = Data.Email,
                 Nacionalidad    = "Mexicano",
                 FechaNacimiento = "",
             };
             db.Maestro.Add(New);
         }
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #16
0
        /// <summary>
        /// Verificar credenciales de login en la db
        /// </summary>
        /// <param name="user"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public void VerifyCredentials(ref Loginn Data)
        {
            string cn = Data.noControl, pass = Data.Constraseña;

            Data = db.Loginn.FirstOrDefault(x => x.noControl == cn && x.Constraseña == pass);
        }