protected void btnSave_Click(object sender, EventArgs e) { try { switch (RowID) { case 0: billingTypeProvider.Add( txtDescription.Text, Convert.ToInt16(txtAutoPayDay.Text), chkIsActive.Checked); break; default: if (chkIsActive.Checked == false && customerProvider.GetCustomersByBillingType(RowID).Count() > 0) { mvwForm.ActiveViewIndex = 0; WebFormHelper.SetLabelTextWithCssClass(lblMessage, "Cannot set this billing type to inactive since there are customers use this billing type", LabelStyleNames.ErrorMessage); return; } billingTypeProvider.Update( RowID, txtDescription.Text, Convert.ToInt16(txtAutoPayDay.Text), chkIsActive.Checked); break; } Refresh(); } catch (Exception ex) { mvwForm.ActiveViewIndex = 0; WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage); } }