Наследование: System.Web.UI.Page
Пример #1
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        admin = new admin();
        admin.Init();
        admin.adminPstate = "public";

        string tmpstr = "";
        string tType = cls.getString(request.querystring("type"));

        switch(tType)
        {
          case "action":
        tmpstr = Module_Action();
        break;
          case "login":
        tmpstr = Module_Login();
        break;
          case "desktop":
        tmpstr = Module_Desktop();
        break;
          default:
        tmpstr = Module_Default();
        break;
        }
        PagePrint(tmpstr);
        PageClose();
    }
Пример #2
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        admin = new admin();
        admin.Init();

        if (admin.ckLogin())
        {
          string tmpstr = "";
          string tType = cls.getString(request.querystring("type"));

          switch(tType)
          {
        case "action":
          tmpstr = Module_Action();
          break;
        case "list":
          tmpstr = Module_List();
          break;
        default:
          tmpstr = Module_List();
          break;
          }

          PagePrint(tmpstr);
        }

        PageClose();
    }
Пример #3
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (Convert.ToInt32(Request.Cookies["login"].Values["_role"]) == 1)
        {

            if (e.CommandName == "Delete")
            {
                admin admin1 = new admin();
                admin1.id = Convert.ToInt32(e.CommandArgument);
                BLLadmin blladmin1 = new BLLadmin();
                int result = blladmin1.deleteAdmin(admin1);
                if (result > 0)
                {
                    Common.MessageAlert.AlertLocation(Page, "alert('删除成功');location.href='adminList.aspx'");

                }
                else
                {
                    Common.MessageAlert.Alert(Page, "删除失败");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('对不起您没有这个权限');</script>");
        }
    }
        public ChangePasswordForm(ref admin.DataServiceSoapClient dataService, ref string userID)
		{
			this.InitializeComponent();
			this._dataService = dataService;
			this._dataService.ChangePasswordCompleted += new EventHandler<admin.ChangePasswordCompletedEventArgs>(this._dataService_ChangePasswordCompleted);
			this._currentUserID = userID;
		}
Пример #5
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        _admin = new admin();
        _admin.Init();
        _admin.adminPstate = "public";

        string tmpstr = "";
        string tType = cls.getString(request.querystring("type"));
        string tAtype = cls.getString(request.querystring("atype"));
        if (!string.IsNullOrEmpty(tType) && !string.IsNullOrEmpty(tAtype))
        {
            switch (tType)
            {
                //登入或登出,都会经过 redirect 跳转出去
                case "action":
                    Module_Action();
                    break;
            }
        }

        if (_admin.ckLogin()) //已登录
        {
            Module_Desktop(); //进入后台主界面
        }
        else //未登录
        {
            tmpstr = Module_Login(); //进入登录界面
        }

        PagePrint(tmpstr);
        PageClose();
    }
Пример #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var txt_acc = context.Request.Form["txt_acc"];
            var txt_pwd = context.Request.Form["txt_pwd"];
            var txt_Vallentity = context.Request.Form["txt_Vallentity"];
            if (txt_Vallentity != context.Session["Catcha"].ToString())
            {
                context.Response.Write("Valerror");
                return;
            }

            admin m = new admin();
            m.u_id = txt_acc;
            m.u_password = txt_pwd;
            adminData md = new adminData();
            var message = md.Ismember(m);

            if (message[0] == "Find")
            {
                context.Session["Member"] = message[1];
                context.Session["MName"] = message[2];
                context.Response.Write("OK");
            }
            else
            {
                context.Session["Member"] = "";
                context.Response.Write("NO");
            }
        }
Пример #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        admin admin1 = new admin();
        admin1.name = txt_name.Text;
        admin1.pwd = txt_pwd.Text;
        admin1.role = Convert.ToInt32(DropDownList1.SelectedValue);
        BLLadmin blladmin = new BLLadmin();
        MySqlDataReader sdr = blladmin._login(admin1);
        if (sdr.Read())
        {
            HttpCookie mycookie = new HttpCookie("login");
            mycookie.Values.Add("_name", txt_name.Text);
            mycookie.Values.Add("_role", DropDownList1.SelectedValue);

            TimeSpan ts = new TimeSpan(3, 0, 30, 0);

            DateTime dt = DateTime.Now;

           mycookie.Expires = dt.Add(ts);

            Response.AppendCookie(mycookie);
            sdr.Close();

            Response.Redirect("Default.aspx");

        }
        else
        {

            Common.MessageAlert.Alert(Page, "用户名或密码有误");
        }
    }
Пример #8
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        _admin = new admin();
        _admin.Init();
        _admin.adminPstate = "public";

        if (!_admin.ckLogin()) Response.Redirect("default.aspx");

        string tmpstr = "";
        tmpstr = jt.ireplace("main.admin_frame", "tpl");

        PagePrint(tmpstr);
        PageClose();
    }
Пример #9
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        _admin = new admin();
        _admin.Init();
        _admin.adminPstate = "public";

        if (!_admin.ckLogin()) Response.Redirect("default.aspx");

        string tmpstr = "";
        tmpstr = Module_Desktop();

        PagePrint(tmpstr);
        PageClose();
    }
