예제 #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string       email = HttpContext.Current.User.Identity.Name;
            ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
            string       cid   = Request.QueryString["cId"];

            if (f != null)
            {
                if (Int32.TryParse(cid, out int o))
                {
                    Comic c = db.Comics.SingleOrDefault(a => a.C_Id == o && a.CC_Id == f.CC_Id);
                    if (c != null)
                    {
                        c.C_CantViewable = true;
                        db.SubmitChanges();
                        Response.Redirect("~/Profile.aspx?creator_id=" + f.CC_Id);
                    }
                    else //other comic creator delete the files
                    {
                        Response.Redirect("~/error.aspx?err=You didnt have permission");
                    }
                }
                else
                {
                    Response.Redirect("~/error.aspx?err=The result cant be found");
                    //Error due to didnt have comic id in query string
                }
            }
            else //Not the comic creator
            {
                Response.Redirect("~/error.aspx?err=You didnt have permission");
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string email = HttpContext.Current.User.Identity.Name;
            user   u     = db.users.SingleOrDefault(a => a.Email == email);

            if (u != null)
            {
                if (u.Role == "Customer")
                {
                    readers r = db.readers.SingleOrDefault(a => a.R_email == u.Email);
                    imgProfile.Visible  = true;
                    imgProfile.ImageUrl = "~/pic/profile/" + r.R_Id + ".jpg";
                }
                else if (u.Role == "admin")
                {
                    admin r = db.admins.SingleOrDefault(a => a.A_email == u.Email);
                    imgProfile.Visible  = true;
                    imgProfile.ImageUrl = "~/pic/profile/" + r.A_Id + ".jpg";
                }
                else if (u.Role == "comic")
                {
                    ComicCreator r = db.ComicCreators.SingleOrDefault(a => a.CC_email == u.Email);
                    imgProfile.Visible  = true;
                    imgProfile.ImageUrl = "~/pic/profile/" + r.CC_Id + ".jpg";
                }
                else
                {
                    imgProfile.Visible = false;
                }
            }
            else
            {
                imgProfile.Visible = false;
            }
        }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string       query = Request.QueryString["comicId"];
         string       email = HttpContext.Current.User.Identity.Name;
         ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);
         if (f != null)
         {
             if (Int32.TryParse(query, out int rem))
             {
                 int comicId = int.Parse(query);
                 //int comicId = 98988572;
                 Comic c = db.Comics.SingleOrDefault(x => x.CC_Id == f.CC_Id && x.C_Id == comicId);
                 if (c == null)
                 {
                     Response.Redirect("~/error.aspx?err=You didnt have permission");
                     //Error page (U didnt have permission to add episode on this comic)
                 }
             }
             else
             {
                 Response.Redirect("~/error.aspx?err=Result cant be found");
                 //if didnt have query
             }
         }
         else
         {
             Response.Redirect("~/error.aspx?err=You didnt have permission");
             //Redirect to error page
         }
     }
 }
예제 #4
0
        static void Main(string[] args)
        {
            IBook book = null;

            Console.WriteLine("what type of book you want: ");
            Console.WriteLine("1.Magazine");
            Console.WriteLine("2.Comic");
            var type = int.Parse(Console.ReadLine());

            switch (type)
            {
            case 1:
                var magazine = new MagazineCreator();
                book = magazine.GetBook();
                break;

            case 2:
                var comic = new ComicCreator();
                book = comic.GetBook();
                break;

            default:
                break;
            }
            if (book != null)
            {
                Console.WriteLine("you type of book is: " + book.Type);
            }
            else
            {
                Console.WriteLine("something is wrong...");
            }
        }
