Пример #1
0
        protected void btn_savePassword_Click(object sender, EventArgs e)
        {
            var item = from u in db.tbl_users
                       where u.UserID == int.Parse(Session["userID"].ToString())
                       select u;

            foreach (var z in item)
            {
                if (TextBoxPasswordOld.Text != z.Password)
                {
                    lbl_introPass.Text = "Please enter old password correctly!";
                    return;
                }
            }
            if (isCorrectPassword())
            {
                foreach (var z in item)
                {
                    z.Password = TextBoxPassword.Text;
                    db.SubmitChanges();
                }

                lnkbtn_changePassword.Visible = true;

                lbl_passwordAgain.Visible  = false;
                lbl_passwordOld.Visible    = false;
                TextBoxPassagain.Visible   = false;
                TextBoxPasswordOld.Visible = false;
                TextBoxPassword.Visible    = false;
                btn_savePassword.Visible   = false;

                lbl_introPass.ForeColor = Color.Green;
                lbl_introPass.Text      = "Your password has been changed successfully!";
            }
        }
Пример #2
0
        protected void Btn_Barrow_Click(object sender, EventArgs e)
        {
            if (Session["cart"] != null)
            {
                tbl_order ne = new tbl_order();
                ne.UserID    = int.Parse(Session["userID"].ToString());
                ne.StartDate = DateTime.Now;
                ne.State     = "Waiting";
                db.tbl_orders.InsertOnSubmit(ne);
                db.SubmitChanges();

                var item = from o in db.tbl_orders
                           select o;
                int id = 0;
                foreach (var z in item)
                {
                    id = z.OrderID;
                }


                string   cart = Session["cart"].ToString();
                string[] crt  = cart.Split('+');
                for (int i = 0; i < crt.Length; i++)
                {
                    tbl_indexOrder n = new tbl_indexOrder();
                    n.OrderID = id;
                    n.BookID  = int.Parse(crt[i]);
                    db.tbl_indexOrders.InsertOnSubmit(n);
                    db.SubmitChanges();
                }
                Session["cart"] = "";
                Label1.Text     = "Your Cart has sent succesfully";
                Response.Redirect("Cart.aspx");
            }
        }
Пример #3
0
        protected void btn_addCategory_Click(object sender, EventArgs e)
        {
            if (TextBoxCategoryName.Text == "" || TextBoxCategoryName.Text.Length > 20)
            {
                lbl_intro.ForeColor = Color.Red;
                lbl_intro.Text      = "Please Enter The Category Name That Length is Shorter Than 20!";
                return;
            }

            var item = from u in db.tbl_Categories
                       where u.CategoryName == TextBoxCategoryName.Text
                       select u;

            foreach (var z in item)
            {
                lbl_intro.ForeColor = Color.Red;
                lbl_intro.Text      = TextBoxCategoryName.Text + " Has Been Added Allready!";
                return;
            }


            tbl_Category a = new tbl_Category();

            a.CategoryName = TextBoxCategoryName.Text;

            db.tbl_Categories.InsertOnSubmit(a);
            db.SubmitChanges();
            lbl_intro.ForeColor = Color.Green;
            lbl_intro.Text      = TextBoxCategoryName.Text + " Has Added Successfuly!";
            DropDownList1.DataBind();
        }
Пример #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox_title.Text.Length == 0)
            {
                lbl_info.ForeColor = Color.Red;
                lbl_info.Text      = "Please enter new title!";
                return;
            }
            else if (TextBox_content.Text.Length == 0)
            {
                lbl_info.ForeColor = Color.Red;
                lbl_info.Text      = "Please enter new content!";
                return;
            }

            tbl_New nw = new tbl_New();

            nw.Title           = TextBox_title.Text;
            nw.NewContent      = TextBox_content.Text;
            nw.Date            = DateTime.Now;
            lbl_info.ForeColor = Color.Green;
            lbl_info.Text      = "New added Successfully!";
            db.tbl_News.InsertOnSubmit(nw);
            db.SubmitChanges();
        }
