Ejemplo n.º 1
0
        protected void btn_kayitekle_Click(object sender, EventArgs e)
        {
            int ID = int.Parse(HttpContext.Current.Request.Cookies["" + Class.Fonksiyonlar.Genel.Parametre().Select(b => b.guvenlik_kodu).FirstOrDefault() + "KullaniciID"].Value);

            try
            {
                using (BaglantiCumlesi db = new BaglantiCumlesi())
                {
                    tbl_admin TblEkle = db.tbl_admin.First(a => a.id == ID);
                    TblEkle.ad      = Class.Fonksiyonlar.Genel.SQLTemizle(form_ad.Text);
                    TblEkle.eposta  = Class.Fonksiyonlar.Genel.SQLTemizle(form_eposta.Text);
                    TblEkle.telefon = Class.Fonksiyonlar.Genel.SQLTemizle(form_telefon.Text);

                    if (form_sifre.Text != "")
                    {
                        TblEkle.sifre = Class.Fonksiyonlar.Genel.Sifrele(form_sifre.Text);
                    }

                    TblEkle.admin_id_gun = int.Parse(HttpContext.Current.Request.Cookies["" + Class.Fonksiyonlar.Genel.Parametre().Select(b => b.guvenlik_kodu).FirstOrDefault() + "KullaniciID"].Value);
                    db.SaveChanges();
                }

                Yonetim.Olay.Islem("kullanici", "Güncellendi", ID.ToString());
                Class.Fonksiyonlar.JavaScript.MesajKutusuVeYonlendir("Profiliniz başarıyla düzenlenmiştir.", "profil.aspx");
            }
            catch (Exception ex)
            {
                Class.Fonksiyonlar.JavaScript.MesajKutusuVeYonlendir(Yonetim.Degiskenler.Hata + ex.Message, "profil.aspx");
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult Puttbl_admin(int id, tbl_admin tbl_admin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_admin.id)
            {
                return(BadRequest());
            }

            db.Entry(tbl_admin).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tbl_adminExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        protected void btn_kayitekle_Click(object sender, EventArgs e)
        {
            try
            {
                using (BaglantiCumlesi db = new BaglantiCumlesi())
                {
                    tbl_admin TblEkle = new tbl_admin();
                    TblEkle.ad          = Class.Fonksiyonlar.Genel.SQLTemizle(form_ad.Text);
                    TblEkle.eposta      = Class.Fonksiyonlar.Genel.SQLTemizle(form_eposta.Text);
                    TblEkle.telefon     = Class.Fonksiyonlar.Genel.SQLTemizle(form_telefon.Text);
                    TblEkle.sifre       = Class.Fonksiyonlar.Genel.Sifrele(form_sifre.Text);
                    TblEkle.onay        = Class.Fonksiyonlar.Genel.StringToBool(form_onay.SelectedValue);
                    TblEkle.admin_id_ek = int.Parse(HttpContext.Current.Request.Cookies["" + Class.Fonksiyonlar.Genel.Parametre().Select(b => b.guvenlik_kodu).FirstOrDefault() + "KullaniciID"].Value);
                    db.AddTotbl_admin(TblEkle);
                    db.SaveChanges();
                }

                Yonetim.Olay.Islem("kullanici", "Yeni Kayıt", "");
                Class.Fonksiyonlar.JavaScript.MesajKutusuVeYonlendir("Kullanıcı başarıyla eklenmiştir. Kullanıcı listesine yönlendiriliyorsunuz.", "kullanici.aspx");
            }
            catch (Exception ex)
            {
                Class.Fonksiyonlar.JavaScript.MesajKutusuVeYonlendir(Yonetim.Degiskenler.Hata + ex.Message, "kullanici-ekle.aspx");
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_admin tbl_admin = db.tbl_admin.Find(id);

            db.tbl_admin.Remove(tbl_admin);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string userName = txtUserName.Value.Trim();
        string userPwd  = txtPassword.Value.Trim();

        //判断登录信息
        userPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(userPwd, "MD5");
        //Response.Write(userPwd);
        //Response.End();
        if (tbl_admin.Exists(userName, userPwd))
        {
            tbl_admin myuser       = new tbl_admin();
            string    sqlGetUserID = "select  id  from [tbl_admin] where huiyuan_bianhao='" + userName + "'";
            int       userid       = Convert.ToInt16(DbHelperSQL.GetSingle(sqlGetUserID));
            myuser.GetModel(userid);

            //判断账号是否被禁用
            if (Convert.ToInt32(myuser.is_lock) == 1)
            {
                MessageBox.errorShow(this.Page, "您的账号被禁用,请联系客服!");
                return;
            }

            //写入登录日志
            tbl_login login_log = new tbl_login();
            login_log.huiyuan_bianhao = userName;
            login_log.huiyuan_name    = myuser.huiyuan_name;
            login_log.login_date      = DateTime.Now;
            login_log.login_flag      = 1;
            login_log.huiyuan_ip      = AXRequest.GetIP();
            login_log.Add();


            //写入Cookies
            Utils.WriteCookie("hy_id", myuser.huiyuan_id, 14400);
            Utils.WriteCookie("hy_bianhao", userName, 14400);
            Utils.WriteCookie("hy_name", myuser.huiyuan_name, 14400);
            Utils.WriteCookie("RoleID", myuser.role_id.ToString(), 14400);


            //写入Session
            Session["hy_id"]      = myuser.huiyuan_id;
            Session["hy_bianhao"] = userName;
            Session["hy_name"]    = myuser.huiyuan_name;
            Session["RoleID"]     = myuser.role_id.ToString();


            Session.Timeout = 45;

            Response.Redirect("index.aspx");
            return;
        }
        else
        {
            MessageBox.errorShow(this.Page, "账号或密码有误,请重试!");
            return;
        }
    }
 public ActionResult AdminCreate(tbl_admin tbl_Admin)
 {
     using (BlogEntities db = new BlogEntities())
     {
         db.tbl_admin.Add(tbl_Admin);
         db.SaveChanges();
     }
     return(RedirectToAction("AdminView"));
 }
 public ActionResult AdminDelete(int id, tbl_admin tbl_Admin)
 {
     using (BlogEntities db = new BlogEntities())
     {
         db.Entry(tbl_Admin).State = EntityState.Deleted;
         db.SaveChanges();
     }
     return(RedirectToAction("AdminView"));
 }
 public ActionResult Edit([Bind(Include = "Id,first_name,last_name,password")] tbl_admin tbl_admin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_admin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_admin));
 }
Ejemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "admin_id,employeeid,admin_name,admin_email,user_name,password,status,admin_access,admin_level,user_id")] tbl_admin tbl_admin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_admin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.user_id = new SelectList(db.tbl_user, "user_id", "user_name", tbl_admin.user_id);
     return(View(tbl_admin));
 }
        public ActionResult Create([Bind(Include = "Id,first_name,last_name,password")] tbl_admin tbl_admin)
        {
            if (ModelState.IsValid)
            {
                db.tbl_admin.Add(tbl_admin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_admin));
        }