예제 #5
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string       email = txtEmail.Text;
                ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);
                if (f != null)
                {
                    int    id       = f.CC_Id;
                    string name     = txtname.Text;
                    string password = txtPassword.Text;
                    var    path     = MapPath("~/pic/profile/");
                    string phone    = txtPhoneNumber.Text;
                    int    n        = Convert.ToInt32(phone);
                    if (fuImage.HasFile)
                    {
                        File.Delete(path + id + ".jpg");
                        var img = new SimpleImage(fuImage.FileContent);
                        img.SaveAs(path + id + ".jpg");
                    }


                    f.CC_NickName = txtname.Text;
                    f.CC_hash     = Security.GetHash(password);
                    //f.CC_email = email;
                    f.CC_phone = phone;
                    db.SubmitChanges();
                }
                ;



                Response.Redirect("~/home.aspx");
            }
        }
예제 #6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string       query     = Request.QueryString["cId"];
            string       eId       = Request.QueryString["eId"];
            string       email     = HttpContext.Current.User.Identity.Name;
            ComicCreator f         = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);
            int          episodeId = int.Parse(eId);
            int          comicId   = int.Parse(query);
            Episode      ep        = db.Episodes.SingleOrDefault(a => a.E_Id == episodeId && a.C_Id == comicId);

            if (ep != null)
            {
                string p      = "~/pic/comic/" + query + "/" + eId + "/";
                var    folder = Server.MapPath(p);
                int    count  = ep.E_PageNumber;
                for (int j = 1; j <= count + 1; j++)
                {
                    File.Delete(folder + j + ".jpg");
                }
                if (Directory.Exists(folder))
                {
                    Directory.Delete(folder);
                }
                db.Episodes.DeleteOnSubmit(ep);
                db.SubmitChanges();
                Response.Redirect("~/DisplayComic.aspx?cId=" + query);
            }
        }
예제 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string       eId   = Request.QueryString["eId"];
         string       query = Request.QueryString["cId"];
         string       email = HttpContext.Current.User.Identity.Name;
         ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);
         if (f != null)
         {
             if (Int32.TryParse(query, out int rem) && Int32.TryParse(eId, out int r))
             {
                 int     comicId = rem;
                 int     episode = r;
                 Comic   c       = db.Comics.SingleOrDefault(x => x.CC_Id == f.CC_Id && x.C_Id == comicId);
                 Episode ep      = db.Episodes.SingleOrDefault(a => a.C_Id == comicId && a.E_Id == episode);
                 if (c == null)
                 {
                     Response.Redirect("~/error.aspx?err=You didnt have permission");
                     //Error page (U didnt have permission to add episode on this comic)
                 }
                 else
                 {
                     if (ep != null)
                     {
                         hfEpisode.Value = ep.E_Id.ToString();
                         hfComicId.Value = ep.C_Id.ToString();
                         hfPageNum.Value = ep.E_PageNumber.ToString();
                         txtEpisode.Text = ep.E_Id.ToString();
                         txtPageNum.Text = ep.E_PageNumber.ToString();
                         txtTitle.Text   = ep.E_Title;
                     }
                     else
                     {
                         Response.Redirect("~/error.aspx?err=The result cant be found");
                         //Didnt have this episode
                     }
                 }
             }
             else
             {
                 Response.Redirect("~/error.aspx?err=The result cant be found");
                 //if didnt have query
             }
         }
         else
         {
             Response.Redirect("~/error.aspx?err=You didnt have the permission");
             //Redirect to error page
         }
     }
 }