Пример #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox_title.Text.Length == 0)
            {
                lbl_info.ForeColor = Color.Red;
                lbl_info.Text      = "Please enter new title!";
                return;
            }
            else if (TextBox_content.Text.Length == 0)
            {
                lbl_info.ForeColor = Color.Red;
                lbl_info.Text      = "Please enter new content!";
                return;
            }

            string id   = Request.QueryString["nid"];
            var    item = from u in db.tbl_News
                          where u.NewID == int.Parse(id)
                          select u;

            foreach (var z in item)
            {
                z.Title      = TextBox_title.Text;
                z.NewContent = TextBox_content.Text;
            }
            db.SubmitChanges();

            lbl_info.ForeColor = Color.Green;
            lbl_info.Text      = "The New Has Been Updated Successfully";
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["bid"] != null)
                {
                    tbl_BlockedBook ne = new tbl_BlockedBook();
                    ne.BookId = int.Parse(Request.QueryString["bid"]);
                    db.tbl_BlockedBooks.InsertOnSubmit(ne);
                    db.SubmitChanges();
                }


                var ite = from b in db.tbl_BlockedBooks
                          select b.BookId;
                var item = from b in db.tbl_Books
                           join c in db.tbl_Categories on b.CategoryID equals c.CategoryId
                           where !ite.Contains(b.BookId)
                           select new
                {
                    b.BookId, b.BookTitle, b.Author,
                    desc = b.BookDesc.Substring(0, 50) + "...",
                    b.Year, b.Publisher, b.ImagePath, c.CategoryName, b.CategoryID
                };
                DataList1.DataSource = item;
                DataList1.DataBind();
            }
        }
Пример #7
0
        protected void btn_accept_Click(object sender, EventArgs e)
        {
            bool flag = true;
            int  oid  = int.Parse(lbl_orderid.Text);
            var  item = from i in db.tbl_indexOrders
                        where i.OrderID == oid
                        select i.BookID;

            var ite = from o in db.tbl_orders
                      join x in db.tbl_indexOrders on o.OrderID equals x.OrderID
                      where o.State == "Accepted" && item.Contains(x.BookID)
                      select new
            {
                x.BookID
            };

            foreach (var z in ite)
            {
                Label1.ForeColor = Color.Red;
                Label1.Text      = "You cannot add this book Because, This book Barrowed please try again Later.";
                flag             = false;
            }



            if (flag)
            {
                var it = from o in db.tbl_orders
                         where o.OrderID == int.Parse(Request.QueryString["oid"].ToString())
                         select o;
                foreach (var z in it)
                {
                    z.State = "Accepted";
                    db.SubmitChanges();
                    tbl_Message ne = new tbl_Message();
                    ne.message = "Your Order whose number is " + Request.QueryString["oid"].ToString() + " Has Been Accepted Succesfully";
                    ne.userID  = z.UserID;
                    ne.state   = "Unreaded";
                    db.tbl_Messages.InsertOnSubmit(ne);
                    db.SubmitChanges();
                    Response.Redirect("AcceptOrders.aspx");
                }
            }
        }
 protected void lnkbtn_delete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < GridView1.Rows.Count; i++)
     {
         if (((CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBoxSelect")).Checked)
         {
             var item = from u in db.tbl_users
                        where u.UserName == GridView1.Rows[i].Cells[1].Text
                        select u;
             foreach (var z in item)
             {
                 db.tbl_users.DeleteOnSubmit(z);
                 db.SubmitChanges();
             }
         }
     }
     GridView1.DataBind();
     lbl_intro.Text = "All Selected Supporters Have Been Deleted!";
 }
Пример #9
0
        protected void Session_Start(object sender, EventArgs e)
        {
            int b = int.Parse(Application["hit"].ToString());

            totalNumberOfUsers += 1;
            b++;
            Application["hit"]    = b;
            currentNumberOfUsers += 1;
            Session.Timeout       = 90;
            if (Request.Cookies["userID"] != null)
            {
                tbl_AccountLog ne = new tbl_AccountLog();
                int            a  = int.Parse(Request.Cookies["userID"].Value.ToString());
                ne.UserID = a;
                ne.Date   = DateTime.Now;
                ne.Type   = "Log in";
                db.tbl_AccountLogs.InsertOnSubmit(ne);
                db.SubmitChanges();
            }
        }
Пример #10
0
        protected void btn_Register_Click(object sender, EventArgs e)
        {
            if (TextBoxEmail.Text == "" || TextBoxName.Text == "" || TextBoxPassagain.Text == "" || TextBoxPassword.Text == "" ||
                TextBoxSurname.Text == "" || TextBoxUsername.Text == "" || Calendar1.SelectedDate == null)
            {
                lbl_intro.Text = "Please fill empty places!";
                return;
            }

            if (isThereUsername())
            {
                lbl_intro.Text = "This username has already registered!";
                return;
            }

            if (TextBoxUsername.Text.Length < 8 || TextBoxUsername.Text.Length > 15)
            {
                lbl_intro.Text = "The length of password should be 8-15 !";
                return;
            }

            if (!isCorrectPassword())
            {
                return;
            }

            if (TextBoxEmail.Text.IndexOf('@') == -1 || TextBoxEmail.Text.IndexOf('.', TextBoxEmail.Text.IndexOf('@')) == -1)
            {
                lbl_intro.Text = "Please enter correct E-mail adress!";
                return;
            }

            if (Calendar1.SelectedDate.Year == 1)
            {
                lbl_intro.Text = "Please choose your birthday!";
                return;
            }

            tbl_user newUser = new tbl_user();

            newUser.UserName = TextBoxUsername.Text;
            newUser.Password = TextBoxPassword.Text;
            newUser.Name     = TextBoxName.Text;
            newUser.Surname  = TextBoxSurname.Text;
            newUser.Email    = TextBoxEmail.Text;
            newUser.Birthday = Calendar1.SelectedDate;
            newUser.Type     = 1;

            db.tbl_users.InsertOnSubmit(newUser);
            db.SubmitChanges();

            Response.Redirect("Login.aspx");
        }
Пример #11
0
 protected void lnkbtnLogout_Click(object sender, EventArgs e)
 {
     if (Session["userID"] != null)
     {
         tbl_AccountLog ne = new tbl_AccountLog();
         ne.UserID = int.Parse(Session["userID"].ToString());
         ne.Date   = DateTime.Now;
         ne.Type   = "Log out";
         db.tbl_AccountLogs.InsertOnSubmit(ne);
         db.SubmitChanges();
     }
     Session["userID"] = null;
     Response.Cookies["userID"].Expires = DateTime.Now.AddDays(-1);
     Response.Redirect("Default.aspx");
 }
Пример #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["nid"] != null)
         {
             tbl_New ne   = new tbl_New();
             var     item = from u in db.tbl_News
                            where u.NewID == int.Parse(Request.QueryString["nid"])
                            select u;
             foreach (var z in item)
             {
                 db.tbl_News.DeleteOnSubmit(z);
             }
             db.SubmitChanges();
         }
     }
 }