Пример #10
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        admin = new admin();
        admin.Init();

        if (admin.ckLogin())
        {
          string tmpstr = "";
          string tType = cls.getString(request.querystring("type"));

          switch(tType)
          {
        case "action":
          tmpstr = Module_Action();
          break;
        case "category":
          tmpstr = Module_Category();
          break;
        case "urls":
          tmpstr = Module_Urls();
          break;
        case "add":
          tmpstr = Module_Add();
          break;
        case "edit":
          tmpstr = Module_Edit();
          break;
        case "list":
          tmpstr = Module_List();
          break;
        case "upload":
          tmpstr = upfiles.uploadHTML("upload-html-1");
          break;
        default:
          tmpstr = Module_List();
          break;
          }

          PagePrint(tmpstr);
        }

        PageClose();
    }
Пример #11
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        admin admin2 = new admin();
        admin2.id = Convert.ToInt32(Label1.Text);
        admin2.name = txt_name.Text;
        admin2.pwd =Common.DESEncrypt.Encrypt(txt_pwd.Text);

        BLLadmin blladmin = new BLLadmin();
        int result = blladmin.updateAdmin(admin2);
        if (result > 0)
        {
            Common.MessageAlert.AlertLocation(Page, "alert('更新成功');location.href='adminList.aspx'");
        }
        else
        {
            Common.MessageAlert.Alert(Page, "更新失败");
        }
    }
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            admin admin1 = new admin();
            admin1.id = Convert.ToInt32(Request.QueryString["id"]);

            BLLadmin blladmin = new BLLadmin();
            MySqlDataReader sdr = blladmin.readAdmin(admin1);
            if (sdr.Read())
            {
                int i = Convert.ToInt32(sdr["_id"].ToString());
                Label1.Text = i.ToString();
                txt_name.Text = sdr["_name"].ToString();
                txt_pwd.Text = Common.DESEncrypt.Decrypt(sdr["_pwd"].ToString());

            }
        }
    }
Пример #13
0
    protected void Page_Load()
    {
        PageInit();
        PageNoCache();

        admin = new admin();
        admin.Init();
        account = new account();
        account.Init(jt.itake("config.naccount", "cfg"));

        if (admin.ckLogin())
        {
          string tmpstr = "";
          string tType = cls.getString(request.querystring("type"));

          switch(tType)
          {
        case "action":
          tmpstr = Module_Action();
          break;
        case "add":
          tmpstr = Module_Add();
          break;
        case "edit":
          tmpstr = Module_Edit();
          break;
        case "list":
          tmpstr = Module_List();
          break;
        default:
          tmpstr = Module_List();
          break;
          }

          PagePrint(tmpstr);
        }

        PageClose();
    }
Пример #14
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Convert.ToInt32(Request.Cookies["login"].Values["_role"])==1)
        {
            admin admin1 = new admin();
            admin1.name = txt_name.Text;

            BLLadmin blladmin1 = new BLLadmin();
            MySqlDataReader sdr = blladmin1.checkAdmin(admin1);
            if (sdr.Read())
            {
                Common.MessageAlert.Alert(Page, "该管理员已存在");
                txt_name.Text = "";
                txt_pwd.Text = "";
                sdr.Close();
            }
            else
            {
                admin admin2 = new admin();
                admin2.name = txt_name.Text;
                admin2.pwd =Common.DESEncrypt.Encrypt(txt_pwd.Text);
                admin2.role =Convert.ToInt32(dl_select.SelectedValue);

                BLLadmin blladmin2 = new BLLadmin();
                int result = blladmin2.insertAdmin(admin2);
                if (result > 0)
                {
                    Common.MessageAlert.AlertLocation(Page, "alert('添加管理员成功');location.href='adminList.aspx'");
                }
            }
        }
        else
        {
            Common.MessageAlert.Alert(Page,"对不起您不能执行此操作");
            txt_name.Text = "";
            txt_pwd.Text = "";
        }
    }
Пример #15
0
        public admin SelectOne(int id)
        {
            admin selectedAdmin = _admins.Where(a => a.AdminID == id).FirstOrDefault();

            return(selectedAdmin);
        }
Пример #16
0
        public ActionResult Edit(int id)
        {
            admin admin = admins.Single(a => a.id == id);

            return(View());
        }
Пример #17
0
 public void SaveAdmin(admin acc)
 {
     AdminRepository.Save(acc);
 }
Пример #18
0
        private void materialRaisedButton6_Click(object sender, EventArgs e)
        {
            cn.Open();
            //cmd = new SqlCommand("select * from login  where U_N='" + UID.Text + "' and PWD='" + PWD.Text + "' and UT='admin'", cn);
            //SqlCommand cmd1 = new SqlCommand("select * from login  where U_N='" + UID.Text + "' and PWD='" + PWD.Text + "' and UT='operator'", cn);
            //dr = cmd.ExecuteReader();

            //if (dr.Read())
            //{
            //    admin a = new admin();
            //    a.Show();
            //    this.Hide();
            //}
            //else
            //{
            //    MessageBox.Show("Invalid Username or Password");

            //}
            //dr.Close();
            //SqlDataReader dr1 = cmd1.ExecuteReader();
            //   if (dr1.Read())
            //   {
            //         Form1 f = new Form1();
            //    f.Show();
            //    this.Hide();
            //    }
            //else
            //{
            //    MessageBox.Show("Invalid Username or Password");
            //}


            //dr1.Close();

            SqlDataAdapter da  = new SqlDataAdapter("select * from login  where U_N='" + UID.Text + "' and PWD='" + PWD.Text + "' and UT='admin'", cn);
            SqlDataAdapter da1 = new SqlDataAdapter("select * from login  where U_N='" + UID.Text + "' and PWD='" + PWD.Text + "' and UT='operator'", cn);
            DataTable      dt  = new DataTable();
            DataTable      dt1 = new DataTable();

            da.Fill(dt);
            da1.Fill(dt1);


            if (dt.Rows.Count == 1)
            {
                admin a = new admin();
                a.Show();
                this.Hide();
            }
            else if (dt1.Rows.Count == 1)
            {
                entry1 f  = new entry1();
                string un = UID.Text;
                f.txtprint = un;
                f.Owner    = this;
                f.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Invalid Username or Password");
            }

            cn.Close();
        }
