protected void Button12_Click(object sender, EventArgs e)
    {
        if (drppublication.SelectedIndex == 0)
        {
            lblmsg.Text      = "Select Publication";
            lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1;
        }
        else if (drpbook.SelectedIndex == 0)
        {
            lblmsg.Text      = "Select Book";
            lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1;
        }
        else
        {
            MultiView1.ActiveViewIndex = 0;
            BookDT            = BookAdapter.Select_By_BNAM(drpbook.SelectedItem.Text);
            ViewState["BBID"] = BookDT.Rows[0]["BookID"].ToString();
            lblbname.Text     = BookDT.Rows[0]["Bookname"].ToString();
            lblauthor.Text    = BookDT.Rows[0]["author"].ToString();
            lblbran.Text      = BookDT.Rows[0]["branch"].ToString();
            lblpub.Text       = BookDT.Rows[0]["publication"].ToString();
            lblprice.Text     = BookDT.Rows[0]["price"].ToString();
            lblqnt.Text       = BookDT.Rows[0]["Quantities"].ToString();
            lblaqnt.Text      = BookDT.Rows[0]["availableqnt"].ToString();
            lblrqnt.Text      = BookDT.Rows[0]["rentqnt"].ToString();
            lbldetail.Text    = BookDT.Rows[0]["Detail"].ToString();
            Image2.ImageUrl   = BookDT.Rows[0]["Image"].ToString();

            drpstudent.Items.Clear();
            drpstudent.Items.Insert(0, "SELECT");
        }
    }
 protected void drppublication_SelectedIndexChanged(object sender, EventArgs e)
 {
     BookDT                 = BookAdapter.Select_By_Publication(drppublication.SelectedItem.Text);
     drpbook.DataSource     = BookDT;
     drpbook.DataTextField  = "Bookname";
     drpbook.DataValueField = "Bookid";
     drpbook.DataBind();
     drpbook.Items.Insert(0, "SELECT");
 }
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     MultiView1.ActiveViewIndex = 1;
     BookDT          = BookAdapter.Select_BY_BID(Convert.ToInt32(e.CommandArgument.ToString()));
     lblbname.Text   = BookDT.Rows[0]["Bookname"].ToString();
     lblauthor.Text  = BookDT.Rows[0]["author"].ToString();
     lblbran.Text    = BookDT.Rows[0]["branch"].ToString();
     lblpub.Text     = BookDT.Rows[0]["publication"].ToString();
     lblprice.Text   = BookDT.Rows[0]["price"].ToString();
     lblqnt.Text     = BookDT.Rows[0]["Quantities"].ToString();
     lblaqnt.Text    = BookDT.Rows[0]["availableqnt"].ToString();
     lblrqnt.Text    = BookDT.Rows[0]["rentqnt"].ToString();
     lbldetail.Text  = BookDT.Rows[0]["Detail"].ToString();
     Image2.ImageUrl = BookDT.Rows[0]["Image"].ToString();
 }
    protected void Button12_Click(object sender, EventArgs e)
    {
        if (drppublication.SelectedIndex == 0)
        {
            lblmsg.Text      = "Select Student";
            lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1;
        }
        else if (drpbook.SelectedIndex == 0)
        {
            lblmsg.Text      = "Select Book";
            lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1;
        }
        else
        {
            MultiView1.ActiveViewIndex = 0;
            BookDT            = BookAdapter.Select_By_BNAM(drpbook.SelectedItem.Text);
            ViewState["BBID"] = BookDT.Rows[0]["BookID"].ToString();
            lblbname.Text     = BookDT.Rows[0]["Bookname"].ToString();
            lblauthor.Text    = BookDT.Rows[0]["author"].ToString();
            lblbran.Text      = BookDT.Rows[0]["branch"].ToString();
            lblpub.Text       = BookDT.Rows[0]["publication"].ToString();
            lblprice.Text     = BookDT.Rows[0]["price"].ToString();

            Image2.ImageUrl = BookDT.Rows[0]["Image"].ToString();

            SDT             = SAdapter.Select_By_SID(Convert.ToInt32(drppublication.SelectedValue));
            lblstudent.Text = SDT.Rows[0]["Studentname"].ToString();

            RDT               = RAdapter.Select_SID_BName_Status(drpbook.SelectedItem.Text, Convert.ToInt32(drppublication.SelectedValue), 0);
            lbldays.Text      = RDT.Rows[0]["Days"].ToString();
            lblidate.Text     = RDT.Rows[0]["IssueDate"].ToString();
            ViewState["RRID"] = RDT.Rows[0]["rid"].ToString();

            int iday = Convert.ToDateTime(RDT.Rows[0]["IssueDate"].ToString()).Day;
            int rday = System.DateTime.Now.Day;

            int pday = rday - iday;
            if (pday > Convert.ToInt32(lbldays.Text))
            {
                lblpanalty.Text = "Yes";
            }
            else

            {
                lblpanalty.Text = "NO";
            }
        }
    }
 protected void btnviewpublication_Click(object sender, EventArgs e)
 {
     if (drppublication.SelectedIndex == 0)
     {
         GridView1.DataSource = null;
         GridView1.DataBind();
         lblmsg.Text      = "Select Publication";
         lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1;
     }
     else
     {
         MultiView1.ActiveViewIndex = 0;
         BookDT = BookAdapter.Select_By_Publication(drppublication.SelectedItem.Text);
         GridView1.DataSource = BookDT;
         GridView1.DataBind();
         lblmsg0.Text = GridView1.Rows.Count.ToString() + " - Records Found";
     }
 }
    protected void btnviewbranch_Click(object sender, EventArgs e)
    {
        if (drpbranch.SelectedIndex == 0)
        {
            lblmsg.Text          = "Select Branch";
            lblmsg.ForeColor     = System.Drawing.Color.Red;
            GridView1.DataSource = null;
            GridView1.DataBind(); MultiView1.ActiveViewIndex = -1;
        }
        else
        {
            BookDT = BookAdapter.Select_By_Branch(drpbranch.SelectedItem.Text);
            GridView1.DataSource = BookDT;
            GridView1.DataBind();
            lblmsg0.Text = GridView1.Rows.Count.ToString() + " - Records Found";

            MultiView1.ActiveViewIndex = 0;
        }
    }