Пример #13
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            GenelDataContext db = new GenelDataContext();

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (((CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1")).Checked)
                {
                    var item = from m in db.tbl_Messages
                               where m.MessageID == int.Parse(GridView1.Rows[i].Cells[1].Text)
                               select m;
                    foreach (var z in item)
                    {
                        z.state = "Readed";
                        db.SubmitChanges();
                        GridView1.DataBind();
                    }
                }
            }
        }
Пример #14
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            GenelDataContext db = new GenelDataContext();

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (((CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox_Select")).Checked)
                {
                    var item = from o in db.tbl_orders
                               where o.OrderID == int.Parse(GridView1.Rows[i].Cells[1].Text)
                               select o;
                    foreach (var z in item)
                    {
                        z.State      = "Done";
                        z.FinishDate = DateTime.Now;
                        db.SubmitChanges();
                        GridView1.DataBind();
                    }
                }
            }
        }
Пример #15
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            if (txbox_password.Text == "" || txbox_Username.Text == "")
            {
                lbl_Intro.Text = "Please Fill The Empty Places!";
                return;
            }
            var item = from x in db.tbl_users
                       where x.UserName == txbox_Username.Text
                       select x;

            int us = 0;

            foreach (var u in item)
            {
                us = 1;
                if (u.Password != txbox_password.Text)
                {
                    lbl_Intro.Text = "You entered wrong password, Please try again!";
                    return;
                }
            }

            if (us == 0)
            {
                lbl_Intro.Text = "There is not such a username, Please click register button to register!";
                return;
            }

            foreach (var u in item)
            {
                Session["userID"] = u.UserID;
                if (Session["userID"] != null)
                {
                    tbl_AccountLog ne = new tbl_AccountLog();
                    ne.UserID = int.Parse(Session["userID"].ToString());
                    ne.Date   = DateTime.Now;
                    ne.Type   = "Log in";
                    db.tbl_AccountLogs.InsertOnSubmit(ne);
                    db.SubmitChanges();
                }
                if (checkbox_rememberMe.Checked)
                {
                    Response.Cookies["userID"].Value   = u.UserID.ToString();
                    Response.Cookies["userID"].Expires = DateTime.Now.AddDays(30);
                }

                if (u.Type == 1 || u.Type == 3)
                {
                    Response.Redirect("Default.aspx");
                }
                else if (u.Type == 0)
                {
                    Response.Redirect("DefaultAdmin.aspx");
                }
                else
                {
                    Response.Redirect("DefaultSupporter.aspx");
                }
            }
        }
        protected void btn_add_Click(object sender, EventArgs e)
        {
            lbl_intro.ForeColor = Color.Red;

            if (TextBoxTitle.Text.Length == 0 || TextBoxTitle.Text.Length > 50)
            {
                lbl_intro.Text = "Length of Title should be 1-50";
                return;
            }

            if (ddl_category.SelectedIndex == -1)
            {
                lbl_intro.Text = "Please Choose Category!";
                return;
            }

            if (TextBoxAuthor.Text.Length < 3)
            {
                lbl_intro.Text = "Author is too short!";
                return;
            }
            int year;

            if (!int.TryParse(TextBoxYear.Text, out year))
            {
                lbl_intro.Text = "Please enter year correctly!";
                return;
            }
            if (year > DateTime.Now.Year || year < 1600)
            {
                lbl_intro.Text = "Year should be 1600-" + DateTime.Now.Year.ToString();
                return;
            }

            if (TextBoxPublisher.Text.Length < 3)
            {
                lbl_intro.Text = "Publisher is too short!";
                return;
            }

            if (TextBoxDesc.Text.Length < 50)
            {
                lbl_intro.Text = "Desc is too short!";
                return;
            }

            if (!regexValidator.IsValid)
            {
                lbl_intro.Text = "Please Choose only .jpg .jpeg .png";
                return;
            }


            tbl_Book newBook = new tbl_Book();

            newBook.Author     = TextBoxAuthor.Text;
            newBook.BookDesc   = TextBoxDesc.Text;
            newBook.BookTitle  = TextBoxTitle.Text;
            newBook.CategoryID = int.Parse(ddl_category.SelectedValue.ToString());
            newBook.Publisher  = TextBoxPublisher.Text;
            newBook.Year       = year;
            newBook.ImagePath  = "~/images/" + FileUploadImage.FileName;
            if (FileUploadImage.HasFile)
            {
                FileUploadImage.SaveAs(Server.MapPath("~/images/" + FileUploadImage.FileName));
            }
            db.tbl_Books.InsertOnSubmit(newBook);
            db.SubmitChanges();

            lbl_intro.ForeColor = Color.Green;
            lbl_intro.Text      = newBook.BookTitle + " Has Been Added Successfully";



            Response.Redirect("AdminBooks.aspx");
        }
Пример #17
0
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            lbl_intro.ForeColor = Color.Red;

            if (TextBoxTitle.Text.Length == 0 || TextBoxTitle.Text.Length > 50)
            {
                lbl_intro.Text = "Length of Title should be 1-50";
                return;
            }

            if (ddl_category.SelectedIndex == -1)
            {
                lbl_intro.Text = "Please Choose Category!";
                return;
            }

            if (TextBoxAuthor.Text.Length < 3)
            {
                lbl_intro.Text = "Author is too short!";
                return;
            }
            int year;
            if (!int.TryParse(TextBoxYear.Text, out year))
            {
                lbl_intro.Text = "Please enter year correctly!";
                return;
            }
            if (year > DateTime.Now.Year || year < 1600)
            {
                lbl_intro.Text = "Year should be 1600-" + DateTime.Now.Year.ToString();
                return;
            }

            if (TextBoxPublisher.Text.Length < 3)
            {
                lbl_intro.Text = "Publisher is too short!";
                return;
            }

            if (TextBoxDesc.Text.Length < 50)
            {
                lbl_intro.Text = "Desc is too short!";
                return;
            }

            if (!regexValidator.IsValid)
            {
                lbl_intro.Text = "Please Choose only .jpg .jpeg .png";
                return;
            }


            string id = Request.QueryString["bid"];
            var item = from u in db.tbl_Books
                       where u.BookId == int.Parse(id)
                       select u;
            foreach (var z in item)
            {
                z.Author = TextBoxAuthor.Text;
                z.BookDesc = TextBoxDesc.Text;
                z.BookTitle = TextBoxTitle.Text;
                z.CategoryID = int.Parse(ddl_category.SelectedValue.ToString());
                z.Publisher = TextBoxPublisher.Text;
                z.Year = year;
                if (FileUploadImage.HasFile)
                {
                    z.ImagePath = "~/images/" + FileUploadImage.FileName;
                    FileUploadImage.SaveAs(Server.MapPath("~/images/" + FileUploadImage.FileName));
                }
                db.SubmitChanges();

                lbl_intro.ForeColor = Color.Green;
                lbl_intro.Text = z.BookTitle + " Has Been Updated Successfully";
            }


            
            
        }