Exemplo n.º 1
0
        void LoadData()
        {
            int idAccount = Convert.ToInt32(Request.Params["idAccount"].ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            User        acc             = db.Users.FirstOrDefault(x => x.idAccount == idAccount);
            User_Detail acc_detail      = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);

            txtusername.Text = acc.username;
            txtFullname.Text = acc_detail.fullname;
            DateTime date      = Convert.ToDateTime(acc_detail.DOB);
            string   formatted = date.ToString("yyyy-MM-dd");

            txtDOB.Text     = formatted;
            txtAddress.Text = acc_detail.Address;
            txtEmail.Text   = acc_detail.Email;
            img.ImageUrl    = "img/customer/" + acc_detail.imgAccount;
            List <ListFavourite> listidFavourties = db.ListFavourites.Where(x => x.idAccount == idAccount).ToList();
            List <Comic>         viewList         = new List <Comic>();

            foreach (ListFavourite items in listidFavourties)
            {
                int   idComic = Convert.ToInt32(items.idComic.ToString());
                Comic comic   = db.Comics.FirstOrDefault(x => x.idComic == idComic);
                viewList.Add(comic);
            }
            dgvListFavourite.DataSource = viewList;
            dgvListFavourite.DataBind();
        }
Exemplo n.º 2
0
        protected void btnSubmitUpdatePassword_Click(object sender, EventArgs e)
        {
            string taikhoan             = txtusernamemodel.Text;
            string matkhaucu            = getMd5Hash(txtoldpasswordmodel.Text);
            string matkhaumoi           = txtnewpasswordmodel.Text;
            string rematkhaumoi         = txtrenewpasswordmodel.Text;
            Managerment_PageEntities db = new Managerment_PageEntities();
            Account acc = db.Accounts.FirstOrDefault(x => x.username == taikhoan);

            if (matkhaucu.Equals(acc.password.ToString()))
            {
                if (matkhaumoi.Equals(rematkhaumoi))
                {
                    acc.password = getMd5Hash(matkhaumoi);
                    db.SaveChanges();
                    lbError.Text = "Đổi mật khẩu thành công!";
                    XoaThongTinModel();
                }
                else
                {
                    lbError.Text = "Mật khẩu mới không khớp nhau!";
                    XoaThongTinModel();
                }
            }
            else
            {
                lbError.Text = "Mật khẩu cũ không đúng!";
                XoaThongTinModel();
            }
        }
Exemplo n.º 3
0
 protected void btnEditAccount_Click(object sender, EventArgs e)
 {
     try
     {
         int    idAccount            = Convert.ToInt32(Request.Params["idAccount"].ToString());
         string fullname             = txtFullname.Text;
         string DOB                  = txtDOB.Text;
         string Address              = txtAddress.Text;
         string Email                = txtEmail.Text;
         Managerment_PageEntities db = new Managerment_PageEntities();
         User_Detail user_detail     = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);
         user_detail.fullname = fullname;
         user_detail.DOB      = Convert.ToDateTime(DOB);
         user_detail.Address  = Address;
         user_detail.Email    = Email;
         db.SaveChanges();
         lblNotice.Text = "Đã Cập nhật thông tin thành công!";
         LoadData();
     }
     catch
     {
         lblNotice.Text = "Thất Bại!";
         LoadData();
     }
 }