示例#7
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int bid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);

        PubDT = PubAdapter.Select_By_PID(bid);

        BDT = BAdapter.Select_By_Publication(PubDT.Rows[0]["publication"].ToString());
        if (BDT.Rows.Count > 0)
        {
            lblmsg.Text = "Please delete first books";
        }
        else
        {
            PubAdapter.Delete(bid);
            lblmsg.Text          = "Publication Deleted";
            PubDT                = PubAdapter.Select();
            GridView1.DataSource = PubDT;
            GridView1.DataBind();
        }
    }
    protected void btnissue_Click(object sender, EventArgs e)
    {
        try
        {
            if (TextBox1.Text == "")
            {
                lblissue.Text = "Enter Days";
            }
            else
            {
                if (Convert.ToInt32(lblaqnt.Text) == 0)
                {
                    lblissue.Text = "Book Stock Empty";
                }
                else
                {
                    RDT = RAdapter.Select_SID_BName_Status(lblbname.Text, Convert.ToInt32(drpstudent.SelectedValue), 0);

                    if (RDT.Rows.Count != 0)
                    {
                        lblissue.Text = "Student can't get copies of same book !!";
                    }
                    else
                    {
                        RDT = RAdapter.Select_by_Status_and_SID(Convert.ToInt32(drpstudent.SelectedValue), 0);
                        if (RDT.Rows.Count == 3)
                        {
                            lblissue.Text = "A student has maximum 3 books";
                        }
                        else
                        {
                            RAdapter.Insert(lblbname.Text, Convert.ToInt32(drpstudent.SelectedValue), Convert.ToInt32(TextBox1.Text));


                            BookAdapter.BOOK_ISSUE_TO_STUDENT(Convert.ToInt32(ViewState["BBID"].ToString()));
                            lblissue.Text = "Book Issued to " + drpstudent.SelectedItem.Text;

                            BookDT            = BookAdapter.Select_BY_BID(Convert.ToInt32(ViewState["BBID"]));
                            ViewState["BBID"] = BookDT.Rows[0]["BookID"].ToString();
                            lblbname.Text     = BookDT.Rows[0]["Bookname"].ToString();
                            lblauthor.Text    = BookDT.Rows[0]["author"].ToString();
                            lblbran.Text      = BookDT.Rows[0]["branch"].ToString();
                            lblpub.Text       = BookDT.Rows[0]["publication"].ToString();
                            lblprice.Text     = BookDT.Rows[0]["price"].ToString();
                            lblqnt.Text       = BookDT.Rows[0]["Quantities"].ToString();
                            lblaqnt.Text      = BookDT.Rows[0]["availableqnt"].ToString();
                            lblrqnt.Text      = BookDT.Rows[0]["rentqnt"].ToString();
                            lbldetail.Text    = BookDT.Rows[0]["Detail"].ToString();
                            Image2.ImageUrl   = BookDT.Rows[0]["Image"].ToString();

                            TextBox1.Text = "";
                            drpstudent.Items.Clear();
                            drpstudent.Items.Insert(0, "SELECT");
                            BDT = BAdapter.SelectBranch();
                            drpbranch.DataSource     = BDT;
                            drpbranch.DataTextField  = "Branchname";
                            drpbranch.DataValueField = "Branchid";
                            drpbranch.DataBind();
                            drpbranch.Items.Insert(0, "SELECT");
                        }
                    }
                }
            }
        }
        catch {
            lblissue.Text = "Sorry !!! Error !!!";
        }
    }