Пример #19
0
        public async Task <JsonResult> saveImage()
        {
            try
            {
                var fileContent = Request.Files[0];
                if (fileContent != null && fileContent.ContentLength > 0)
                {
                    // get a stream
                    var stream = fileContent.InputStream;
                    // and optionally write the file to disk
                    var fileName = Request.Files[0].FileName;
                    var path     = Path.Combine(Server.MapPath("~/userImages"), fileName);
                    using (var fileStream = System.IO.File.Create(path))
                    {
                        stream.CopyTo(fileStream);
                    }

                    admin  adm         = db.admins.Single(ad => ad.name == User.Identity.Name);
                    string oldFileName = adm.image;
                    string oldPath     = Server.MapPath("~/") + oldFileName.Replace("/", "\\");
                    if (oldFileName != "/userImages/default.png")
                    {
                        if (System.IO.File.Exists(oldPath))
                        {
                            System.IO.File.Delete(oldPath);
                        }
                    }
                    if (adm != null)
                    {
                        adm.image           = "/userImages/" + fileName;
                        db.Entry(adm).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }

                    HttpCookie oldAuthCookie          = Request.Cookies[FormsAuthentication.FormsCookieName];
                    FormsAuthenticationTicket mytiket = FormsAuthentication.Decrypt(oldAuthCookie.Value);
                    var newTicket = new FormsAuthenticationTicket
                                        (mytiket.Version,
                                        mytiket.Name,
                                        mytiket.IssueDate,
                                        mytiket.Expiration,
                                        mytiket.IsPersistent,
                                        "/userImages/" + fileName, "/admin");
                    FormsAuthentication.SignOut();
                    Session.Abandon();
                    var isPersistent = FormsAuthentication.Decrypt(oldAuthCookie.Value).IsPersistent;
                    FormsAuthenticationTicket oldticket = FormsAuthentication.Decrypt(oldAuthCookie.Value);
                    string oldCookieName = oldticket.Name;
                    var    newticket     = new FormsAuthenticationTicket
                                               (oldticket.Version, oldticket.Name, oldticket.IssueDate, oldticket.Expiration, oldticket.IsPersistent, "/userImages/" + fileName, "/admin");
                    oldAuthCookie.Value = FormsAuthentication.Encrypt(newticket);
                    Request.Cookies.Remove(oldCookieName);
                    if (isPersistent)
                    {
                        oldAuthCookie.Expires = newticket.Expiration;
                    }
                    oldAuthCookie.Path = newticket.CookiePath;
                    Response.Cookies.Add(oldAuthCookie);
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Пример #20
0
 public admin Login(admin admin) => user_Repostory.Login(admin);
Пример #21
0
 public MySqlDataReader readAdmin(admin admin)
 {
     DALadminDAL DALadminDAL = new DALadminDAL();
     return DALadminDAL.readAdmin(admin);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            labeldata.Text = (string)Session["UserName"];



            if (!Page.IsPostBack)
            {
                using (SqlConnection con = new SqlConnection(str))
                {
                    admin      admindata = new admin();
                    SqlCommand cmd       = new SqlCommand("select EmpId,Reviewer,UserName,Approver,Password from AddEmployee where Reviewer= '" + Session["UserName"] + "' OR  Approver = '" + Session["UserName"] + "'", con);

                    con.Open();


                    using (SqlDataReader oReader1 = cmd.ExecuteReader())
                    {
                        while (oReader1.Read())
                        {
                            admindata.UserName = oReader1["UserName"].ToString();
                            admindata.Password = oReader1["Password"].ToString();
                            admindata.EmpId    = oReader1["EmpId"].ToString();
                            admindata.Reviewer = oReader1["Reviewer"].ToString();
                            admindata.Approver = oReader1["Approver"].ToString();
                        }
                    }
                    try
                    {
                        if (admindata.Approver == labeldata.Text)
                        {
                            labeldata.Text = (string)Session["Approver"];
                            //Binddropdown();

                            //GridView3.Visible = false;
                            usernamelabel.Visible = false;
                            usernamedata.Visible  = false;
                            reviewerdata.Visible  = false;
                            reviewer.Visible      = false;
                            approverlabel.Visible = false;
                            approver.Visible      = false;
                            list.Visible          = false;
                            distributor.Visible   = false;
                            submit.Visible        = false;
                            testbutton.Visible    = false;
                        }
                        else if (admindata.Reviewer == labeldata.Text)
                        {
                            labeldata.Text = (string)Session["Reviewer"];
                            usernamedatabind();
                            reviewerdatabind();
                            approverdatabind();
                            //GridView3.Visible = false;
                            submit.Visible        = false;
                            usernamelabel.Visible = false;
                            usernamedata.Visible  = false;
                            reviewerdata.Visible  = false;
                            reviewer.Visible      = false;
                            approverlabel.Visible = false;
                            approver.Visible      = false;
                            list.Visible          = false;
                            distributor.Visible   = false;
                            finalsave.Visible     = false;
                        }
                        else
                        {
                            //usernamebind();
                            //reviewerbind();
                            //approverbind();
                            //GridView3.Visible = false;
                            //reviewerdropdown();
                            //approverdropdown();
                            RadioButtonList1.Visible = false;
                            testbutton.Visible       = false;
                            reviewercomments.Visible = false;
                            commentbox.Visible       = false;
                            finalsave.Visible        = false;
                        }
                    }
                    catch (Exception)
                    {
                    }
                    con.Close();
                }



                taskid.Text  = Session["Name"] as String;
                label10.Text = taskid.Text;
            }
            //bindtextvalues(Label10.Text);
        }
Пример #23
0
 public int deleteAdmin(admin admin)
 {
     DALadminDAL DALadminDAL = new DALadminDAL();
     return DALadminDAL.deleteAdmin(admin);
 }
Пример #24
0
 public int insertAdmin(admin admin)
 {
     DALadminDAL DALadminDAL = new DALadminDAL();
     return DALadminDAL.insertAdmin(admin);
 }
Пример #25
0
 public MySqlDataReader checkAdmin(admin admin)
 {
     DALadminDAL DALadminDAL = new DALadminDAL();
     return DALadminDAL.checkAdmin(admin);
 }
Пример #26
0
        public void button1_Click(object sender, EventArgs e)
        {
            ShowQuyenhan();
            try
            {
                SqlConnection Cnn = db._DbContext();
                Cnn.Open();

                string login_in = "Select Count(*) from Accounts Where ID=@acc and Password=@pass";
                Cmd = new SqlCommand(login_in, Cnn);
                Cmd.Parameters.Add(new SqlParameter("@acc", Taikhoan.Text));
                Cmd.Parameters.Add(new SqlParameter("@pass", Matkhau.Text));
                int K = (int)Cmd.ExecuteScalar();
                if (K == 1)
                {
                    if (bientam.Trim() != null)
                    {
                        if (bientam.Trim() == "admin")
                        {
                            admin ad = new admin();
                            this.Visible = false;
                            if ((new admin()).ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                this.Visible = true;
                            }
                            ad.Show();
                            this.Close();
                        }
                        if (bientam.Trim() == "manager")
                        {
                            QLphong ql = new QLphong();
                            this.Visible = false;
                            if ((new QLphong()).ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                this.Visible = true;
                            }
                            ql.Show();
                            this.Close();
                        }
                        if (bientam.Trim() == "salesman")
                        {
                            Thuephong tp = new Thuephong();
                            this.Visible = false;
                            if ((new Thuephong()).ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                this.Visible = true;
                            }
                            tp.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bạn chưa có quyền đăng nhập!" + "\nHệ Thống đang cập nhật... Vui lòng liên hệ Quản Trị Viên!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
                else
                {
                    MessageBox.Show("Đăng nhập thất bại !!!" + "\n Lỗi: Sai tài khoản hoặc mật khẩu ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi kết nối Form 1 ");
            }

            Taikhoan.Text = string.Empty;
            Matkhau.Text  = string.Empty;
        }
Пример #27
0
 public JsonResult UpdataAdmin(admin a)
 {
     return(Json(new AdminBBL().UpdataAdmin(a), JsonRequestBehavior.AllowGet));
 }
Пример #28
0
 public void Update(admin admin)
 {
     this.context.Entry(admin).State = System.Data.Entity.EntityState.Modified;
     this.context.SaveChanges();
 }
Пример #29
0
 public int updateAdmin(admin admin)
 {
     DALadminDAL DALadminDAL = new DALadminDAL();
     return DALadminDAL.updateAdmin(admin);
 }
Пример #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //temporary
            //creator_id=7757276
            string cc_Id   = Request.QueryString["creator_id"];
            string ccEmail = HttpContext.Current.User.Identity.Name;

            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(cc_Id)) //get the creator id from query string
                {
                    int          ccId = Int32.Parse(cc_Id);
                    ComicCreator c    = db.ComicCreators.SingleOrDefault(a => a.CC_Id == ccId);
                    if (c != null) //great querystring
                    {
                        imgProfile.ImageUrl = "~/pic/profile/" + ccId + ".jpg";
                        lbName.Text         = c.CC_NickName;
                        lbEmail.Text        = c.CC_email;
                        lbphone.Text        = c.CC_phone;
                        int counts = (from row in db.Comics
                                      where row.CC_Id == c.CC_Id && row.C_Status == 'V'
                                      select row).Count();
                        lbQuantity.Text = counts.ToString();

                        //button add comic
                        if (!string.IsNullOrEmpty(ccEmail))
                        {
                            ComicCreator current = db.ComicCreators.SingleOrDefault(a => a.CC_email == ccEmail);
                            admin        ad      = db.admins.SingleOrDefault(a => a.A_email == ccEmail);
                            if (current != null && current.CC_Id == ccId)
                            {
                                lvUnverify.Visible  = true;
                                lblUnverify.Visible = true;
                                bntEdit.Visible     = true;
                            }
                            else if (ad != null)
                            {
                                lvUnverify.Visible  = true;
                                lblUnverify.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        Response.Redirect("~/error.aspx?err=The result cant be found");
                        //Error page as the creator id is fake get from query string
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ccEmail))
                    {
                        ComicCreator cc = db.ComicCreators.SingleOrDefault(a => a.CC_email == ccEmail);
                        if (cc != null)
                        {
                            Response.Redirect("~/Profile.aspx?creator_id=" + cc.CC_Id);
                        }
                        else
                        {
                            Response.Redirect("~/error.aspx?err=You didnt have the permission");
                        }
                    }
                    else
                    {
                        Response.Redirect("~/error.aspx?err=The result cant be found");
                    }
                }
                //Will do the looping for the comic to count the quantity
            }
        }
Пример #31
0
 public MySqlDataReader _login(admin admin)
 {
     DALadminDAL DALadminDAL = new DALadminDAL();
     return DALadminDAL._login(admin);
 }
Пример #32
0
 public JsonResult CheckAdmin(admin a)
 {
     return(Json(new AdminBBL().CheckAdmin(a), JsonRequestBehavior.AllowGet));
 }
Пример #33
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            String email   = model.Email.ToString();
            var    request = (HttpWebRequest)WebRequest.Create("http://localhost:18080/21meeseeks-web/rest/authentication");

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            byte[] bytes = Encoding.ASCII.GetBytes("username="******"&password="******"token"].Value = responseMessage;
                    //   Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);

                    //localhost:18080/21meeseeks-web/rest/[email protected]
                    ClientService cs = new ClientService();
                    client        c  = cs.Get(d => d.email.Equals(email));
                    if (c == null)
                    {
                        AdminService aserv = new AdminService();
                        admin        a     = aserv.Get(d => d.email.Equals(email));
                        Session["role"]     = "Admin";
                        Session["id"]       = a.idUser;
                        Session["token"]    = responseMessage;
                        Session["username"] = a.email;
                    }
                    else
                    {
                        Session["role"]     = "Client";
                        Session["id"]       = c.idUser;
                        Session["token"]    = responseMessage;
                        Session["username"] = c.email;
                        Session["logo"]     = c.logo;
                        Session["name"]     = c.clientName;
                    }
                    return(RedirectToAction("Index", "Client", new { area = "" }));
                }
            }
            catch (WebException e)
            {
                ViewBag.message = "Wrong credentials";
                return(View(model));
            }


            /*
             * if (!ModelState.IsValid)
             * {
             *  return View(model);
             * }
             *
             * // This doesn't count login failures towards account lockout
             * // To enable password failures to trigger account lockout, change to shouldLockout: true
             * var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
             * switch (result)
             * {
             *  case SignInStatus.Success:
             *      return RedirectToLocal(returnUrl);
             *  case SignInStatus.LockedOut:
             *      return View("Lockout");
             *  case SignInStatus.RequiresVerification:
             *      return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
             *  case SignInStatus.Failure:
             *  default:
             *      ModelState.AddModelError("", "Invalid login attempt.");
             *      return View(model);
             * }*/
        }
Пример #34
0
        protected void ButPwd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string       email = txtEmail.Text;
                user         m     = db.users.SingleOrDefault(x => x.Email == email);
                readers      c     = db.readers.SingleOrDefault(x => x.R_email == email);
                ComicCreator cr    = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);
                admin        ad    = db.admins.SingleOrDefault(a => a.A_email == email);

                if (m == null)
                {
                    cvNotMatched.IsValid = false;
                }
                else
                {
                    if (c != null)
                    {
                        string pass = Security.GetPass();

                        MailMessage mm = new MailMessage("*****@*****.**", txtEmail.Text);
                        mm.Subject    = "Your password!";
                        mm.Body       = string.Format("Hello :" + m.Email + "<p>This is your new password : <h3>" + pass + "</h3>");
                        mm.IsBodyHtml = true;
                        SmtpClient smtp = new SmtpClient();
                        smtp.Host      = "smtp.gmail.com";
                        smtp.EnableSsl = true;
                        NetworkCredential nc = new NetworkCredential();
                        nc.UserName = "******";
                        nc.Password = "******";
                        smtp.UseDefaultCredentials = true;
                        smtp.Credentials           = nc;
                        smtp.Port = 587;
                        smtp.Send(mm);
                        Labmsg.Text      = "Your password has been sent to " + txtEmail.Text;
                        Labmsg.ForeColor = Color.Green;
                        c.R_hash         = Security.GetHash(pass);
                        db.SubmitChanges();
                    }
                    else if (cr != null)
                    {
                        string pass = Security.GetPass();

                        MailMessage mm = new MailMessage("*****@*****.**", txtEmail.Text);
                        mm.Subject    = "Your password!";
                        mm.Body       = string.Format("Hello :" + m.Email + "<p>This is your new password : <h3>" + pass + "</h3>");
                        mm.IsBodyHtml = true;
                        SmtpClient smtp = new SmtpClient();
                        smtp.Host      = "smtp.gmail.com";
                        smtp.EnableSsl = true;
                        NetworkCredential nc = new NetworkCredential();
                        nc.UserName = "******";
                        nc.Password = "******";
                        smtp.UseDefaultCredentials = true;
                        smtp.Credentials           = nc;
                        smtp.Port = 587;
                        smtp.Send(mm);
                        Labmsg.Text      = "Your password has been sent to " + txtEmail.Text;
                        Labmsg.ForeColor = Color.Green;
                        cr.CC_hash       = Security.GetHash(pass);
                        db.SubmitChanges();
                    }
                    else if (ad != null)
                    {
                        string pass = Security.GetPass();

                        MailMessage mm = new MailMessage("*****@*****.**", txtEmail.Text);
                        mm.Subject    = "Your password!";
                        mm.Body       = string.Format("Hello :" + m.Email + "<p>This is your new password : <h3>" + pass + "</h3>");
                        mm.IsBodyHtml = true;
                        SmtpClient smtp = new SmtpClient();
                        smtp.Host      = "smtp.gmail.com";
                        smtp.EnableSsl = true;
                        NetworkCredential nc = new NetworkCredential();
                        nc.UserName = "******";
                        nc.Password = "******";
                        smtp.UseDefaultCredentials = true;
                        smtp.Credentials           = nc;
                        smtp.Port = 587;
                        smtp.Send(mm);
                        Labmsg.Text      = "Your password has been sent to " + txtEmail.Text;
                        Labmsg.ForeColor = Color.Green;
                        ad.A_hash        = Security.GetHash(pass);
                        db.SubmitChanges();
                    }
                    else
                    {
                        Labmsg.Text      = "The account is not register yet";
                        Labmsg.ForeColor = Color.Red;
                    }
                }
            }
        }
