Пример #1
0
    protected void btn_login_Click(object sender, EventArgs e)
    {
        LoginModel model = new LoginModel();

        model.LoginId   = txt_loginid.Text;
        model.Password  = txt_Password.Text;
        model.LoginType = ddl_logintype.Text;

        Session["type"] = model.LoginType;

        if (model.LoginType == "Student")
        {
            LibraryDAL dal    = new LibraryDAL();
            bool       status = dal.Login(model);
            if (status == true)
            {
                Session["loginid"] = txt_loginid.Text;
                Response.Redirect("~/Home.aspx");
            }
            else
            {
                lbl_msg.Text = "Invalid User";
            }
        }
        else if (model.LoginId == "Admin" && model.Password == "Admin@123" && model.LoginType == "Admin")
        {
            Session["loginid"] = txt_loginid.Text;
            Response.Redirect("~/AdminHome.aspx");
        }

        else
        {
            lbl_msg.Text = "Invalid User";
        }
    }
    protected void btn_search_Click(object sender, EventArgs e)
    {
        string     key = txt_search.Text;
        LibraryDAL dal = new LibraryDAL();

        gv_books.DataSource = dal.ShowAllIssuedBook(key);
        gv_books.DataBind();
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int        sid = Convert.ToInt32(Session["loginid"]);
        LibraryDAL dal = new LibraryDAL();

        gv_books.DataSource = dal.Show(sid);
        gv_books.DataBind();
    }
Пример #4
0
    protected void btn_search_Click(object sender, EventArgs e)
    {
        LibraryDAL       dal  = new LibraryDAL();
        List <BookModel> list = dal.Search(txt_search.Text);

        gv_books.DataSource = list;
        gv_books.DataBind();
    }
    protected void gv_books_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gv_books.PageIndex = e.NewPageIndex;
        int        sid = Convert.ToInt32(Session["loginid"]);
        LibraryDAL dal = new LibraryDAL();

        gv_books.DataSource = dal.MyBookCart(sid);
        gv_books.DataBind();
    }
Пример #6
0
    protected void gv_books_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gv_books.PageIndex = e.NewPageIndex;
        LibraryDAL       dal  = new LibraryDAL();
        List <BookModel> list = dal.Search(txt_search.Text);

        gv_books.DataSource = list;
        gv_books.DataBind();
    }
Пример #7
0
    protected void gv_books_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        gv_books.EditIndex = -1;
        LibraryDAL       dal  = new LibraryDAL();
        List <BookModel> list = dal.Search(txt_search.Text);

        gv_books.DataSource = list;
        gv_books.DataBind();
    }
    protected void btn_newAdmin_Click(object sender, EventArgs e)
    {
        LibraryDAL    dal   = new LibraryDAL();
        NewAdminModel model = new NewAdminModel();

        model.AdminName     = txt_Adminname.Text;
        model.AdminEmailId  = txt_Adminemailid.Text;
        model.AdminPassword = txt_Adminpassword.Text;
        model.AdminMobileNo = txt_AdminMobileNo.Text;
    }
