protected void btnSave_Click(object sender, EventArgs e) { hideDIV(); bool trackAll = true; string branchName = null; string districtName = null; if (txtBranchName.Text != "") { branchName = txtBranchName.Text; } else { trackAll = false; infoPanel.Visible = true; InfoDIV.Visible = true; lblInformationMsg.Text = "Branch Name can't be Empty!"; } if (DropDownDistrictList.SelectedValue != "-1") { districtName = DropDownDistrictList.SelectedValue; } else { trackAll = false; infoPanel.Visible = true; InfoDIV.Visible = true; lblInformationMsg.Text = "District Name must be selected!"; } if (!trackAll) { return; } Branch branch = new Branch(); branch.branchName = branchName; branch.district = districtName; BranchManager branchManager = new BranchManager(branch); //call sote to DB method. TransactionResponse response = branchManager.addNewBranch(); //if store to DB is successful if (response.isSuccessful()) { hideDIV(); infoPanel.Visible = true; SucessDIV.Visible = true; lblSuccessMessage.Text = "Branch Successfully Registered!"; btnSave.Enabled = false; } // show error message to a user. else { hideDIV(); infoPanel.Visible = true; WarnDIV.Visible = true; //Display Exception here lblWarningMsg.Text = response.getMessage(); } }