Ejemplo n.º 11
0
        public IHttpActionResult Gettbl_admin(int id)
        {
            tbl_admin tbl_admin = db.tbl_admin.Find(id);

            if (tbl_admin == null)
            {
                return(NotFound());
            }

            return(Ok(tbl_admin));
        }
Ejemplo n.º 12
0
        public IHttpActionResult Posttbl_admin(tbl_admin tbl_admin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tbl_admin.Add(tbl_admin);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tbl_admin.id }, tbl_admin));
        }
        public ActionResult login(adminviewmodel avm)
        {
            tbl_admin t = db.tbl_admin.Where(x => x.Ad_name == avm.Ad_name && x.Ad_password == avm.Ad_password).SingleOrDefault();

            if (t != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View("login"));
            }
            return(View());
        }
Ejemplo n.º 14
0
 public ActionResult AdminHome()
 {
     if (Session["ad_id"] != null)
     {
         int       aid = Convert.ToInt32(Session["ad_id"]);
         tbl_admin ta  = db.tbl_admin.Where(x => x.ad_id == aid).Single();
         ViewBag.adname = ta.ad_username;
         return(View());
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
        // GET: admin/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_admin tbl_admin = db.tbl_admin.Find(id);

            if (tbl_admin == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_admin));
        }
Ejemplo n.º 16
0
        public IHttpActionResult Deletetbl_admin(int id)
        {
            tbl_admin tbl_admin = db.tbl_admin.Find(id);

            if (tbl_admin == null)
            {
                return(NotFound());
            }

            db.tbl_admin.Remove(tbl_admin);
            db.SaveChanges();

            return(Ok(tbl_admin));
        }