예제 #8
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            int          randomId;
            Random       random   = new Random();
            bool         repeatId = false;
            string       email    = HttpContext.Current.User.Identity.Name;
            ComicCreator f        = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
            int          id       = f.CC_Id;

            if (Page.IsValid)
            {
                do
                {
                    randomId = random.Next(100000, 99999999);
                    var b = db.Comics.SingleOrDefault(
                        cc => cc.C_Id == randomId);
                    if (b == null)
                    {
                        repeatId = true;
                    }
                } while (repeatId == false);

                string p      = "~/pic/comic/" + randomId + "/";
                var    folder = Server.MapPath(p);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                var img = new SimpleImage(fuImage.FileContent);
                img.SaveAs(folder + randomId + ".jpg");

                Comic c = new Comic
                {
                    C_Id           = randomId,
                    C_Title        = txtTitle.Text,
                    C_Description  = txtDescription.Text,
                    C_Price        = decimal.Parse(txtPrice.Text),
                    C_Publish_Date = DateTime.Now,
                    C_Status       = 'U',
                    C_category     = ddlCategory.SelectedValue,
                    C_AgeRestrict  = int.Parse(ddlAgeRestrt.SelectedValue),
                    C_IsForVip     = bool.Parse(rblVipView.SelectedValue),
                    CC_Id          = id
                };
                db.Comics.InsertOnSubmit(c);
                db.SubmitChanges();
                Response.Redirect("~/Comic.aspx");
            }
        }
        private async Task CreateComicCreator(IList <Creator> creators, Comic comic)
        {
            IList <ComicCreator> comicCreators = new List <ComicCreator>();

            foreach (var item in creators)
            {
                ComicCreator comicCreatorItem = new ComicCreator();
                comicCreatorItem.Comic   = comic;
                comicCreatorItem.Creator = item;

                comicCreators.Add(comicCreatorItem);
            }

            await _unitOfWOrk.ComicCreatorRepository.Add(comicCreators);
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string email = HttpContext.Current.User.Identity.Name;
                string cid   = Request.QueryString["cId"];

                if (string.IsNullOrEmpty(cid))
                {
                    //Redirect the page to error page
                }
                else
                {
                    int          cId = Int32.Parse(cid);
                    ComicCreator f   = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
                    if (f != null)
                    {
                        Comic c = db.Comics.SingleOrDefault(a => a.C_Id == cId && a.CC_Id == f.CC_Id);
                        if (c != null)
                        {
                            for (int i = 1; i < 22; i++)
                            {
                                ddlAgeRestrt.Items.Add(new ListItem(i.ToString(), i.ToString()));
                            }

                            txtTitle.Text              = c.C_Title;
                            txtDescription.Text        = c.C_Description;
                            txtPrice.Text              = c.C_Price.ToString();
                            rblVipView.SelectedValue   = c.C_IsForVip.ToString();
                            ddlCategory.SelectedValue  = c.C_category;
                            ddlAgeRestrt.SelectedValue = c.C_AgeRestrict.ToString();
                        }
                        else
                        {
                            Response.Redirect("~/error.aspx?err=The result cant be found");
                            //Redirect
                        }
                    }
                    else
                    {
                        Response.Redirect("~/error.aspx?err=You didnt have permission");
                        //redirect to the error page
                    }
                }
            }
        }
예제 #11
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            int          ccId  = 0;
            string       query = Request.QueryString["comicId"];
            string       name  = HttpContext.Current.User.Identity.Name;
            ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_NickName.ToString() == name);

            if (f != null)
            {
                ccId = f.CC_Id;
            }
            if (Page.IsValid)
            {
                int pageNum = int.Parse(txtPageNum.Text);
                int comicId = int.Parse(query);
                //int comicId = 98988572;
                int episode = int.Parse(txtEpisode.Text);
                //Create new folder
                string p      = "~/pic/comic/" + query + "/" + episode + "/";
                var    folder = Server.MapPath(p);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                int i = 0;
                foreach (HttpPostedFile File in fuImage.PostedFiles)
                {
                    ++i;
                    File.SaveAs(folder + i + ".jpg");
                }

                Episode c = new Episode
                {
                    E_Id         = episode,
                    E_Title      = txtTitle.Text,
                    E_PageNumber = pageNum,
                    E_DateUpload = DateTime.Now,
                    E_Status     = 'U',
                    C_Id         = comicId
                };
                db.Episodes.InsertOnSubmit(c);
                db.SubmitChanges();
                Response.Redirect("~/DisplayComic.aspx?cId=" + query);
            }
        }
