コード例 #1
0
ファイル: ItemPanel.aspx.cs プロジェクト: Emtey/BootCamp
    protected void btnAddItem_Click(object sender, EventArgs e)
    {
        try
        {
            int    isbn     = Convert.ToInt32(txtISBN.Text);
            string title    = txtTitle.Text;
            string author   = txtAuthor.Text;
            string loanable = "";
            if (chkLoanable.Checked)
            {
                loanable = "Y";
            }
            else
            {
                loanable = "N";
            }

            myDb.AddItem(isbn, title, author, loanable);
            Label lbl = (Label)Page.Master.FindControl("lblStatus");
            lbl.Text      = "Item Added";
            lbl.ForeColor = Color.Blue;
        }
        catch (LibraryException ex)
        {
            if (ex.LibraryErrorCode == ErrorCode.AddItemFailed)
            {
                StringBuilder myString = new StringBuilder();
                myString.Append("Add Item Failed");
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = myString.ToString();
                lbl.ForeColor = Color.Red;
            }
        }
    }
コード例 #2
0
ファイル: Service.cs プロジェクト: Emtey/BootCamp
    public void AddItem(int isbn, string title, string author, string loanable)
    {
        DBInteraction db = new DBInteraction();

        try
        {
            db.AddItem(isbn, title, author, loanable);
        }
        catch (LibraryException ex)
        {
            throw new SoapException(ex.Message, ExceptionCodes.AddItemFailed);
        }
    }