public static bool CheckFormDirtyClose(Func <bool> inpMethod, bool isDirty) { return(isDirty ? ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.YesNo, UniversalVariables.UnsavedData) == DialogResult.Yes ? inpMethod() : false : inpMethod()); }
private void ManageUserAccessTypes_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { e.Cancel = !ApplicationUtilities.CheckFormDirtyClose(CloseFormWithChecks, FormDirty); }
private void UserAccessLevelsToolStripMenuItem_Click_1(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new ManagePrivileges(), this); }
private void changePasswordToolStripMenuItem_Click_1(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new ResetPassword(), this); }
private void ManageConfigurationsToolStripMenuItem_Click_1(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new ManageConfigurations(), this); }
private void usageLogToolStripMenuItem_Click(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new ViewSessions(), this); }
private void ManageCountriesCitiesToolStripMenuItem_Click(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new ManageCountryCity(), this); }
private void ContactAdminToolStripMenuItem_Click(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new About(), this); }
private void ManageOrganisationSectorsToolStripMenuItem_Click(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new ManageCategoriesSubCategories(), this); }
private void MemberToolStripMenuItem_Click(object sender, EventArgs e) { ApplicationUtilities.DisplayForm(new MemberDetails(), this); }
private void ManageOrganisations_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = !ApplicationUtilities.CheckFormDirtyClose(CloseFormWithChecks, FormDirty); }
private void btn_save_organisation_Click(object sender, EventArgs e) { try { if (!IsNewRecord && !hasAccessUpdate) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "You have no save rights.", "Access Denied"); return; } if (txt_new_organisation.IsNotEmpty()) { var CityKey = cbo_city.ToIntNullable(); if (IsNewRecord) { if (new BL_Organisation().selectNewRecord(new ML_Organisation { Organisation = txt_new_organisation.Text, Key = (SelectedID == 0 ? (int?)null : SelectedID) }).Rows.Count < 1) { int?insertedID = null; if (txt_address.IsNotEmpty()) { if (cbo_city.IsNotEmpty() && cbo_country.IsNotEmpty()) { insertedID = new BL_Address().insert(new ML_Address { CityKey = cbo_city.ToIntNullable(), UserKey = UniversalVariables.UserKey, Address = txt_address.Text.Trim() }); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "Error saving address. The address, city and country values need to be filled. Please re-check!", "Error"); return; } } else if (cbo_city.IsNotEmpty() || cbo_country.IsNotEmpty()) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "Error saving address. The address, city and country values need to be filled. Please re-check!", "Error"); return; } new BL_Organisation().insert(new ML_Organisation() { Organisation = txt_new_organisation.Text.Trim(), SubCategoryKey = cbo_sub_category.ToIntNullable(), Website = txt_website.Text.Trim(), AddressKey = insertedID }); LastOrganization = txt_new_organisation.Text; BindOrganisation(); ResetForm(true, true, hasAccessInsert, hasAccessDelete, false); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered organisation is already in the database. Please re-check!", "Error"); } } else if (SelectedID > 0) { if (new BL_Organisation().select(new ML_Organisation { Organisation = txt_new_organisation.Text, Key = (SelectedID == 0 ? (int?)null : SelectedID) }).Rows.Count == 1) { DataRowView currentRow = (lst_organisation.SelectedItem as DataRowView); int addressKey = currentRow.Row["AddressKey"].ToString().IsEmpty() ? 0 : currentRow.Row["AddressKey"].ToString().ToInt(); if (txt_address.IsNotEmpty()) { if (cbo_city.IsNotEmpty() && cbo_country.IsNotEmpty()) { if (addressKey == 0) { addressKey = new BL_Address().insert(new ML_Address { CityKey = cbo_city.ToIntNullable(), UserKey = UniversalVariables.UserKey, Address = txt_address.Text.Trim() }); } else { new BL_Address().update(new ML_Address { Key = Convert.ToInt32(currentRow.Row["AddressKey"]), CityKey = cbo_city.ToIntNullable(), UserKey = UniversalVariables.UserKey, Address = txt_address.Text.Trim() }); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "Error saving address. The address, city and country values need to be filled. Please re-check!", "Error"); return; } } else if (cbo_city.IsNotEmpty() || cbo_country.IsNotEmpty()) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "Error saving address. The address, city and country values need to be filled. Please re-check!", "Error"); return; } new BL_Organisation().update(new ML_Organisation { Key = SelectedID, Organisation = txt_new_organisation.Text.Trim(), SubCategoryKey = cbo_sub_category.ToIntNullable(), Website = txt_website.Text.Trim(), AddressKey = txt_address.IsNotEmpty() ? addressKey : (int?)null }); LastOrganization = txt_new_organisation.Text; BindOrganisation(); ResetForm(true, true, hasAccessInsert, hasAccessDelete, false); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered organisation is already in the database. Please re-check!", "Error"); } } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "Null value detected for organisation. Please re-check!", "Error!"); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
private void btn_save_Click(object sender, EventArgs e) { try { if (!IsNewRecord && !hasAccessUpdate) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "You have no save rights.", "Access Denied"); return; } using (DataTable Table = new BL_User().selectUsage(new ML_User { Key = (SelectedID == 0 ? null : (int?)SelectedID), LoginId = txt_login_name.Text })) { if (IsNewRecord) { //New record - insert if (UserWithPasswordValidation.Validate() && UserValidation.Validate()) { if (Table.Rows.Count < 1) { new BL_User().insert(new ML_User() { LoginId = txt_login_name.Text.Trim(), Name = txt_name.Text.Trim(), NIC = txt_nic.Text.Trim(), Password = (txt_password.IsEmpty() ? null : txt_password.Text), UserAccessTypeKey = (int)cbo_user_access_type.EditValue, UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); LastUser = txt_name.Text; BindUser(); ResetForm(false, true, true, hasAccessInsert, hasAccessDelete, true); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered user login name is already in the database. Please re-check!", "Error"); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "None of the values can be null / invalid. Please re-check!", "Error!"); } } else { //Update if (UserValidation.Validate() && SelectedID > 0) { if (Table.Rows.Count <= 1) { bool IsPasswordReset; if (txt_password.IsNotEmpty()) { IsPasswordReset = UserWithPasswordValidation.Validate(); if (!IsPasswordReset) { return; } } else { IsPasswordReset = false; } new BL_User().update(new ML_User { LoginId = txt_login_name.Text.Trim(), Name = txt_name.Text.Trim(), NIC = txt_nic.Text.Trim(), UserAccessTypeKey = Convert.ToInt32(cbo_user_access_type.EditValue), UserKey = UniversalVariables.UserKey, Key = SelectedID, Password = IsPasswordReset ? (txt_password.IsEmpty() ? null : txt_password.Text) : null, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); LastUser = txt_name.Text.Trim(); BindUser(); ResetForm(false, true, true, hasAccessInsert, hasAccessDelete, true); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered user login name is already in the database. Please re-check!", "Error"); } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "None of the values can be null / invalid. Please re-check!", "Error"); } } } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
private void bindConfigurations() { try { using (DataTable dt = new BL_Configurations().select()) { #region Membership No EnumerableRowCollection <DataRow> MembershipNoIndex = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.MembershipNoIndexStr select myRow; if (MembershipNoIndex.Any()) { rtb_mem_no_desc.Text = MembershipNoIndex.First()["Description"].ToString(); txt_mem_no_value.Text = MembershipNoIndex.First()["ConfigurationValue"].ToString(); txt_mem_no_conf_by.Text = MembershipNoIndex.First()["Name"].ToString(); txt_mem_no_conf_date.Text = Convert.ToDateTime(MembershipNoIndex.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region Membership Date EnumerableRowCollection <DataRow> MembershipDate = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.MembershipDateStr select myRow; if (MembershipDate.Any()) { txt_mem_date_desc.Text = MembershipDate.First()["Description"].ToString(); txt_mem_date_value.EditValue = Convert.ToDateTime(MembershipDate.First()["ConfigurationValue"].ToString()).ToShortDateString(); txt_mem_date_conf_by.Text = MembershipDate.First()["Name"].ToString(); txt_mem_date_conf_date.Text = Convert.ToDateTime(MembershipDate.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region Internet Connection EnumerableRowCollection <DataRow> InternetConnection = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.InternetConnectionStr select myRow; if (InternetConnection.Any()) { txt_int_con_desc.Text = InternetConnection.First()["Description"].ToString(); tsw_int_con.IsOn = Convert.ToBoolean(InternetConnection.First()["ConfigurationValue"].ToString()); txt_int_con_conf_by.Text = InternetConnection.First()["Name"].ToString(); txt_int_con_conf_date.Text = Convert.ToDateTime(InternetConnection.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region Receipt No EnumerableRowCollection <DataRow> ReceiptNo = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.ReceiptNoStr select myRow; if (ReceiptNo.Any()) { txt_rec_no_desc.Text = ReceiptNo.First()["Description"].ToString(); txt_rec_no_value.Text = ReceiptNo.First()["ConfigurationValue"].ToString(); txt_rec_no_conf_by.Text = ReceiptNo.First()["Name"].ToString(); txt_rec_no_conf_date.Text = Convert.ToDateTime(ReceiptNo.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region Receipt Amount EnumerableRowCollection <DataRow> ReceiptAmount = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.ReceiptAmountStr select myRow; if (ReceiptAmount.Any()) { txt_rec_amount_desc.Text = ReceiptAmount.First()["Description"].ToString(); lst_receipt_amount.Items.Clear(); lst_receipt_amount.Items.AddRange(ReceiptAmount.First()["ConfigurationValue"].ToString().Split(new char[] { ';' })); txt_rec_amount_conf_by.Text = ReceiptAmount.First()["Name"].ToString(); txt_rec_amount_conf_date.Text = Convert.ToDateTime(ReceiptAmount.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region System Timeout EnumerableRowCollection <DataRow> TimeoutPeriod = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.TimeoutPeriodStr select myRow; if (TimeoutPeriod.Any()) { txt_timeout_desc.Text = TimeoutPeriod.First()["Description"].ToString(); string[] time = TimeoutPeriod.First()["ConfigurationValue"].ToString().Split(new char[] { ':' }); nud_timeout_hrs.Text = time[0]; nud_timeout_minutes.Text = time[1]; nud_timeout_seconds.Text = time[2]; txt_timeout_conf_by.Text = TimeoutPeriod.First()["Name"].ToString(); txt_timeout_conf_date.Text = Convert.ToDateTime(TimeoutPeriod.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region Logout Confirmation Timeout EnumerableRowCollection <DataRow> LogoffPeriod = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.LogoffPeriodStr select myRow; if (LogoffPeriod.Any()) { mem_logout_desc.Text = LogoffPeriod.First()["Description"].ToString(); string[] time = LogoffPeriod.First()["ConfigurationValue"].ToString().Split(new char[] { ':' }); nud_msg_box_minutes.Text = time[1]; nud_msg_box_seconds.Text = time[2]; txt_logout_conf_by.Text = LogoffPeriod.First()["Name"].ToString(); txt_logout_conf_date.Text = Convert.ToDateTime(LogoffPeriod.First()["UpdatedDate"].ToString()).ToShortDateString(); } #endregion #region Default Values EnumerableRowCollection <DataRow> DefaultSalutation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.DefaultSalutationStr select myRow; if (DefaultSalutation.Any()) { mem_def_val_desc.Text = DefaultSalutation.First()["Description"].ToString(); cbo_salutation.EditValue = DefaultSalutation.First()["ConfigurationValue"].ToString(); txt_def_val_conf_by.Text = DefaultSalutation.First()["Name"].ToString(); txt_def_val_conf_date.Text = Convert.ToDateTime(DefaultSalutation.First()["UpdatedDate"].ToString()).ToShortDateString(); } EnumerableRowCollection <DataRow> DefaultCountry = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.DefaultCountryStr select myRow; if (DefaultCountry.Any()) { cbo_country.EditValue = DefaultCountry.First()["ConfigurationValue"].ToString(); cbo_country_EditValueChanged(this, new EventArgs()); } EnumerableRowCollection <DataRow> DefaultCity = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.DefaultCityStr select myRow; if (DefaultCity.Any()) { cbo_city.EditValue = DefaultCity.First()["ConfigurationValue"].ToString(); } #endregion #region Control Validations EnumerableRowCollection <DataRow> TelephoneValidation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.TelephoneValidationStr select myRow; if (TelephoneValidation.Any()) { mem_validations_desc.Text = TelephoneValidation.First()["Description"].ToString(); chk_validations_tel.EditValue = TelephoneValidation.First()["ConfigurationValue"].ToString().ToBool(); txt_validations_conf_by.Text = TelephoneValidation.First()["Name"].ToString(); txt_validations_conf_date.Text = Convert.ToDateTime(TelephoneValidation.First()["UpdatedDate"].ToString()).ToShortDateString(); } EnumerableRowCollection <DataRow> MobileValidation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.MobileValidationStr select myRow; if (MobileValidation.Any()) { chk_validations_mobile.EditValue = MobileValidation.First()["ConfigurationValue"].ToString().ToBool(); } EnumerableRowCollection <DataRow> EmailValidation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.EmailValidationStr select myRow; if (EmailValidation.Any()) { chk_validations_email.EditValue = EmailValidation.First()["ConfigurationValue"].ToString().ToBool(); } #endregion } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
private void btn_save_Click(object sender, EventArgs e) { try { switch (tab_configurations.SelectedTabPage.Text.Trim()) { case "Membership No": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.MembershipNoIndexStr, Description = rtb_mem_no_desc.Text, ConfigurationValue = txt_mem_no_value.Text, UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "Receipt No": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.ReceiptNoStr, Description = txt_rec_no_desc.Text, ConfigurationValue = txt_rec_no_value.Text, UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "Membership Date": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.MembershipDateStr, Description = txt_mem_date_desc.Text, ConfigurationValue = txt_mem_date_value.Text, UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "Internet Connection": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.InternetConnectionStr, Description = txt_int_con_desc.Text, ConfigurationValue = tsw_int_con.IsOn.ToString(), UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "Receipt Amount": string receiptValues = string.Empty; int count = 0; foreach (string rec_val in lst_receipt_amount.Items) { receiptValues = (count == lst_receipt_amount.Items.Count) ? string.Format("{0}{1}", receiptValues, rec_val) : string.Format("{0}{1};", receiptValues, rec_val); count++; } new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.ReceiptAmountStr, Description = txt_rec_amount_desc.Text, ConfigurationValue = receiptValues, UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "System Timeout": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.TimeoutPeriodStr, Description = txt_timeout_desc.Text, ConfigurationValue = string.Format("{0}:{1}:{2}", nud_timeout_hrs.Text.PadLeft(2, '0'), nud_timeout_minutes.Text.PadLeft(2, '0'), nud_timeout_seconds.Text.PadLeft(2, '0')), UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "Logout Confirmation Timeout": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.LogoffPeriodStr, Description = mem_logout_desc.Text, ConfigurationValue = string.Format("{0}:{1}:{2}", "00", nud_msg_box_minutes.Text.PadLeft(2, '0'), nud_msg_box_seconds.Text.PadLeft(2, '0')), UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; case "Default Values": if (cbo_country.EditValue != null && cbo_city.EditValue != null && cbo_salutation.EditValue != null) { new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.DefaultCountryStr, Description = mem_def_val_desc.Text, ConfigurationValue = cbo_country.EditValue.ToString(), UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.DefaultCityStr, Description = mem_def_val_desc.Text, ConfigurationValue = cbo_city.EditValue.ToString(), UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.DefaultSalutationStr, Description = mem_def_val_desc.Text, ConfigurationValue = cbo_salutation.EditValue.ToString(), UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "One or more required values are null. Please re-check!", "Error Saving"); } break; case "Control Validations": new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.TelephoneValidationStr, Description = mem_validations_desc.Text, ConfigurationValue = chk_validations_tel.Checked ? "True" : "False", UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.EmailValidationStr, Description = mem_validations_desc.Text, ConfigurationValue = chk_validations_email.Checked ? "True" : "False", UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); new BL_Configurations().update(new Model.ML_Configurations { ConfigurationName = Configurations.MobileValidationStr, Description = mem_validations_desc.Text, ConfigurationValue = chk_validations_mobile.Checked ? "True" : "False", UserKey = UniversalVariables.UserKey, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat) }); break; default: break; } ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Information, "Configuration settings saved. The new settings will be applied at next login.", "Record Updated"); bindConfigurations(); FormDirty = false; } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }