protected void btnSave_Click(object sender, EventArgs e) { //Adding New Records if ((txtId.Text != "") || (txtName.Text != "") || (txtSid.Text != "") || (txtBname.Text != "") || (txtAname.Text != "") || (txtprice.Text != "")) { try { ServiceReference1.Book bk = new ServiceReference1.Book(); bk.Id = txtId.Text; bk.student_name = txtName.Text; bk.student_id = txtSid.Text; bk.book_name = txtBname.Text; bk.author_name = txtAname.Text; bk.price = txtprice.Text; ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); lblMsg.Text = "ID: " + bk.Id + ", " + client.AddRecord(bk); } catch (Exception ex) { lblMsg.Text = "ID must be unique! "; } } else { lblMsg.Text = "All fields are mandatory! "; lblMsg.ForeColor = System.Drawing.Color.Red; } }
protected void btnDelete_Click(object sender, EventArgs e) { ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); ServiceReference1.Book bk = new ServiceReference1.Book(); bk.Id = txtSearch.Text.Trim(); string result = client.DeleteRecords(bk); if (result == "Record Deleted Successfully!") { BindGridData(); lblSearchResult.Text = "ID: " + txtSearch.Text.Trim() + "Deleted Successfully!"; } else { lblSearchResult.Text = "ID: " + txtSearch.Text.Trim() + "Not Found!"; } }