Пример #35
0
 public bool adminlogin(admin ad)
 {
     db = new Cusdb();
     return(db.adminlogin(ad));
 }
Пример #36
0
 public admin Registered(admin admin) => user_Repostory.Registered(admin);
Пример #37
0
 partial void Insertadmin(admin instance);
Пример #38
0
        public ActionResult addshop(admin pro, int purchasedAmount)
        {
            Shop shop = new Shop();

            var checkNo = db.lasts.Where(a => a.no == 1).FirstOrDefault();  //runเลข

            var    A = checkNo.lastS.Value;
            String B = Convert.ToString(A);

            if (A < 10)
            {
                B = "S000" + B;
            }
            else if (A < 100)
            {
                B = "S00" + B;
            }
            else if (A < 1000)
            {
                B = "S0" + B;
            }
            else if (A < 10000)
            {
                B = "S" + B;
            }


            var checkUP = db.lasts.Where(a => a.no == 1).FirstOrDefault();

            checkUP.lastS = A + 1;
            db.SaveChanges();

            shop.SID             = B;
            shop.Name            = Request.Form["nameS"];
            shop.S_name          = Request.Form["name"];
            shop.S_lastname      = Request.Form["lastname"];
            shop.S_tel           = Request.Form["tel"];
            shop.purchasedAmount = purchasedAmount;
            shop.S_pass          = Request.Form["Pass"];
            shop.S_no            = Request.Form["no"];
            shop.S_subD          = Request.Form["subD"];
            shop.S_sub           = Request.Form["sub"];
            shop.S_ProV          = Request.Form["ProV"];
            shop.state           = 1;

            if (Request.Form["Pass"] == Request.Form["Pass2"])
            {
                if (ModelState.IsValid)
                {
                    db.Shops.Add(shop);
                    db.SaveChanges();
                    ViewBag.Message = "บันทึกสำเร็จ ชื่อผู้ใช้ของคุณคือ " + B;
                }
            }
            else
            {
                ViewBag.Message2 = "รหัสผ่านไม่ตรงกัน";
            }

            return(View());
        }