Пример #9
0
 protected void btn_IssueBook_Click(object sender, EventArgs e)
 {
     if (Session["type"] == "Student")
     {
         int        bid     = Convert.ToInt32(txt_Bookid.Text);
         int        sid     = Convert.ToInt32(Session["loginid"]);
         LibraryDAL dal     = new LibraryDAL();
         int        issueid = dal.IssueBook(bid, sid);
         Response.Redirect("~/IssuedDone.aspx?issueid=" + issueid);
     }
     else
     {
         lbl_msg.Text = "Admin Cannot Issue Book";
     }
 }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string id  = Request.QueryString["bid"];
        int    bid = Convert.ToInt32(id);

        LibraryDAL dal   = new LibraryDAL();
        BookModel  model = dal.FindBook(id);

        txt_Bookid.Text      = model.BookID.ToString();
        txt_Bookname.Text    = model.BookName;
        txt_BookAuthor.Text  = model.BookAuthor;
        txt_BookTitle.Text   = model.BookTitle;
        txt_BookPrice.Text   = model.BookPrice.ToString();
        img.ImageUrl         = model.BookImage;
        txt_BookAddDate.Text = model.BookAddDate.ToString();
        txt_NoOfPages.Text   = model.NoOfPages.ToString();
    }
    protected void btn_newBook_Click(object sender, EventArgs e)
    {
        LibraryDAL dal   = new LibraryDAL();
        BookModel  model = new BookModel();

        model.BookName   = txt_Bookname.Text;
        model.BookAuthor = txt_BookAuthor.Text;
        model.BookTitle  = txt_BookTitle.Text;
        model.BookPrice  = Convert.ToInt32(txt_BookPrice.Text);

        model.NoOfPages = Convert.ToInt32(txt_NoOfPages.Text);
        model.BookImage = "~/Images/" + Guid.NewGuid() + ".jpg";
        file_BookImage.SaveAs(Server.MapPath(model.BookImage));
        int id = dal.AddBooks(model);

        lbl_msg.Text = "Book Added :" + id;
    }
    protected void btn_newstudent_Click(object sender, EventArgs e)
    {
        LibraryDAL      dal   = new LibraryDAL();
        NewStudentModel model = new NewStudentModel();

        model.StudentName     = txt_studentname.Text;
        model.StudentEmailId  = txt_studentemailid.Text;
        model.StudentPassword = txt_studentpassword.Text;
        model.StudentCity     = txt_studentcity.Text;
        model.StudentAddress  = txt_studentaddress.Text;
        model.StudentDOB      = Convert.ToDateTime(txt_studentdob.Text);
        model.StudentMobileNo = txt_studentMobileNo.Text;
        model.StudentImage    = "~/Images/" + Guid.NewGuid() + ".jpg";
        file_StudentImage.SaveAs(Server.MapPath(model.StudentImage));
        int id = dal.AddStudent(model);

        lbl_msg.Text = "Student Added : " + id;
    }
Пример #13
0
 protected void btn_MyCart_Click(object sender, EventArgs e)
 {
     if (Session["type"].ToString() == "Student")
     {
         int        bid    = Convert.ToInt32(txt_Bookid.Text);
         int        sid    = Convert.ToInt32(Session["loginid"]);
         LibraryDAL dal    = new LibraryDAL();
         int        CartID = dal.AddCart(bid, sid);
         if (CartID == 0)
         {
             lbl_msg.Text = "Book is already in cart";
         }
         else
         {
             lbl_msg.Text = "Book added in Cart :" + CartID;
         }
     }
     else
     {
         lbl_msg.Text = "Admin Cannot Add to Cart";
     }
 }
Пример #14
0
    protected void btn_RemoveFromCart_Click(object sender, EventArgs e)
    {
        if (Session["type"].ToString() == "Student")
        {
            int        bid    = Convert.ToInt32(txt_Bookid.Text);
            int        sid    = Convert.ToInt32(Session["loginid"]);
            LibraryDAL dal    = new LibraryDAL();
            bool       status = dal.RemoveFromCart(bid, sid);
            if (status == true)
            {
                lbl_msg.Text = "not removed from cart";
            }
            else

            {
                lbl_msg.Text = "removed from cart";
            }
        }
        else
        {
            lbl_msg.Text = "Admin Cannot Add to Cart";
        }
    }
Пример #15
0
    protected void gv_books_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string     bid     = (gv_books.Rows[e.RowIndex].FindControl("lbl_bid") as Label).Text;
        string     bname   = (gv_books.Rows[e.RowIndex].FindControl("txt_bname") as TextBox).Text;
        string     bauthor = (gv_books.Rows[e.RowIndex].FindControl("txt_bAuthor") as TextBox).Text;
        string     btitle  = (gv_books.Rows[e.RowIndex].FindControl("txt_bTitle") as TextBox).Text;
        string     bprice  = (gv_books.Rows[e.RowIndex].FindControl("txt_bPrice") as TextBox).Text;
        string     bpages  = (gv_books.Rows[e.RowIndex].FindControl("txt_bNoofPages") as TextBox).Text;
        FileUpload bimage  = (gv_books.Rows[e.RowIndex].FindControl("txt_bimg") as FileUpload);
        string     address = "~/Images/" + Guid.NewGuid() + ".jpg";

        bimage.SaveAs(Server.MapPath(address));
        LibraryDAL dal = new LibraryDAL();

        dal.Update(Convert.ToInt32(bid), bname, bauthor, btitle, Convert.ToInt32(bprice), Convert.ToInt32(bpages), address);
        gv_books.EditIndex = -1;

        List <BookModel> list = dal.Search(txt_search.Text);

        gv_books.DataSource = list;
        gv_books.DataBind();
        lbl_msg.Text = "Updated Successfully...";
    }