예제 #12
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string       query = Request.QueryString["cId"];
            string       eId   = Request.QueryString["eId"];
            string       email = HttpContext.Current.User.Identity.Name;
            ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);

            if (Page.IsValid)
            {
                int episodeId = int.Parse(eId);
                int pageNum   = int.Parse(txtPageNum.Text);
                int comicId   = int.Parse(query);
                int episode   = int.Parse(txtEpisode.Text);
                //Create new folder
                string p      = "~/pic/comic/" + query + "/" + episode + "/";
                var    folder = Server.MapPath(p);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                int i = 0;
                //Delete file first
                Episode ep    = db.Episodes.SingleOrDefault(a => a.C_Id == comicId && a.E_Id == episodeId);
                int     count = ep.E_PageNumber;
                //If no pic
                if (fuImage.HasFiles)  // if the got the pic
                {
                    for (int j = 1; j <= count + 1; j++)
                    {
                        File.Delete(folder + j + ".jpg");
                    }
                    foreach (HttpPostedFile File in fuImage.PostedFiles)
                    {
                        ++i;
                        File.SaveAs(folder + i + ".jpg");
                    }
                }
                ep.E_Title      = txtTitle.Text;
                ep.E_PageNumber = pageNum;
                db.SubmitChanges();
                Response.Redirect("~/DisplayComic.aspx?cId=" + query);
            }
        }
예제 #13
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string       email = HttpContext.Current.User.Identity.Name;
            ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
            string       cid   = Request.QueryString["cId"];

            if (Page.IsValid)
            {
                if (!string.IsNullOrEmpty(cid))
                {
                    int    cId    = Int32.Parse(cid);
                    string p      = "~/pic/comic/" + cid + "/";
                    var    folder = Server.MapPath(p);
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }
                    if (fuImage.HasFile)
                    {
                        File.Delete(folder + cid + ".jpg");
                        var img = new SimpleImage(fuImage.FileContent);
                        img.SaveAs(folder + cid + ".jpg");
                    }
                    Comic c = db.Comics.SingleOrDefault(a => a.C_Id == cId);
                    c.C_Title       = txtTitle.Text;
                    c.C_Description = txtDescription.Text;
                    c.C_Price       = decimal.Parse(txtPrice.Text);
                    c.C_category    = ddlCategory.SelectedValue;
                    c.C_AgeRestrict = Int32.Parse(ddlAgeRestrt.SelectedValue);
                    c.C_IsForVip    = bool.Parse(rblVipView.SelectedValue);

                    db.SubmitChanges();
                    Response.Redirect("~/DisplayComic.aspx?cId=" + cid);
                }
                else
                {
                    Response.Redirect("~/error.aspx?err=The result cant be found");

                    //redirect to the error page
                }
            }
        }
예제 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string       email = HttpContext.Current.User.Identity.Name;
         ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
         if (f != null) //
         {
             for (int i = 1; i < 22; i++)
             {
                 ddlAgeRestrt.Items.Add(new ListItem(i.ToString(), i.ToString()));
             }
         }
         else
         {
             Response.Redirect("~/error.aspx?err=You didnt have permission");
             //redirect to the error page
         }
     }
 }
예제 #15
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            int index = 0;

            foreach (GridViewRow r in GridView1.Rows)
            {
                var chk = (CheckBox)r.Cells[0].FindControl("CheckBox1");
                if (chk != null && chk.Checked)
                {
                    int          id = Convert.ToInt32(GridView1.DataKeys[index].Value.ToString());
                    ComicCreator c  = db.ComicCreators.SingleOrDefault(a => a.CC_Id == id);
                    if (c != null)
                    {
                        c.CC_BanStatus = false;
                        db.SubmitChanges();
                    }
                }


                index++;
            }
            Response.Redirect("../Admin/ban.aspx");
        }
예제 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) // Initial page load
            {
                string       email = HttpContext.Current.User.Identity.Name;
                ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);

                if (f != null)
                {
                    txtPhoneNumber.Text = f.CC_phone;
                    hfId.Value          = f.CC_Id.ToString();
                    txtname.Text        = f.CC_NickName;
                    txtPassword.Text    = f.CC_hash;
                    txtEmail.Text       = f.CC_email;
                    gender = (char)f.CC_gender;
                    id     = f.CC_Id;
                }
                else
                {
                    Response.Redirect("~/error.aspx?err=You didnt have permission");
                }
            }
        }