Пример #39
0
        private void signin_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(usernametext.Text) || String.IsNullOrWhiteSpace(passwordtext.Text))
            {
                if (String.IsNullOrWhiteSpace(usernametext.Text))
                {
                    invuser.Visible = true;
                }
                else
                {
                    invuser.Visible = false;
                }

                if (String.IsNullOrWhiteSpace(passwordtext.Text))
                {
                    invpass.Visible = true;
                }
                else
                {
                    invpass.Visible = false;
                }
            }

            else
            {
                ac = new Access();

                if (usernametext.Text[0] == 'A' && usernametext.Text[1] == '-')
                {
                    //  MessageBox.Show("kl");
                    admin ad = new admin();
                    ad.username = usernametext.Text;
                    ad.password = passwordtext.Text;
                    if (ac.adminlogin(ad))
                    {
                        invpass.Visible = false;
                        invuser.Visible = false;
                        logged          = true;
                        loginb.Text     = ad.username;

                        this.Hide();
                        AdminPanel ap = new AdminPanel();
                        ap.ShowDialog();
                    }
                    else
                    {
                        invup.Visible = true;
                        //MessageBox.Show("Nope");
                    }
                }
                else if (usernametext.Text[0] == 'S' && usernametext.Text[1] == '-')
                {
                    st          = new Staff();
                    st.username = usernametext.Text;
                    st.password = passwordtext.Text;
                    object ob = ac.stafflogin(st);
                    if (ob.GetType() == typeof(Staff))
                    {
                        invpass.Visible = false;
                        invuser.Visible = false;
                        //logged = true;
                        loginb.Text = us.username;
                        st          = (Staff)ob;
                        //ac.genorder(us);
                        this.Hide();

                        /*StaffPanel sp = new StaffPanel(st);
                         * sp.ShowDialog();
                         */
                        Staffmain sm = new Staffmain(st);
                        sm.ShowDialog();
                        //MessageBox.Show("Success!!");
                    }
                    else
                    {
                        invup.Visible = true;
                        //MessageBox.Show("Nope");
                    }
                }
                else
                {
                    us.username = usernametext.Text;
                    us.password = passwordtext.Text;
                    object ob = ac.login(us);
                    if (ob.GetType() == typeof(user))
                    {
                        invpass.Visible = false;
                        invuser.Visible = false;
                        logged          = true;
                        loginb.Text     = us.username;
                        us = (user)ob;
                        ac.genorder(us);
                        this.Hide();

                        //MessageBox.Show("Success!!");
                    }
                    else
                    {
                        invup.Visible = true;
                        //MessageBox.Show("Nope");
                    }
                }
            }
        }
