コード例 #1
0
        public AppUser CreateNewAccount(AUser user)
        {
            //get role
            var role = context.Roles.SingleOrDefault(e => e.Id == (int)SupportLayer.Enum.RoleType.Admin);
            //create App
            var pipe    = new DefualtPipeForCreateApp();
            var app     = new CDefualtApp();
            var factory = AppFactory.CreateApp <DefaultAppBuilder>(pipe);

            factory.CreateApp(app);
            //create User
            var cum = new CUserManager();

            cum.AddUser(user, app);
            cum.AddUserRole(user, role);
            cum.Save();
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Length < 1 && txtPassword.Text.Length < 1)
            {
                return;
            }

            String sTempUser = txtUserName.Text.Trim();

            String sTempPass = txtPassword.Text.Trim();

            int iTempType = ((CComboBoxItem)cmbUserType.SelectedItem).Value;

            String sTempGender = cmbSex.SelectedItem.ToString();

            CUserInfo oUser = new CUserInfo();

            oUser.UserName = sTempUser;

            oUser.Password = sTempPass;

            oUser.Type = iTempType;

            oUser.Gender = sTempGender;

            if (rdoActive.Checked)
            {
                oUser.Status = 1;
            }
            else if (rdoInActive.Checked)
            {
                oUser.Status = 0;
            }

            CUserAccess oUserAccess = new CUserAccess();

            if (chkOpenDrawer.Checked)
            {
                oUserAccess.OpenDrawer = 1;
            }

            if (chkReviewTrans.Checked)
            {
                oUserAccess.ReviewTransaction = 1;
            }

            if (chkVoidTable.Checked)
            {
                oUserAccess.VoidTable = 1;
            }

            if (chkViewReport.Checked)
            {
                oUserAccess.ViewReport = 1;
            }

            if (chkTransferTable.Checked)
            {
                oUserAccess.TransferTable = 1;
            }

            if (chkTillReport.Checked)
            {
                oUserAccess.TillReporting = 1;
            }

            if (chkMergeTable.Checked)
            {
                oUserAccess.MergeTable = 1;
            }

            if (chkExitRms.Checked)
            {
                oUserAccess.ExitRms = 1;
            }

            if (chkUnlockTable.Checked)
            {
                oUserAccess.UnlockTable = 1;
            }

            if (chkBooking.Checked)
            {
                oUserAccess.Booking = 1;
            }

            if (chkUsers.Checked)
            {
                oUserAccess.Users = 1;
            }

            if (chkDeposit.Checked)
            {
                oUserAccess.Deposit = 1;
            }

            if (chkCustomer.Checked)
            {
                oUserAccess.Customers = 1;
            }

            if (chkUpdateItems.Checked)
            {
                oUserAccess.UpdateItems = 1;
            }

            if (chkRemoveItems.Checked)
            {
                oUserAccess.RemoveItems = 1;
            }

            if (chkLogRegister.Checked)
            {
                oUserAccess.LogRegister = 1;
            }

            if (chkSettings.Checked)
            {
                oUserAccess.SystemSettings = 1;
            }
            if (chkRmsAdmin.Checked)
            {
                oUserAccess.RmsAdminAccess = 1;
            }



            oUser.UserAccess = oUserAccess;


            CUserManager oManager = new CUserManager();

            CResult oResult = oManager.AddUser(oUser);

            if (oResult.IsSuccess)
            {
                lblSaveStatus.Text = "User information has been saved successfully.";

                lblSaveStatus.Visible = true;
            }
            else
            {
                lblSaveStatus.Text    = oResult.Message;
                lblSaveStatus.Visible = true;
            }
        }