예제 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string       cid = Request.QueryString["cId"];
            int          readerId = 0;
            bool         isVip = false, cantSee = false;
            char         vStatus = '\0';
            string       email   = HttpContext.Current.User.Identity.Name;
            Comic        f       = db.Comics.SingleOrDefault(o => o.C_Id.ToString() == cid);   //f comic
            readers      r       = db.readers.SingleOrDefault(a => a.R_email == email);
            ComicCreator cc      = db.ComicCreators.SingleOrDefault(a => a.CC_email == email); // cc comiccreator
            admin        ad      = db.admins.SingleOrDefault(a => a.A_email == email);

            if (r != null)
            {
                readerId = r.R_Id;
            }
            if (f != null)
            {
                hfId.Value   = f.C_Id.ToString(); // Id is int
                lblName.Text = f.C_Title;
                lblD.Text    = f.C_Description;
                vStatus      = f.C_Status;
                isVip        = f.C_IsForVip;
                cantSee      = f.C_CantViewable;
                ComicCreator c = db.ComicCreators.SingleOrDefault(
                    a => a.CC_Id == f.CC_Id);
                if (isVip == true)
                {
                    lblVip.Visible = true;
                }
                lblAuthor.Text = c.CC_NickName;

                //get the discount
                lblPrice.Text    = "RM" + f.C_Price;
                lblDiscount.Text = "RM" + Math.Round(f.C_Price * Convert.ToDecimal(0.9), 2);
                if (cantSee == true)
                {
                    //cant see
                    Response.Redirect("~/error.aspx?err=You didnt have the permission");
                }
                if (cc != null)              //Is comic creator
                {
                    if (cc.CC_Id == f.CC_Id) // If the comic creator itself see it own comic
                    {
                        btnEdit.Visible       = true;
                        btnAddEpisode.Visible = true;
                        btnRead.Visible       = false;
                        btnCantRead.Visible   = false;
                        btnFavourite.Visible  = false;
                        btnFavourited.Visible = false;
                        btnPurchase.Visible   = false;
                        btnPurchased.Visible  = false;
                        lvEpisode.Visible     = false;
                        lvUpdate.Visible      = true;
                        btnStatus.Visible     = true;
                        string status = verifyStatus(f.C_Status);
                        btnStatus.Text     = status;
                        lvCantView.Visible = false;
                    }
                    else //Other comic creator see ur comic
                    {
                        if (vStatus != 'V')
                        {
                            // Error page
                            Response.Redirect("~/error.aspx?err=The result cant be found");
                        }
                        //Default button
                        btnFavourite.Visible  = false;
                        btnFavourited.Visible = false;
                        btnPurchase.Visible   = false;
                        btnPurchased.Visible  = false;
                        btnCantRead.Visible   = true;
                        btnRead.Visible       = false;
                        lvCantView.Visible    = true;
                        lvCan.Visible         = false;
                        lvEpisode.Visible     = false;
                        lvOnlyVip.Visible     = true;
                    }
                }
                else if (r != null)                         // Is reader
                {
                    if (r.R_isvip == true && isVip == true) // vip with comic vip
                    {
                        Purchased p = db.Purchaseds.SingleOrDefault(a => a.R_Id == readerId && a.C_Id == f.C_Id);
                        if (p != null) //Is purchased
                        {
                            btnPurchase.Visible  = false;
                            btnPurchased.Visible = true;
                            btnPurchased.Enabled = false;
                            lvOnlyVip.Visible    = false;
                            lvEpisode.Visible    = true;
                            lvCantView.Visible   = false;
                            lvCan.Visible        = true;
                        }
                        else
                        {
                            btnPurchase.Visible  = true;
                            btnPurchased.Visible = false;
                        }
                        Favourite fa = db.Favourites.SingleOrDefault(a => a.R_Id == readerId && a.C_Id == f.C_Id);
                        if (fa != null) // Is Faourite
                        {
                            btnFavourite.Visible  = false;
                            btnFavourited.Visible = true;
                            btnFavourited.Enabled = false;
                        }
                        else
                        {
                            btnFavourite.Visible  = true;
                            btnFavourited.Visible = false;
                        }
                        Episode ep = db.Episodes.SingleOrDefault(a => a.C_Id == f.C_Id && a.E_Id == 1);
                        if (ep == null)  //Didnt have episode
                        {
                            btnRead.Visible     = false;
                            btnCantRead.Visible = true;
                            btnCantRead.Enabled = false;
                        }
                        else
                        {
                            btnRead.Visible     = true;
                            btnCantRead.Visible = false;
                        }
                    }
                    else if (r.R_isvip == true && isVip == false) // if the reader is vip and comic not vip
                    {
                        Purchased p = db.Purchaseds.SingleOrDefault(a => a.R_Id == readerId && a.C_Id == f.C_Id);
                        if (p != null) //Is purchased
                        {
                            btnPurchase.Visible  = false;
                            btnPurchased.Visible = true;
                            btnPurchased.Enabled = false;
                            lblPrice.CssClass   += " discount";
                            lblDiscount.Visible  = true;
                            lvCantView.Visible   = false;
                            lvCan.Visible        = true;
                            lvEpisode.Visible    = true;
                            lvOnlyVip.Visible    = false;
                        }
                        else
                        {
                            lblPrice.CssClass   += " discount";
                            lblDiscount.Visible  = true;
                            lvEpisode.Visible    = true;
                            lvOnlyVip.Visible    = false;
                            lvCantView.Visible   = true;
                            btnPurchase.Visible  = true;
                            btnPurchased.Visible = false;
                        }
                        Favourite fa = db.Favourites.SingleOrDefault(a => a.R_Id == readerId && a.C_Id == f.C_Id);
                        if (fa != null) // Is Faourite
                        {
                            btnFavourite.Visible  = false;
                            btnFavourited.Visible = true;
                            btnFavourited.Enabled = false;
                        }
                        else
                        {
                            btnFavourite.Visible  = true;
                            btnFavourited.Visible = false;
                        }
                        Episode ep = db.Episodes.SingleOrDefault(a => a.C_Id == f.C_Id && a.E_Id == 1);
                        if (ep == null)  //Didnt have episode
                        {
                            btnRead.Visible     = false;
                            btnCantRead.Visible = true;
                            btnCantRead.Enabled = false;
                        }
                        else
                        {
                            btnRead.Visible     = true;
                            btnCantRead.Visible = false;
                        }
                    }
                    else if (r.R_isvip == false && isVip == true)
                    {
                        btnPurchase.Visible   = false;
                        btnPurchased.Visible  = false;
                        btnRead.Visible       = false;
                        btnCantRead.Visible   = true;
                        btnCantRead.Enabled   = false;
                        btnFavourite.Visible  = false;
                        btnFavourited.Visible = false;
                        lvOnlyVip.Visible     = true;
                        lvEpisode.Visible     = false;
                        lvCantView.Visible    = true;
                        lvCan.Visible         = false;
                    }
                    else
                    {
                        Purchased p = db.Purchaseds.SingleOrDefault(a => a.R_Id == readerId && a.C_Id == f.C_Id);
                        if (p != null) //Is purchased
                        {
                            btnPurchase.Visible  = false;
                            btnPurchased.Visible = true;
                            btnPurchased.Enabled = false;
                            lvOnlyVip.Visible    = false;
                            lvEpisode.Visible    = true;
                            lvCantView.Visible   = false;
                            lvCan.Visible        = true;
                        }
                        else
                        {
                            btnPurchase.Visible  = true;
                            btnPurchased.Visible = false;
                        }
                        Favourite fa = db.Favourites.SingleOrDefault(a => a.R_Id == readerId && a.C_Id == f.C_Id);
                        if (fa != null) // Is Faourite
                        {
                            btnFavourite.Visible  = false;
                            btnFavourited.Visible = true;
                            btnFavourited.Enabled = false;
                        }
                        else
                        {
                            btnFavourite.Visible  = true;
                            btnFavourited.Visible = false;
                        }
                        Episode ep = db.Episodes.SingleOrDefault(a => a.C_Id == f.C_Id && a.E_Id == 1);
                        if (ep == null)  //Didnt have episode
                        {
                            btnRead.Visible     = false;
                            btnCantRead.Visible = true;
                            btnCantRead.Enabled = false;
                        }
                        else
                        {
                            btnRead.Visible     = true;
                            btnCantRead.Visible = false;
                        }
                    }
                    if (vStatus != 'V')
                    {
                        // Error page
                        Response.Redirect("~/error.aspx?err=The result cant be found");
                    }
                }
                else if (ad != null) //Admin
                {
                    btnStatus.Visible = true;
                    string status = verifyStatus(f.C_Status);
                    btnStatus.Text        = status;
                    btnFail.Visible       = true;
                    btnVerify.Visible     = true;
                    btnUnverify.Visible   = true;
                    btnRead.Visible       = false;
                    btnCantRead.Visible   = false;
                    btnFavourite.Visible  = false;
                    btnFavourited.Visible = false;
                    btnPurchase.Visible   = false;
                    btnPurchased.Visible  = false;
                    lvCantView.Visible    = false;
                    lvCan.Visible         = true;
                    lvEpisode.Visible     = true;
                    lvOnlyVip.Visible     = false;
                }
                else
                {
                    if (isVip == true)
                    {
                        btnPurchase.Visible   = true;
                        btnPurchased.Visible  = false;
                        btnRead.Visible       = false;
                        btnCantRead.Visible   = true;
                        btnCantRead.Enabled   = false;
                        btnFavourite.Visible  = false;
                        btnFavourited.Visible = false;
                        lvEpisode.Visible     = false;
                        lvOnlyVip.Visible     = true;
                    }
                    else
                    {
                        Episode ep = db.Episodes.SingleOrDefault(a => a.C_Id == f.C_Id && a.E_Id == 1);
                        if (ep == null) //Havent  Favourite
                        {
                            btnRead.Visible     = false;
                            btnCantRead.Visible = true;
                            btnCantRead.Enabled = false;
                        }
                        else
                        {
                            btnRead.Visible     = true;
                            btnCantRead.Visible = false;
                        }
                    }

                    //Default button
                    btnFavourite.Visible  = true;
                    btnFavourited.Visible = false;
                    btnPurchase.Visible   = true;
                    btnPurchased.Visible  = false;
                    if (vStatus != 'V')
                    {
                        // Error page
                        Response.Redirect("~/error.aspx?err=The result cant be found");
                    }
                }
                //Verified the available to see all or not
            }
            else
            {
                Response.Redirect("~/error.aspx?err=The result cant be found");
            }
        }
