Ejemplo n.º 1
0
        protected override void populateInputFields()
        {
            UserAccount obj = new UserAccount(selectedRowID());

            itxt_Username.ValueText       = obj.Username;
            itxt_Firstname.ValueText      = obj.Firstname;
            itxt_Lastname.ValueText       = obj.Lastname;
            idtp_Birthdate.Value          = obj.Birthdate;
            itxt_Address1.ValueText       = obj.Address1;
            itxt_Address2.ValueText       = obj.Address2;
            itxt_Email.ValueText          = obj.Email;
            itxt_Phone1.ValueText         = obj.Phone1;
            itxt_Phone2.ValueText         = obj.Phone2;
            itxt_Identification.ValueText = obj.Identification;
            itxt_Height.Value             = obj.Height;
            itxt_Weight.Value             = obj.Weight;
            itxt_Notes.ValueText          = obj.Notes;

            LIBUtil.Desktop.UserControls.InputControl_CheckedListBox.clearCheckedItems(clbUserAccountRoles);
            foreach (DataRow row in UserAccountRoleAssignment.getByUserAccountId(obj.Id).Rows)
            {
                for (int i = 0; i < clbUserAccountRoles.Items.Count; i++)
                {
                    DataRowView item = (DataRowView)clbUserAccountRoles.Items[i];
                    if (item[UserAccountRole.COL_DB_Id].ToString() == row[UserAccountRoleAssignment.COL_DB_UserAccountRoles_Id].ToString())
                    {
                        clbUserAccountRoles.SetItemChecked(i, true);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void update(Guid userAccountID, Guid id, string username, string firstName, string lastName,
                                  string address1, string address2, string phone1, string phone2, string email, DateTime?birthdate, string identification, int height, int weight, string notes, List <Guid?> userAccountRoles)
        {
            UserAccount objOld = new UserAccount(id);
            string      log    = "";

            log = Util.appendChange(log, objOld.Username, username, "Username: '******' to '{1}'");
            log = Util.appendChange(log, objOld.Firstname, firstName, "First Name: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Lastname, lastName, "Last Name: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Address1, address1, "Address 1: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Address2, address2, "Address 2: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Phone1, phone1, "Phone 1: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Phone2, phone2, "Phone 2: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Email, email, "Email: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Birthdate, birthdate, "Birthdate: '{0:dd MMM yyyy}' to '{1:dd MMM yyyy}'");
            log = Util.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                if (!string.IsNullOrEmpty(log))
                {
                    SqlQueryResult result = DBConnection.query(
                        sqlConnection,
                        QueryTypes.ExecuteNonQuery,
                        "UserAccounts_update",
                        new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                        new SqlQueryParameter(COL_DB_Username, SqlDbType.NVarChar, username),
                        new SqlQueryParameter(COL_DB_Firstname, SqlDbType.NVarChar, firstName),
                        new SqlQueryParameter(COL_DB_Lastname, SqlDbType.NVarChar, Util.wrapNullable(lastName)),
                        new SqlQueryParameter(COL_DB_Address1, SqlDbType.NVarChar, Util.wrapNullable(address1)),
                        new SqlQueryParameter(COL_DB_Address2, SqlDbType.NVarChar, Util.wrapNullable(address2)),
                        new SqlQueryParameter(COL_DB_Phone1, SqlDbType.NVarChar, Util.wrapNullable(phone1)),
                        new SqlQueryParameter(COL_DB_Phone2, SqlDbType.NVarChar, Util.wrapNullable(phone2)),
                        new SqlQueryParameter(COL_DB_Email, SqlDbType.NVarChar, Util.wrapNullable(email)),
                        new SqlQueryParameter(COL_DB_Birthdate, SqlDbType.NVarChar, Util.wrapNullable(birthdate)),
                        new SqlQueryParameter(COL_DB_Identification, SqlDbType.NVarChar, Util.wrapNullable(identification)),
                        new SqlQueryParameter(COL_DB_Height, SqlDbType.Int, Util.wrapNullable(height)),
                        new SqlQueryParameter(COL_DB_Weight, SqlDbType.Int, Util.wrapNullable(weight)),
                        new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                        );

                    if (result.IsSuccessful)
                    {
                        LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, String.Format("Updated: {0}", log));
                    }
                }
                UserAccountRoleAssignment.update(sqlConnection, userAccountID, id, userAccountRoles);
            }
        }
        /// <summary>
        /// <para>userAccountID is user that is performing the assignment</para>
        /// <para>userAccountsId is the user to be assigned to the userAccountRoleId </para>
        /// </summary>
        public static void delete(Guid userAccountID, Guid id)
        {
            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(
                    sqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "UserAccountRoleAssignments_delete",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id)
                    );

                if (result.IsSuccessful)
                {
                    UserAccountRoleAssignment obj = new UserAccountRoleAssignment(id);
                    LOGGING.ActivityLog.add(sqlConnection, userAccountID, obj.UserAccounts_Id, "Deleted Role " + obj.UserAccountRoles_Name);
                }
            }
        }
Ejemplo n.º 4
0
        public static Guid add(Guid userAccountID, string username, string password, string firstName, string lastName,
                               string address1, string address2, string phone1, string phone2, string email, DateTime?birthdate, string identification, int height, int weight, string notes, List <Guid?> userAccountRoles)
        {
            Guid id = Guid.NewGuid();

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(
                    sqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "UserAccounts_add",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_Username, SqlDbType.NVarChar, username),
                    new SqlQueryParameter(COL_DB_Firstname, SqlDbType.NVarChar, firstName),
                    new SqlQueryParameter(COL_INPUT_Password, SqlDbType.NVarChar, password),
                    new SqlQueryParameter(COL_DB_Lastname, SqlDbType.NVarChar, Util.wrapNullable(lastName)),
                    new SqlQueryParameter(COL_DB_Address1, SqlDbType.NVarChar, Util.wrapNullable(address1)),
                    new SqlQueryParameter(COL_DB_Address2, SqlDbType.NVarChar, Util.wrapNullable(address2)),
                    new SqlQueryParameter(COL_DB_Phone1, SqlDbType.NVarChar, Util.wrapNullable(phone1)),
                    new SqlQueryParameter(COL_DB_Phone2, SqlDbType.NVarChar, Util.wrapNullable(phone2)),
                    new SqlQueryParameter(COL_DB_Email, SqlDbType.NVarChar, Util.wrapNullable(email)),
                    new SqlQueryParameter(COL_DB_Birthdate, SqlDbType.NVarChar, Util.wrapNullable(birthdate)),
                    new SqlQueryParameter(COL_DB_Identification, SqlDbType.NVarChar, Util.wrapNullable(identification)),
                    new SqlQueryParameter(COL_DB_Height, SqlDbType.Int, Util.wrapNullable(height)),
                    new SqlQueryParameter(COL_DB_Weight, SqlDbType.Int, Util.wrapNullable(weight)),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, "Added");
                    UserAccountRoleAssignment.update(sqlConnection, userAccountID, id, userAccountRoles);
                }
            }
            return(id);
        }