Пример #40
0
 public void Insert(admin admin)
 {
     throw new NotImplementedException();
 }
Пример #41
0
 public void SetSessionAdmin(admin obj)
 {
     Session[Shared.Constants.SESSION_ADMIN] = obj;
 }
 public MockGitHubRepository(bool admin, bool canPush, bool canPull) => Permissions = new RepositoryPermissions(admin, admin, canPush, false, canPull);
Пример #43
0
 partial void Insertadmin(admin instance);
Пример #44
0
 public void Create(admin admin)
 {
     this.context.Admins.Add(admin);
     this.context.SaveChanges();
 }
Пример #45
0
 partial void Updateadmin(admin instance);
Пример #46
0
 public void Delete(admin admin)
 {
     this.context.Admins.Remove(admin);
     this.context.SaveChanges();
 }
Пример #47
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, PhoneNumber = model.Phone
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    await UserManager.AddToRoleAsync(user.Id, model.UserRoles);

                    if (model.UserRoles == "doctor")
                    {
                        doctor doctors = new doctor();

                        doctors.name        = model.Name;
                        doctors.homeAddress = model.Address;
                        doctors.userId      = user.Id;
                        doctors.phone       = model.Phone;
                        doctors.gender      = model.Gender;

                        //var type = model.photos.ContentType; // Check image type ryan logic
                        //photoService.UploadDoctorPictureFILE(model.photos.InputStream, type); // Upload patient pictures to database

                        List <WorkSchedule> workSch = new List <WorkSchedule>();
                        var WorkSch1 = (new WorkSchedule {
                            Day = "Monday", DoctorID = doctors.userId, IsAvailable = true
                        });
                        var WorkSch2 = (new WorkSchedule {
                            Day = "Tuesday", DoctorID = doctors.userId, IsAvailable = true
                        });
                        var WorkSch3 = (new WorkSchedule {
                            Day = "Wednesday", DoctorID = doctors.userId, IsAvailable = true
                        });
                        var WorkSch4 = (new WorkSchedule {
                            Day = "Thursday", DoctorID = doctors.userId, IsAvailable = true
                        });
                        var WorkSch5 = (new WorkSchedule {
                            Day = "Friday", DoctorID = doctors.userId, IsAvailable = true
                        });
                        var WorkSch6 = (new WorkSchedule {
                            Day = "Saturday", DoctorID = doctors.userId, IsAvailable = true
                        });
                        var WorkSch7 = (new WorkSchedule {
                            Day = "Sunday", DoctorID = doctors.userId, IsAvailable = true
                        });

                        workSch.Add(WorkSch1);
                        workSch.Add(WorkSch2);
                        workSch.Add(WorkSch3);
                        workSch.Add(WorkSch4);
                        workSch.Add(WorkSch5);
                        workSch.Add(WorkSch6);
                        workSch.Add(WorkSch7);
                        foreach (var item in workSch)
                        {
                            db.WorkSchedules.Add(item);
                        }
                        db.doctors.Add(doctors);
                        db.SaveChanges();
                    }
                    if (model.UserRoles == "admin")
                    {
                        admin admins = new admin();
                        admins.name    = model.Name;
                        admins.address = model.Address;
                        admins.userId  = user.Id;
                        admins.phone   = model.Phone;
                        admins.gender  = model.Gender;
                        db.admins.Add(admins);
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                ViewBag.userRole = new SelectList(context.Roles.Where(u => !u.Name.Contains("Admin"))
                                                  .ToList(), "Name", "Name");
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #48
0
        public void SendAdminInsert(string ID, string Name, string Surname, string Username, string Password)
        {
            admin adminInsert = new admin(ID, Name, Surname, Username, Password);

            access.AdminAdd(adminInsert);
        }
Пример #49
0
 partial void Deleteadmin(admin instance);
Пример #50
0
 partial void Deleteadmin(admin instance);
Пример #51
0
        protected void Page_Load(object sender, EventArgs e)
        {
            username.Text = (string)Session["UserName"];


            using (SqlConnection con = new SqlConnection(str))
            {
                admin      admindata = new admin();
                SqlCommand cmd       = new SqlCommand("select EmpId,Reviewer,UserName,Approver,Password from AddEmployee where Reviewer= '" + Session["UserName"] + "' OR  Approver = '" + Session["UserName"] + "'", con);

                con.Open();


                using (SqlDataReader oReader1 = cmd.ExecuteReader())
                {
                    while (oReader1.Read())
                    {
                        admindata.UserName = oReader1["UserName"].ToString();
                        admindata.Password = oReader1["Password"].ToString();
                        admindata.EmpId    = oReader1["EmpId"].ToString();
                        admindata.Reviewer = oReader1["Reviewer"].ToString();
                        admindata.Approver = oReader1["Approver"].ToString();
                    }
                }
                try
                {
                    if (admindata.Approver == username.Text)
                    {
                        username.Text         = (string)Session["UserName"];
                        viewstatus.Visible    = false;
                        bull1.Visible         = false;
                        BulletedList2.Visible = false;
                        //GridView1.Visible = false;

                        string Reviewer = (string)Session["UserName"];
                        sql2.SelectParameters["Approver"].DefaultValue = Reviewer;
                        SqlCommand comm = new SqlCommand("select count(distinct TaskId) from Inboxdetails where Approver= '" + username.Text + "' and  Reviewerstatus='ACCEPTED' and Status='PENDING' ", con);
                        Button1.Text = "Inbox(" + comm.ExecuteScalar().ToString() + ")";
                    }
                    else if (admindata.Reviewer == username.Text)
                    {
                        username.Text = (string)Session["UserName"];
                        SqlCommand command = new SqlCommand("select count(distinct TaskId) from Inboxdetails where Reviewer= '" + username.Text + "' and  Reviewerstatus='PENDING' ", con);
                        Button1.Text = "Inbox(" + command.ExecuteScalar().ToString() + ")";
                        string Reviewer = (string)Session["UserName"];
                        sql1.SelectParameters["Reviewer"].DefaultValue = Reviewer;
                        viewstatus.Visible    = false;
                        BulletedList1.Visible = false;
                        BulletedList2.Visible = false;
                    }
                    else
                    {
                        //GridView1.Visible = false;
                        username.Text         = (string)Session["UserName"];
                        BulletedList1.Visible = false;
                        SqlCommand command = new SqlCommand("select count(distinct TaskId) from Inboxdetails where EmployeeName= '" + username.Text + "' and  Reviewerstatus='REJECTED' or   Status='REJECTED' ", con);
                        Button1.Text  = "Inbox(" + command.ExecuteScalar().ToString() + ")";
                        bull1.Visible = false;
                        string Reviewer = (string)Session["UserName"];
                        sql3.SelectParameters["UserName"].DefaultValue = Reviewer;
                    }
                }
                catch (Exception)
                {
                }
                con.Close();
            }
        }
Пример #52
0
        public JsonResult Update(admin p)
        {
            try
            {
                if (p.name.Length < 3 || p.name.Length > 30 || p.password.Length < 8 || p.password.Length > 25)
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
                admin oldAdmin = db.admins.FirstOrDefault(d => d.name == User.Identity.Name);
                ((IObjectContextAdapter)db).ObjectContext.Detach(oldAdmin);
                string oldPassword = oldAdmin.password;
                p.dateOfJoin = oldAdmin.dateOfJoin;
                p.lastPatientComplainsVieweddate = oldAdmin.lastPatientComplainsVieweddate;
                p.lastDoctorComplainsViewedDate  = oldAdmin.lastDoctorComplainsViewedDate;
                p.lastGeneralComplainViewedDate  = oldAdmin.lastGeneralComplainViewedDate;
                db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                MembershipUser adminMember = Membership.GetUser();
                adminMember.Email = p.mail;
                if (p.password != oldPassword)
                {
                    var generatedPass = adminMember.ResetPassword();
                    adminMember.ChangePassword(generatedPass, p.password);
                }
                if (p.name != oldAdmin.name)
                {
                    Guid         userID = (Guid)adminMember.ProviderUserKey;
                    aspnet_Users user   = db.aspnet_Users.Where(us => us.UserId == userID).FirstOrDefault();
                    user.UserName        = p.name;
                    user.LoweredUserName = p.name.ToLower();
                }
                Membership.UpdateUser(adminMember);
                db.SaveChanges();;

                if (p.name != User.Identity.Name || p.password != oldPassword)
                {
                    FormsAuthentication.SignOut();
                    Session.Abandon();
                    var    oldAuthCookie = Request.Cookies[FormsAuthentication.FormsCookieName];//my authenticated cookie
                    var    isPersistent  = FormsAuthentication.Decrypt(oldAuthCookie.Value).IsPersistent;
                    string userImage     = FormsAuthentication.Decrypt(oldAuthCookie.Value).UserData;
                    FormsAuthenticationTicket oldticket = FormsAuthentication.Decrypt(oldAuthCookie.Value);
                    string oldCookieName = oldticket.Name;
                    var    cookie        = FormsAuthentication.GetAuthCookie(p.name, isPersistent);
                    var    currentticket = FormsAuthentication.Decrypt(cookie.Value);
                    var    newticket     = new FormsAuthenticationTicket
                                               (oldticket.Version, currentticket.Name, oldticket.IssueDate, oldticket.Expiration, oldticket.IsPersistent, userImage, "/admin");
                    cookie.Value = FormsAuthentication.Encrypt(newticket);
                    Request.Cookies.Remove(oldCookieName);
                    if (isPersistent)
                    {
                        cookie.Expires = newticket.Expiration;
                    }
                    cookie.Path = newticket.CookiePath;
                    Response.Cookies.Add(cookie);
                }
                return(Json(new { mess = "your profile is updated successfully", result = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Пример #53
0
 partial void Updateadmin(admin instance);