public ManageCountryCity()
        {
            try
            {
                InitializeComponent();

                if (BindCountry() == 0)
                {
                    ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "No countries are available to show. Please add a new country!", "Message");
                    btn_new_country.PerformClick();
                }

                btn_new_country.Enabled    = btn_new_city.Enabled = hasAccessInsert;
                btn_delete_country.Enabled = btn_delete_city.Enabled = hasAccessDelete;
                btn_save_country.Enabled   = btn_save_city.Enabled = (hasAccessInsert || hasAccessUpdate);
            }
            catch (Exception ex)
            {
                AuditFactory.AuditLog(ex);
                ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
            }
        }
 private void btn_new_organisation_Click(object sender, EventArgs e)
 {
     try
     {
         if (FormDirty)
         {
             if (ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.YesNo, UniversalVariables.UnsavedData) == DialogResult.Yes)
             {
                 ResetForm(false, true, false, false, true);
             }
         }
         else
         {
             ResetForm(false, true, false, false, true);
         }
     }
     catch (Exception ex)
     {
         AuditFactory.AuditLog(ex);
         ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
     }
 }
Exemple #3
0
        private void lst_categories_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (lst_categories.SelectedIndex > -1)
                {
                    DataRowView currentRow = (lst_categories.SelectedItem as DataRowView);
                    if (currentRow != null)
                    {
                        txt_new_category.Text = currentRow.Row["Category"].ToString();
                        CategoryID            = (int)currentRow.Row["Key"];

                        BindSubCategory(CategoryID);
                        FormDirty = false;
                    }
                }
            }
            catch (Exception ex)
            {
                AuditFactory.AuditLog(ex);
                ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
            }
        }
        public ManageUsers()
        {
            try
            {
                InitializeComponent();

                if (BindUser() == 0)
                {
                    ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "No users are available to show. Please add a new user!", "Message");
                }

                BindUserAccessTypes();

                btn_create.Enabled = hasAccessInsert;
                btn_delete.Enabled = hasAccessDelete;
                btn_save.Enabled   = (hasAccessInsert || hasAccessUpdate);
            }
            catch (Exception ex)
            {
                AuditFactory.AuditLog(ex);
                ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
            }
        }
Exemple #5
0
        private void btn_update_password_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet user = new BL_User().checkLogin(new ML_User {
                    LoginId = UniversalVariables.Username, Password = txt_current_pwd.Text
                });

                if (user.Tables[0].Rows.Count == 1 && user.Tables[1].Rows.Count > 0)
                {
                    if (vp_password.Validate() && txt_retype_pwd.Text == txt_password.Text)
                    {
                        new BL_User().resetPassword(new ML_User()
                        {
                            Key = UniversalVariables.UserKey, Password = txt_password.Text, LoginId = UniversalVariables.Username, UpdatedDate = DateTime.Now.GetFormattedDateString(UniversalVariables.MySQLDateFormat)
                        });
                        FormDirty = false;
                        ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Information, "Password changed successfully! The new password will be available from next login.", "Success");
                        this.Close();
                    }
                    else
                    {
                        ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The passwords you have entered do not match or there are errors in the password constraints. Please re-check!", "Error");
                    }
                }
                else
                {
                    ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The current password you have entered does not match what is stored in the database. Please re-check. If the problem persists contact the System Administrator.", "Error");
                    txt_current_pwd.Focus();
                }
            }
            catch (Exception ex)
            {
                AuditFactory.AuditLog(ex);
                ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
            }
        }
Exemple #6
0
        private void btn_delete_category_Click(object sender, EventArgs e)
        {
            try
            {
                if (CategoryID > 0)
                {
                    if (new BL_OrganisationCategory().selectUsage(new ML_OrganisationCategory {
                        Key = CategoryID
                    }) == 0)
                    {
                        if (ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Warning, string.Format("Are you sure you want to delete the category {0} from the database? WARNING: All its sub categories will also be deleted!", lst_categories.Text), "Warning") == System.Windows.Forms.DialogResult.OK)
                        {
                            new BL_OrganisationSubCategory().deleteByCategory(new ML_OrganisationSubCategory {
                                CategoryKey = CategoryID
                            });
                            new BL_OrganisationCategory().delete(new ML_OrganisationCategory {
                                Key = CategoryID
                            });

                            ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Information, string.Format("Category {0} and all its sub categories have been successfully deleted.", lst_categories.Text), "Deletion Successful.");

                            ResetCategoryForm();
                            BindCategory();
                        }
                    }
                    else
                    {
                        ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The category you are trying to delete has been referenced in one or more organisation records. This category cannot be deleted.", "Error");
                    }
                }
            }
            catch (Exception ex)
            {
                AuditFactory.AuditLog(ex);
                ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
            }
        }
 private void lst_users_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (lst_users.SelectedIndex > -1)
         {
             DataRowView currentRow = (lst_users.SelectedItem as DataRowView);
             if (currentRow != null)
             {
                 SelectedID                     = (int)currentRow.Row["Key"];
                 txt_name.Text                  = currentRow.Row["Name"].ToString();
                 txt_login_name.Text            = currentRow.Row["LoginId"].ToString();
                 txt_nic.Text                   = currentRow.Row["NIC"].ToString();
                 cbo_user_access_type.EditValue = currentRow.Row["UserAccessTypeKey"].ToString().IsEmpty() ? null : currentRow.Row["UserAccessTypeKey"];
                 FormDirty = false;
             }
         }
     }
     catch (Exception ex)
     {
         AuditFactory.AuditLog(ex);
         ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
     }
 }
Exemple #8
0
 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 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);
            }
        }
Exemple #11
0
        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);
            }
        }
Exemple #12
0
        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);
            }
        }