Exemplo n.º 4
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            Managerment_PageEntities db = new Managerment_PageEntities();
            string      sTenFile;
            int         idAccount     = Convert.ToInt32(Request.Params["idAccount"].ToString());
            User_Detail getOldNameImg = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);
            string      imgAccountOld = getOldNameImg.imgAccount.ToString();

            if (imgAccountOld.Equals("default-avatar.jpg") == false)
            {
                string filePath = MapPath("~/img/customer/" + imgAccountOld);
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
            //Tách lấy tên tập tin
            sTenFile = FileUpload1.FileName;
            //Thực hiện chép tập tin lên thư mục Upload
            FileUpload1.SaveAs(MapPath("~/img/customer/" + sTenFile));
            lblNotice.Text = "Đã upload thành công";
            User_Detail acc_detail = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);

            acc_detail.imgAccount = sTenFile;
            db.SaveChanges();
            LoadData();
        }
        protected void imbLogin_Click(object sender, ImageClickEventArgs e)
        {
            if (txtName.Text != "" && txtPass.Text != "")
            {
                string taikhoan             = txtName.Text;
                string matkhau              = getMd5Hash(txtPass.Text);
                Managerment_PageEntities db = new Managerment_PageEntities();
                int check = db.Users.Count(x => x.username == taikhoan && x.password == matkhau);

                if (check == 1)
                {
                    User        acc         = db.Users.FirstOrDefault(x => x.username == taikhoan);
                    int         idAccount   = Convert.ToInt32(acc.idAccount.ToString());
                    User_Detail acc_detail  = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);
                    Boolean     checkStatus = Convert.ToBoolean(acc_detail.status.ToString());
                    if (checkStatus == true)
                    {
                        Session["idKhachHang"] = idAccount;
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        txtError.Text = "Tài khoản của bạn đã bị Vô hiệu hóa!";
                    }
                }
                else
                {
                    txtError.Text = "Tài khoản và mật khẩu sai!";
                }
            }
            else
            {
                lbThongBao.Text = "Tên đăng nhập hoặc mật khẩu trống!";
            }
        }
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            string username             = txtusername.Text;
            string password             = getMd5Hash(txtpassword.Text);
            string fullname             = txtFullname.Text;
            string DOB                  = txtDOB.Text;
            string Address              = txtAddress.Text;
            string Email                = txtEmail.Text;
            Managerment_PageEntities db = new Managerment_PageEntities();
            User newUser                = new User();

            newUser.username = username;
            newUser.password = password;
            db.Users.Add(newUser);
            db.SaveChanges();
            User        acc            = db.Users.FirstOrDefault(x => x.username == username);
            int         idAccount      = acc.idAccount;
            User_Detail newuser_Detail = new User_Detail();

            newuser_Detail.idAccount  = idAccount;
            newuser_Detail.fullname   = fullname;
            newuser_Detail.DOB        = Convert.ToDateTime(DOB);
            newuser_Detail.Address    = Address;
            newuser_Detail.Email      = Email;
            newuser_Detail.status     = false;
            newuser_Detail.imgAccount = "default-avatar.jpg";
            db.User_Detail.Add(newuser_Detail);
            db.SaveChanges();
            LoadData();
        }
        void LoadData()
        {
            Managerment_PageEntities db   = new Managerment_PageEntities();
            List <User_Detail>       data = db.User_Detail.ToList <User_Detail>();

            dgvUser.DataSource = data;
            dgvUser.DataBind();
        }
Exemplo n.º 8
0
        void LoadData()
        {
            Managerment_PageEntities db   = new Managerment_PageEntities();
            List <Account_Detail>    data = db.Account_Detail.ToList <Account_Detail>();

            dgvTaiKhoan.DataSource = data;
            dgvTaiKhoan.DataBind();
        }
        void LoadData()
        {
            Managerment_PageEntities db   = new Managerment_PageEntities();
            List <Comic>             data = db.Comics.ToList <Comic>();

            dgvComic.DataSource = data;
            dgvComic.DataBind();
            getNameTypeComic();
        }
        protected void btnResetContent_Click(object sender, EventArgs e)
        {
            string idChuong             = Request.Params["idChuong"].ToString();
            Managerment_PageEntities db = new Managerment_PageEntities();
            Chuong obj = db.Chuongs.FirstOrDefault(x => x.idChuong.ToString() == idChuong.ToString());

            txtTenChuong.Text = obj.tenChuong.ToString();
            txtContent.Text   = obj.content.ToString();
        }
        void GetData()
        {
            int idChuong = Convert.ToInt32(Request.Params["idChuong"].ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            Chuong obj = db.Chuongs.FirstOrDefault(x => x.idChuong == idChuong);

            txtTenChuong.Text = obj.tenChuong.ToString();
            txtContent.Text   = obj.content.ToString();
        }
        protected void btnDeleteComic_Command(object sender, CommandEventArgs e)
        {
            int idComic = int.Parse(e.CommandArgument.ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            Comic obj = db.Comics.FirstOrDefault(x => x.idComic == idComic);

            db.Comics.Remove(obj);
            db.SaveChanges();
            LoadData();
        }
Exemplo n.º 13
0
        protected void btnProfile_Click(object sender, EventArgs e)
        {
            string username             = Session["username"].ToString();
            Managerment_PageEntities db = new Managerment_PageEntities();
            Account obj       = db.Accounts.FirstOrDefault(x => x.username == username);
            int     idAccount = obj.idAccount;
            string  url       = "Profile.aspx?idAccount=" + idAccount;

            Response.Redirect(url);
        }
        protected void btnDelete_Command(object sender, CommandEventArgs e)
        {
            int idChuong = Convert.ToInt32(e.CommandArgument.ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            Chuong obj = db.Chuongs.FirstOrDefault(x => x.idChuong == idChuong);

            db.Chuongs.Remove(obj);
            db.SaveChanges();
            LoadData();
            getNameTypeComic();
        }
Exemplo n.º 15
0
        void LoadData()
        {
            string     query = "exec TinhTiLeTaiKhoan";
            SqlCommand cmd   = new SqlCommand(query, conn);

            conn.Open();
            string ketqua = cmd.ExecuteScalar().ToString();

            conn.Close();
            txtstatus.Text = ketqua + "%";
            Label1.Text    = "";
            Label1.Text   += "<div class='progress-bar bg-info' role='progressbar' runat='server' style='width:" + ketqua + "%; height: 100%;' aria-valuenow='" + ketqua + "' aria-valuemin='0' aria-valuemax='100'></div>";
            string     queryTiLETrang = "exec TinhTiLeComicActive";
            SqlCommand cmd2           = new SqlCommand(queryTiLETrang, conn);

            conn.Open();
            float codeStatusTrang = float.Parse(cmd2.ExecuteScalar().ToString());

            conn.Close();
            Label2.Text = codeStatusTrang + "%";
            Label3.Text = "<div class='progress-bar bg-info' role='progressbar' runat='server' style='width:" + codeStatusTrang + "%; height: 100%;' aria-valuenow='" + codeStatusTrang + "' aria-valuemin='0' aria-valuemax='100'></div>";
            Managerment_PageEntities db = new Managerment_PageEntities();
            int countComic = db.Comics.Count();

            txtTotalComic.Text = countComic.ToString();
            int countChapter = db.Chuongs.Count();

            txtTotalChapter.Text = countChapter.ToString();
            int countAccount = db.Accounts.Count();

            txtTotalAccount.Text = countAccount.ToString();
            int countUser = db.Users.Count();

            txtTotalUser.Text = countUser.ToString();
            string     queryChuong = "exec TinhTiLeChuongActive";
            SqlCommand cmd3        = new SqlCommand(queryChuong, conn);

            conn.Open();
            string ketquaChuong = cmd3.ExecuteScalar().ToString();

            conn.Close();
            txtStatusChuong.Text = ketquaChuong + "%";
            Label4.Text          = "<div class='progress-bar bg-info' role='progressbar' runat='server' style='width:" + ketquaChuong + "%; height: 100%;' aria-valuenow='" + ketquaChuong + "' aria-valuemin='0' aria-valuemax='100'></div>";
            string     queryUser = "******";
            SqlCommand cmd4      = new SqlCommand(queryUser, conn);

            conn.Open();
            string ketquaUser = cmd4.ExecuteScalar().ToString();

            conn.Close();
            lbPercentUser.Text    = ketquaUser + "%";
            lbPercentUserBar.Text = "<div class='progress-bar bg-info' role='progressbar' runat='server' style='width:" + ketquaUser + "%; height: 100%;' aria-valuenow='" + ketquaUser + "' aria-valuemin='0' aria-valuemax='100'></div>";
        }
        protected void btnResetPassword_Command(object sender, CommandEventArgs e)
        {
            string passwordmacdinh      = "admin123";
            string password             = getMd5Hash(passwordmacdinh);
            int    idAccount            = int.Parse(e.CommandArgument.ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            User acc = db.Users.FirstOrDefault(x => x.idAccount == idAccount);

            acc.password = password;
            db.SaveChanges();
            LoadData();
        }
Exemplo n.º 17
0
 public string getURLAvatar(object idComic)
 {
     try
     {
         Managerment_PageEntities db = new Managerment_PageEntities();
         Comic obj = db.Comics.FirstOrDefault(x => x.idComic.ToString() == idComic.ToString());
         return("./img/comic/" + obj.imgComic);
     }
     catch
     {
         return("./img/comic/default-avatar.jpg");
     }
 }
 public string getusernameUser(object idAccount)
 {
     try
     {
         Managerment_PageEntities db = new Managerment_PageEntities();
         User obj = db.Users.FirstOrDefault(x => x.idAccount.ToString() == idAccount.ToString());
         return(obj.username);
     }
     catch
     {
         return("Đã xóa");
     }
 }
 public string getnameComic(object idComic)
 {
     try
     {
         Managerment_PageEntities db = new Managerment_PageEntities();
         Comic obj = db.Comics.FirstOrDefault(x => x.idComic.ToString() == idComic.ToString());
         return(obj.nameComic);
     }
     catch
     {
         return("Đã xóa");
     }
 }
        protected void btnXoa_Command(object sender, CommandEventArgs e)
        {
            int idAccount = int.Parse(e.CommandArgument.ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            User_Detail obj             = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);

            db.User_Detail.Remove(obj);
            db.SaveChanges();
            User objAcc = db.Users.FirstOrDefault(x => x.idAccount == idAccount);

            db.Users.Remove(objAcc);
            db.SaveChanges();
            LoadData();
        }
 public void getNameTypeComic()
 {
     try
     {
         Managerment_PageEntities db            = new Managerment_PageEntities();
         List <Type_Comic>        dataTypeComic = db.Type_Comic.ToList();
         cmbNameType.DataSource     = dataTypeComic;
         cmbNameType.DataTextField  = "nameTypeComic";
         cmbNameType.DataValueField = "idTypeComic";
         cmbNameType.DataBind();
     }
     catch
     {
     }
 }
        protected void btnSaveContent_Click(object sender, EventArgs e)
        {
            int    idChuong             = Convert.ToInt32(Request.Params["idChuong"]);
            string txtContentUpdate     = txtContent.Text;
            string txttenChuong         = txtTenChuong.Text;
            Managerment_PageEntities db = new Managerment_PageEntities();
            Chuong obj = db.Chuongs.FirstOrDefault(x => x.idChuong == idChuong);

            obj.tenChuong = txttenChuong;
            obj.content   = txtContentUpdate;
            db.SaveChanges();
            Status.Text = "Cập nhật thành công!";

            /*Thread.Sleep(2000);
             * Response.Redirect("DS_Truyen.aspx");*/
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string sTenFile;
            int    idComic = Convert.ToInt32(Request.Params["idComic"].ToString());

            sTenFile = FileUpload1.FileName;
            FileUpload1.SaveAs(MapPath("~/img/Comic/" + sTenFile));
            lblNotice.Text = "Đã upload thành công";
            Managerment_PageEntities db = new Managerment_PageEntities();
            Comic obj = db.Comics.FirstOrDefault(x => x.idComic == idComic);

            obj.imgComic = sTenFile;
            db.SaveChanges();
            LoadData();
            getNameTypeComic();
        }
        protected void CreateChuong_Click(object sender, EventArgs e)
        {
            int    idComic              = Convert.ToInt32(Request.Params["idComic"]);
            string tenChuong            = txtTenChuong.Text;
            string content              = txtContent.Text;
            Managerment_PageEntities db = new Managerment_PageEntities();
            Chuong newChuong            = new Chuong();

            newChuong.idComic   = idComic;
            newChuong.tenChuong = tenChuong;
            newChuong.content   = content;
            db.Chuongs.Add(newChuong);
            db.SaveChanges();
            LoadData();
            getNameTypeComic();
        }
        protected void btnUpdateComicDetail_Command(object sender, CommandEventArgs e)
        {
            int    idComic              = Convert.ToInt32(Request.Params["idComic"]);
            string nameComic            = txtnameComic.Text;
            int    typeComic            = Convert.ToInt32(cmbNameType.SelectedValue);
            string decription           = txtDecription.Text;
            string author               = txtAuthor.Text;
            Managerment_PageEntities db = new Managerment_PageEntities();
            Comic obj = db.Comics.FirstOrDefault(x => x.idComic == idComic);

            obj.nameComic   = nameComic;
            obj.idTypeComic = typeComic;
            obj.decription  = decription;
            obj.author      = author;
            db.SaveChanges();
            LoadData();
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string taikhoan = txtusername.Text;
            string matkhau  = getMd5Hash(txtpassword.Text);

            if (taikhoan.Length == 0 && matkhau.Length == 0)
            {
                txtError.Text = "Vui lòng nhập tài khoản và mật khẩu!";
            }
            else if (taikhoan.Length == 0)
            {
                txtError.Text = "Vui lòng nhập tài khoản!";
            }
            else if (matkhau.Length == 0)
            {
                txtError.Text = "Vui lòng nhập mật khẩu!";
            }
            else
            {
                Managerment_PageEntities db = new Managerment_PageEntities();
                int            check        = db.Accounts.Count(x => x.username == taikhoan && x.password == matkhau);
                Account        acc          = db.Accounts.FirstOrDefault(x => x.username == taikhoan);
                int            idAccount    = Convert.ToInt32(acc.idAccount.ToString());
                Account_Detail acc_detail   = db.Account_Detail.FirstOrDefault(x => x.idAccount == idAccount);
                Boolean        checkStatus  = Convert.ToBoolean(acc_detail.status.ToString());

                if (check == 1)
                {
                    if (checkStatus == true)
                    {
                        Session["username"] = taikhoan;
                        Response.Redirect("Index_ManagermentPage.aspx");
                    }
                    else
                    {
                        txtError.Text = "Tài khoản của bạn đã bị Vô hiệu hóa!";
                    }
                }
                else
                {
                    txtError.Text = "Tài khoản và mật khẩu sai!";
                }
            }
        }
Exemplo n.º 27
0
 public string getStatus(object idComic)
 {
     try
     {
         Managerment_PageEntities db = new Managerment_PageEntities();
         Comic obj = db.Comics.FirstOrDefault(x => x.idComic.ToString() == idComic.ToString());
         if (obj.status == true)
         {
             return("Kích Hoạt");
         }
         else
         {
             return("Vô Hiệu Hóa");
         }
     }
     catch
     {
         return("");
     }
 }
        protected void btnUpdateStatus_Command(object sender, CommandEventArgs e)
        {
            int idComic = int.Parse(e.CommandArgument.ToString());
            Managerment_PageEntities db = new Managerment_PageEntities();
            Chuong  chuong            = db.Chuongs.FirstOrDefault(x => x.idComic == idComic);
            Boolean status            = Convert.ToBoolean(chuong.status.ToString());
            Boolean statusafterupdate = true;

            if (status == true)
            {
                statusafterupdate = false;
            }
            else
            {
                statusafterupdate = true;
            }
            chuong.status = statusafterupdate;
            db.SaveChanges();
            LoadData();
        }
        protected void btnUpdateStatus_Command(object sender, CommandEventArgs e)
        {
            int idAccount = int.Parse(e.CommandArgument.ToString());
            Managerment_PageEntities db   = new Managerment_PageEntities();
            User_Detail acc_detail        = db.User_Detail.FirstOrDefault(x => x.idAccount == idAccount);
            Boolean     status            = Convert.ToBoolean(acc_detail.status.ToString());
            Boolean     statusafterupdate = true;

            if (status == true)
            {
                statusafterupdate = false;
            }
            else
            {
                statusafterupdate = true;
            }
            acc_detail.status = statusafterupdate;
            db.SaveChanges();
            LoadData();
        }
 public string getStatus(object idComic)
 {
     try
     {
         Managerment_PageEntities db = new Managerment_PageEntities();
         Comic obj = db.Comics.FirstOrDefault(x => x.idComic.ToString() == idComic.ToString());
         if (obj.status == true)
         {
             return("Đang kích hoạt!");
         }
         else
         {
             return("Vô hiệu hóa!");
         }
     }
     catch
     {
         return("Không có!");
     }
 }