Ejemplo n.º 17
0
        public ActionResult Giris(tbl_admin t)
        {
            var bilgiler = db.tbl_admin.FirstOrDefault(x => x.kullanici == t.kullanici && x.sifre == t.sifre);

            if (bilgiler != null)
            {
                FormsAuthentication.SetAuthCookie(bilgiler.kullanici, false);
                return(RedirectToAction("Index", "Musteri"));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 18
0
        public ActionResult login(tbl_admin admin)
        {
            tbl_admin adminLogueandose = db.tbl_admin.Where(x => x.ad_username.Equals(admin.ad_username) && x.ad_password.Equals(admin.ad_password)).SingleOrDefault();

            if (adminLogueandose != null)
            {
                Session["ad_id"] = adminLogueandose.ad_id;
                return(RedirectToAction("Create"));
            }
            else
            {
                ViewBag.error = "Invalid user name or password";
            }
            return(View());
        }
Ejemplo n.º 19
0
        public ActionResult Login(tbl_admin t)
        {
            var bilgiler = db.tbl_admin.FirstOrDefault(x => x.kullanıcı == t.kullanıcı && x.şifre == t.şifre);

            if (bilgiler != null)
            {
                FormsAuthentication.SetAuthCookie(bilgiler.kullanıcı, false);
                return(RedirectToAction("Index", "Müşteri"));
            }
            else
            {
                return(View());
            }
            return(View());
        }
Ejemplo n.º 20
0
        public ActionResult Login(tbl_admin avm)
        {
            tbl_admin ad = db.tbl_admin.Where(x => x.ad_username == avm.ad_username && x.ad_password == avm.ad_password).SingleOrDefault();

            if (ad != null)
            {
                Session["ad_id"] = ad.ad_id.ToString();
                return(RedirectToAction("Create"));
            }
            else
            {
                ViewBag.error = "invalid username or password";
            }
            return(View());
        }
Ejemplo n.º 21
0
        // GET: /Admin/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_admin tbl_admin = db.tbl_admin.Find(id);

            if (tbl_admin == null)
            {
                return(HttpNotFound());
            }
            ViewBag.user_id = new SelectList(db.tbl_user, "user_id", "user_name", tbl_admin.user_id);
            return(View(tbl_admin));
        }
Ejemplo n.º 22
0
        //post login form
        public ActionResult Login(adminviewmodel obj)
        {
            tbl_admin t = db.tbl_admin.Where(x => x.ad_Email == obj.ad_Email && x.ad_password == obj.ad_password && x.ad_designation == obj.ad_designation).SingleOrDefault();

            if (t != null)
            {
                Session["User_id"] = t.ad_name;
                return(RedirectToAction("Adminplate"));
            }
            else
            {
                return(RedirectToAction("Login"));
            }

            return(View());
        }
Ejemplo n.º 23
0
        public ActionResult login(tbl_admin avm)
        {
            tbl_admin ad = db.tbl_admin.Where(x => x.admin_username == avm.admin_username && x.admin_password == avm.admin_password).SingleOrDefault();

            if (ad != null)
            {
                Session["admin_id"] = ad.admin_id.ToString();
                return(RedirectToAction("Create"));
            }
            else
            {
                ViewBag.error = "Geçersiz kullanıcı adı ve şifre";
            }

            return(View());
        }
Ejemplo n.º 24
0
        public ActionResult Login(tbl_admin admin)
        {
            var person = db.tbl_admin.Where(x => x.ad_username == admin.ad_username && x.ad_password == admin.ad_password).SingleOrDefault();

            if (person != null)
            {
                Session["ad_id"]       = person.ad_id.ToString();
                Session["ad_username"] = person.ad_username.ToString();
                return(RedirectToAction("Create"));
            }
            else
            {
                ViewBag.Message = "Invalid user name and password!";
            }

            return(View());
        }
Ejemplo n.º 25
0
        public ActionResult adminManagementEdit(FormCollection form)
        {
            var username = form["username"];

            if (username == null)
            {
                return(adminManagementCreate(form));
            }
            else
            {
                tbl_admin tic      = getOneAdmin(username);
                var       password = form["password"];

                bool err = false;
                if (String.IsNullOrEmpty(username))
                {
                    err = true;
                    ViewData["Error"] += "Vui lòng nhập username!\n";
                }
                if (String.IsNullOrEmpty(password))
                {
                    err = true;
                    ViewData["Error"] += "Vui lòng nhập mật khẩu!\n";
                }
                if (form["priority"].ToString().Equals("0"))
                {
                    err = true;
                    ViewData["Error"] += "Vui lòng chọn quyền admin!\n";
                }
                else
                {
                    tic.Priority = Int32.Parse(form["priority"]);
                }
                tic.Password = password;
                if (err == false)
                {
                    UpdateModel(tic);
                    data.SubmitChanges();
                    return(RedirectToAction("adminManagementView"));
                }
                else
                {
                    return(View(URLHelper.URL_ADMIN_MANAGEMENT_M, tic));
                }
            }
        }
 public ActionResult Login(tbl_admin a)
 {
     //to handle post
     if (ModelState.IsValid)
     {
         using (HospitalDatabaseContext db = new HospitalDatabaseContext())
         {
             var v = db.tbl_admin.Where(u => u.first_name.Equals(a.first_name) && u.password.Equals(a.password)).FirstOrDefault();
             if (v != null)
             {
                 Session["LoggedInUserFirstName"] = v.first_name.ToString();
                 Session["LoggedInUserPassword"]  = v.password.ToString();
                 return(RedirectToAction("AfterLogin"));
             }
         }
     }
     return(View(a));
 }
Ejemplo n.º 27
0
        //post signuup form
        public ActionResult Signup(adminviewmodel obj)
        {
            if (ModelState.IsValid)
            {
                tbl_admin t = new tbl_admin();
                t.ad_name        = obj.ad_name;
                t.ad_Email       = obj.ad_Email;
                t.ad_password    = obj.ad_password;
                t.ad_designation = obj.ad_designation;
                db.tbl_admin.Add(t);
                db.SaveChanges();
                return(Redirect("Login"));
            }



            return(View());
        }
        public ActionResult Login(tbl_admin tbl_Admin)
        {
            using (BlogEntities db = new BlogEntities())
            {
                var AdminInfo = db.tbl_admin.FirstOrDefault(x => x.Email == tbl_Admin.Email && x.Password == tbl_Admin.Password);

                if (AdminInfo == null)
                {
                    ViewBag.Error = "Wrong Information";
                }
                else
                {
                    Session["Admin"] = AdminInfo;
                    return(RedirectToAction("Dashboard"));
                }
            }

            return(View());
        }
Ejemplo n.º 29
0
        protected void SifreDenetle()
        {
            string KullaniciAdi = Class.Fonksiyonlar.Genel.SQLTemizle(form_kullanici.Text);
            string Sifre        = Class.Fonksiyonlar.Genel.SQLTemizle(form_sifre.Text);

            Sifre = Class.Fonksiyonlar.Genel.Sifrele(Sifre);

            using (BaglantiCumlesi db = new BaglantiCumlesi())
            {
                var SQL = (from a in db.tbl_admin
                           where a.eposta == KullaniciAdi && a.sifre == Sifre
                           select new
                {
                    a.id
                }).AsEnumerable();

                if (SQL.Any())
                {
                    Class.Fonksiyonlar.Genel.OturumIslemleri.CookieOlustur("" + Class.Fonksiyonlar.Genel.Parametre().Select(b => b.guvenlik_kodu).FirstOrDefault() + "giris", "7777777");
                    Class.Fonksiyonlar.JavaScript.MesajKutusuVeYonlendir("Kimlik doğrulaması başarılı. Kontrol paneline yönlendiriliyorsunuz!", "Default.aspx");

                    foreach (var item in SQL)
                    {
                        Class.Fonksiyonlar.Genel.OturumIslemleri.CookieOlustur("" + Class.Fonksiyonlar.Genel.Parametre().Select(b => b.guvenlik_kodu).FirstOrDefault() + "KullaniciID", item.id.ToString());

                        BaglantiCumlesi dbu          = new BaglantiCumlesi();
                        tbl_admin       TblKullanici = dbu.tbl_admin.First(p => p.id == item.id);
                        TblKullanici.son_giris = DateTime.Now;
                        TblKullanici.son_ip    = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                        dbu.SaveChanges();

                        Yonetim.Olay.GirisCikis("Giriş");
                    }
                }
                else
                {
                    Class.Fonksiyonlar.JavaScript.MesajKutusu("Şifreniz hatalıdır!");
                    Yonetim.Olay.GirisHata("Geçersiz Şifre", form_kullanici.Text);
                }
            }
        }
        public ActionResult AdminUpdate(int id, string btn, tbl_admin tbl_Admin)
        {
            using (BlogEntities db = new BlogEntities())
            {
                var admin   = db.tbl_admin.FirstOrDefault(x => x.ID == id);
                var session = (tbl_admin)Session["Admin"];

                if (btn == "name")
                {
                    admin.Name   = tbl_Admin.Name;
                    session.Name = admin.Name;
                }

                else if (btn == "email")
                {
                    admin.Email   = tbl_Admin.Email;
                    session.Email = admin.Email;
                }

                else
                {
                    if (admin.Password == Request["OldPassword"])
                    {
                        admin.Password = Request["NewPassword"];
                        db.SaveChanges();

                        return(RedirectToAction("Logout"));
                    }
                    else
                    {
                        TempData["PassError"] = "Current Password Not Match..";
                        return(RedirectToAction("Setting"));
                    }
                }

                db.SaveChanges();
            }
            return(RedirectToAction("Setting"));
        }