protected void gridRoles_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("DeleteRow")) { string roleName = e.CommandArgument.ToString(); try { if (Roles.GetUsersInRole(roleName).Length > 0) { lblStatus.Text = String.Format("Cannot delete role name {0} since it already has users associated with it", roleName); } else { try { UserManagement.DeleteRole(roleName); } catch (Exception ex) { ApplicationLogger.Write(ex); DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, ex.Message, LabelStyleNames.ErrorMessage); } } } catch (Exception ex) { ApplicationLogger.Write(ex); DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, ex.Message, LabelStyleNames.ErrorMessage); } } BindToGrid(null); }
private void DoResetPassword() { try { string userName = ViewState["_UserName"].ToString(); UserManagement.UnlockUser(userName); string newPassword = UserManagement.ResetPassword(userName); lblNewPassword.Text = String.Format("New Password for <strong>{0}</strong> is <strong style='color:green;'>{1}</strong>", userName, newPassword); btnDoReset.Enabled = false; } catch (Exception ex) { DynamicControlBinding.SetLabelTextWithCssClass(lblNewPassword, String.Format("<b>Error:</b> {0}", ex.Message), LabelStyleNames.ErrorMessage); } }
protected void btnDoReset_Click(object sender, EventArgs e) { try { string userName = ViewState["_UserName"].ToString(); //UserManagement.UnlockUser(userName); string newPassword = SecurityService.ResetPassword(userName); lblNewPassword.Text = String.Format("New Password for <strong>{0}</strong> is <strong style='color:green;'>{1}</strong>", userName, newPassword); btnDoReset.Enabled = false; } catch (Exception ex) { DynamicControlBinding.SetLabelTextWithCssClass(lblNewPassword, String.Format("<b>Error:</b> {0}", ex.Message), LabelStyleNames.ErrorMessage); LogService.ErrorException(GetType().FullName, ex); } }
void IBasicCommand.Delete() { int[] arrayOfID = DynamicControlBinding.GetRowIdForDeletion(gvwMaster); try { using (var ctx = new FitnessDataContext()) { ctx.Alerts.DeleteAllOnSubmit(ctx.Alerts.Where(row => arrayOfID.Contains(row.ID))); ctx.SubmitChanges(); } } catch (Exception ex) { DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, ex.Message, LabelStyleNames.ErrorMessage); ApplicationLogger.Write(ex); } ((IBasicCommand)this).Refresh(); }
void IBasicCommand.Save() { if (this.IsValid) { try { using (var ctx = new FitnessDataContext()) { Alert entity = RowID == 0 ? new Alert() : ctx.Alerts.Single(row => row.ID == RowID); entity.Description = txtDescription.Text; entity.StartDate = CalendarPopup1.SelectedValue.Value; entity.EndDate = chkInfinite.Checked ? null : CalendarPopup2.SelectedValue; entity.Active = chkActive.Checked; if (RowID == 0) { EntityHelper.SetAuditFieldForInsert(entity, User.Identity.Name); ctx.Alerts.InsertOnSubmit(entity); } else { EntityHelper.SetAuditFieldForUpdate(entity, User.Identity.Name); } ctx.SubmitChanges(); } DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, "Data has been saved.", LabelStyleNames.InfoMessage); } catch (Exception ex) { DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, ex.Message, LabelStyleNames.ErrorMessage); ApplicationLogger.Write(ex); } finally { ((IBasicCommand)this).Refresh(); } } }
protected void btnSave_Click(object sender, EventArgs e) { try { Validate("AddEdit"); if (IsValid) { if (calDateOfBirth.SelectedDate > DateTime.Today) { DynamicControlBinding.SetLabelTextWithCssClass( lblMessageAddEdit, "Invalid date of birth", LabelStyleNames.ErrorMessage); return; } if (ddlBillingType.SelectedItem.Text.ToUpper() == "AUTO PAYMENT") { cuvCreditCardNo.Validate(); if (cuvCreditCardNo.IsValid) { if (ddlBillingCardType.SelectedIndex == 0 || ddlBillingBank.SelectedIndex == 0 || String.IsNullOrEmpty(txtBillingCardHolderID.Text) || String.IsNullOrEmpty(txtBillingCardHolderName.Text) || String.IsNullOrEmpty(txtBillingCardNo.Text)) { DynamicControlBinding.SetLabelTextWithCssClass( lblMessageAddEdit, "Auto payment information is incomplete", LabelStyleNames.ErrorMessage); return; } } if (txtDuesAmount.Text.ToDefaultNumber <decimal>() == 0 || ddlMonthlyDuesItem.SelectedValue.ToDefaultNumber <int>() == 0) { DynamicControlBinding.SetLabelTextWithCssClass( lblMessageAddEdit, "Both <b>Dues Amount</b> and <b>Monthly Dues Item</b> fields must be specified if billing type is manual payment", LabelStyleNames.ErrorMessage); return; } } if (chkGenerateNewBarcodeCustomer.Checked) { if (chkFather.Checked && ( String.IsNullOrEmpty(txtFatherName.Text))) { DynamicControlBinding.SetLabelTextWithCssClass( lblStatusParent, "Parent Information (Father) is incomplete", cssClass: LabelStyleNames.ErrorMessage); return; } if (chkMother.Checked && ( String.IsNullOrEmpty(txtMotherName.Text))) { DynamicControlBinding.SetLabelTextWithCssClass( lblStatusParent, "Parent Information (Mother) is incomplete", LabelStyleNames.ErrorMessage); return; } } switch (RowID) { case 0: ContractService.Add( calDate.SelectedDate.GetValueOrDefault(), !chkGenerateNewBarcodeCustomer.Checked, txtCustomerBarcode.Text, chkIsTransfer.Checked, txtCustomerFirstName.Text, txtCustomerLastName.Text, calDateOfBirth.SelectedDate.GetValueOrDefault(), txtIDCardNo.Text, ddlOccupation.SelectedIndex == 0 ? (int?)null :Convert.ToInt32(ddlOccupation.SelectedValue), Convert.ToInt32(ddlFindBranch.SelectedValue), Convert.ToInt32(ddlPackage.SelectedValue), null, calEffectiveDate.SelectedDate.GetValueOrDefault(), Convert.ToInt32(ddlBillingType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingCardType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingBank.SelectedValue), txtBillingCardNo.Text, txtBillingCardHolderName.Text, txtBillingCardHolderID.Text, new DateTime(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue), DateTime.DaysInMonth(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue))), 'P', Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlMonthlyDuesItem.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtDuesAmount.Value), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtAdditionalDuesAmount.Value), calNextDuesDate.SelectedDate.GetValueOrDefault(), calExpiredDate.SelectedDate.GetValueOrDefault(), txtHomePhone.Text, txtCellPhone.Text, txtWorkPhone.Text, txtMailingAddress.Text, txtMailingZipCode.Text, txtAddress.Text, txtZipCode.Text, Convert.ToInt32(ddlArea.SelectedValue), chkFather.Checked, txtFatherName.Text, txtIDCardNoFather.Text, chkFatherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateFather.SelectedDate, txtFatherPhone.Text, txtFatherEmail.Text, chkMother.Checked, txtMotherName.Text, txtIDCardNoMother.Text, chkMotherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateMother.SelectedDate, txtMotherPhone.Text, txtMotherEmail.Text, txtNotes.Text, ddlRenewalOrUpgrade.SelectedValue ); break; default: ContractService.Update( RowID, Convert.ToInt32(ddlPackage.SelectedValue), calDate.SelectedDate.GetValueOrDefault(), calEffectiveDate.SelectedDate.GetValueOrDefault(), txtIDCardNo.Text, ddlOccupation.SelectedIndex == 0 ? (int?)null : Convert.ToInt32(ddlOccupation.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingCardType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingBank.SelectedValue), txtBillingCardNo.Text, txtBillingCardHolderName.Text, txtBillingCardHolderID.Text, new DateTime(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue), DateTime.DaysInMonth(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue))), txtHomePhone.Text, txtCellPhone.Text, txtWorkPhone.Text, txtMailingAddress.Text, txtMailingZipCode.Text, txtAddress.Text, txtZipCode.Text, Convert.ToInt32(ddlArea.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlMonthlyDuesItem.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtDuesAmount.Value.GetValueOrDefault()), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtAdditionalDuesAmount.Value.GetValueOrDefault()), calNextDuesDate.SelectedDate.GetValueOrDefault(), calExpiredDate.SelectedDate.GetValueOrDefault(), chkFather.Checked, txtFatherName.Text, txtIDCardNoFather.Text, chkFatherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateFather.SelectedDate, txtFatherPhone.Text, txtFatherEmail.Text, chkMother.Checked, txtMotherName.Text, txtIDCardNoMother.Text, chkMotherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateMother.SelectedDate, txtMotherPhone.Text, txtMotherEmail.Text, txtNotes.Text ); break; } Refresh(); } } catch (Exception ex) { WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage); LogService.ErrorException(GetType().FullName, ex); } }