コード例 #1
0
ファイル: IssueBook.aspx.cs プロジェクト: rwells/LMS
    protected void btnIssue_Click(object sender, EventArgs e)
    {
        lblEMsg.Visible = false;
        string[] iBook;
        try
        {
            SqlDataReader sdr;
            Profile pro = new Profile();

            int aQty = Convert.ToInt32(txtQuantity.Text.ToString());
            if (aQty == 0)
            {
                lblEMsg.Visible = true;
                lblEMsg.Text = "This book is Out of stock, please select a different book.";
                return;
            }

            string sql = "SELECT Count(1) FROM Book_Transaction WHERE Book_ID = '" + LstBook.SelectedItem.Text + "' And Member_ID = '" + DropDownList1.SelectedItem.Text  + "' And Actual_Return_Date Is Null";
            sdr = pro.ReturnMDetails(sql);
            sdr.Read();
            int iB = (int)sdr[0];
            if (iB > 0)
            {
                lblEMsg.Visible = true;
                lblEMsg.Text = "This book is already issued, please select a different book.";
                return;
            }
            sdr.Close();

            //Insert the data.
            iBook = new string[4];

            iBook[0] = LstBook.SelectedItem.Text;
            iBook[1] = DropDownList1.SelectedItem.Text;
            iBook[2] = txtIDate.Text;
            iBook[3] = txtRDate.Text;

            bool status;
            status = pro.IssueBook(iBook);

            if (status == false)
            {
                lblEMsg.Visible = true;
                lblEMsg.Text = "Book Issuing Failed";
            }
            lblEMsg.Visible = true;
            lblEMsg.Text = "Book Issued.";
            DropDownList1.Text = "";
            LstBook.Text = "";
            txtBTitle.Text = "";
            txtAuthor.Text = "";
            txtPub.Text = "";
            txtCat.Text = "";
            txtSup.Text = "";
            txtQuantity.Text = "";
            txtPrice.Text = "";
            txtRDate.Text = "";
            Label9.Text = "";
            return;
        }
        catch (Exception ex)
        {
            lblEMsg.Visible = true;
            lblEMsg.Text = ex.Message;
        }
    }