예제 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();

            if (!IsPostBack)
            {
                string       email = HttpContext.Current.User.Identity.Name;
                string       cId   = Request.QueryString["cId"];
                string       eId   = Request.QueryString["eId"];
                ComicCreator cc    = db.ComicCreators.SingleOrDefault(a => a.CC_email == email);
                readers      r     = db.readers.SingleOrDefault(a => a.R_email == email);
                admin        ad    = db.admins.SingleOrDefault(a => a.A_email == email);
                if (!string.IsNullOrEmpty(email) || int.TryParse(cId, out int o) || Int32.TryParse(eId, out int p))
                {
                    int     c_id = Int32.Parse(cId);
                    int     e_id = Int32.Parse(eId);
                    Episode ep   = db.Episodes.SingleOrDefault(
                        a => a.E_Id == e_id && a.C_Id == c_id);
                    Comic com = db.Comics.SingleOrDefault(
                        a => a.C_Id == c_id);
                    if (ep != null)
                    {
                        string path    = Server.MapPath("/pic/comic/");
                        int    success = 0;
                        for (int i = 0; i <= ep.E_PageNumber; i++)
                        {
                            string pageEpisode = path + "/" + ep.C_Id + "/" + ep.E_Id + "/" + i + ".jpg";
                            if (File.Exists(pageEpisode))
                            {
                                success++;
                            }
                        }
                        if (success == ep.E_PageNumber)
                        {
                            hfEpisode.Value = ep.E_Id.ToString();
                            hfPageNum.Value = ep.E_PageNumber.ToString();
                            hfComicId.Value = ep.C_Id.ToString();
                        }
                        if (com != null)
                        {
                            if (r != null)
                            {
                                if (r.R_isvip == true && com.C_IsForVip == true)
                                {
                                    //got purchased
                                    if (!db.Purchaseds.Any(a => a.R_Id == r.R_Id && a.C_Id == com.C_Id))
                                    {
                                        if (ep.E_Id > 5)
                                        {
                                            Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                        }
                                    }
                                }
                                else if (r.R_isvip == false && com.C_IsForVip == true)
                                {
                                    Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                }
                                else if (r.R_isvip == true && com.C_IsForVip == false)
                                {
                                    if (!db.Purchaseds.Any(a => a.R_Id == r.R_Id && a.C_Id == com.C_Id))
                                    {
                                        if (ep.E_Id > 5)
                                        {
                                            Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                        }
                                    }
                                }
                                else
                                {
                                    if (!db.Purchaseds.Any(a => a.R_Id == r.R_Id && a.C_Id == com.C_Id))
                                    {
                                        if (ep.E_Id > 5)
                                        {
                                            Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                        }
                                    }
                                }
                            }
                            else if (cc != null)
                            {
                                if (com.C_IsForVip == true)
                                {
                                    Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                }
                                else
                                {
                                    if (ep.E_Id > 5)
                                    {
                                        Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                    }
                                }
                            }
                            else if (ad != null)
                            {
                            }
                            else
                            {
                                if (com.C_IsForVip == true)
                                {
                                    Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                }
                                else
                                {
                                    if (ep.E_Id > 5)
                                    {
                                        Response.Redirect("~/error.aspx?err=You didnt have the permission");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Response.Redirect("~/error.aspx?err=Result cant be found");
                    }
                }
                else
                {
                    Response.Redirect("~/error.aspx?err=Result cant be found");
                }
            }
        }
예제 #19
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int    randomId  = 0;
                Random random    = new Random();
                bool   repeatId  = false;
                String NickName  = txtname.Text;
                string password  = txtPassword.Text;
                string email     = txtEmail.Text;
                string phone     = txtPhoneNumber.Text;
                string gender    = rblGender.Text;
                string newFormat = DateTime.ParseExact(TxtDob.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture)
                                   .ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime dat = DateTime.Parse(newFormat);
                do
                {
                    randomId = random.Next(10000, 9999999);
                    var p = db.ComicCreators.SingleOrDefault(
                        b => b.CC_Id == randomId);
                    if (p == null)
                    {
                        repeatId = true;
                    }
                } while (repeatId == false);


                var sourcePath = MapPath("~/pic/system/");
                var destPath   = MapPath("~/pic/profile/");

                if (gender == "M")
                {
                    string fileName    = "male.jpg";
                    string oldFileName = sourcePath + fileName;
                    string newFileName = destPath + randomId + ".jpg";
                    File.Copy(oldFileName, newFileName);
                }
                else
                {
                    string fileName    = "female.jpg";
                    string oldFileName = sourcePath + fileName;
                    string newFileName = destPath + randomId + ".jpg";
                    File.Copy(oldFileName, newFileName);
                }
                ComicCreator r = new ComicCreator
                {
                    CC_Id            = randomId,
                    CC_NickName      = NickName,
                    CC_hash          = Security.GetHash(password),
                    CC_email         = email,
                    CC_phone         = phone,
                    CC_gender        = char.Parse(gender),
                    CC_birth_date    = dat,
                    CC_register_date = DateTime.Now
                };
                db.ComicCreators.InsertOnSubmit(r);
                db.SubmitChanges();

                Response.Redirect("~/Authentication/login.aspx");
            }
        }
예제 #20
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
            }
        }
예제 #21
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;
                    }
                }
            }
        }