Beispiel #1
0
        public bool UserIsValid(FormUser user, bool ignoreEmail, out string message)
        {
            if (!FieldValidator.FieldIsValid(user.UserName, FieldType.UserName, out var detailMessage))
            {
                message = $"Некорректное имя пользователя: {detailMessage}";
                return(false);
            }

            if (!ignoreEmail &&
                !FieldValidator.FieldIsValid(user.Email, FieldType.Email, out detailMessage))
            {
                message = $"Некорректный email: {detailMessage}";
                return(false);
            }

            if (!FieldValidator.FieldIsValid(user.Password, FieldType.Password, out detailMessage))
            {
                message = $"Некорректный пароль: {detailMessage}";
                return(false);
            }

            message = "Опрос проверен успешно";

            return(true);
        }
Beispiel #2
0
        private void btnUsersEdit_Click(object sender, System.EventArgs e)
        {
            // get current selected item
            Dictionary <int, FormUser> updatedList = new Dictionary <int, FormUser>();

            foreach (DataGridViewRow row in dataGridViewUsers.Rows)
            {
                if (row.Cells[0].Value != null &&
                    (bool)row.Cells[0].Value)
                {
                    int    userId   = (int)row.Cells[1].Value;
                    string username = (string)row.Cells[3].Value;

                    FormUser formUser = new FormUser(username);
                    formUser.Text = "Edit User";
                    formUser.SetGroups(userPresenter.GetGroupsList());
                    formUser.DisplayName       = (string)row.Cells[2].Value;
                    formUser.UserName          = username;
                    formUser.Password          = (string)row.Cells[4].Value;
                    formUser.SelectedGroupName = (string)row.Cells[5].Value;

                    if (formUser.ShowDialog(this) == System.Windows.Forms.DialogResult.OK &&
                        formUser.IsDirty)
                    {
                        // add to database
                        updatedList.Add(userId, formUser);
                    }
                }
            }

            foreach (KeyValuePair <int, FormUser> data in updatedList)
            {
                userPresenter.EditUser(data.Key, data.Value.DisplayName, data.Value.UserName, data.Value.Password, data.Value.SelectedGroupId);
            }
        }
Beispiel #3
0
        void LanguageClick(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;

            foreach (SynapseLanguage lang in _language)
            {
                if (lang.CULTURE == tsmi.Tag.ToString())
                {
                    _CurrentLanguage = lang;
                }
            }
            Security.Tools.SetCulture(_CurrentLanguage.CULTURE);
            FormUser.UserCulture = _CurrentLanguage.CULTURE;
            FormUser.SaveUser();
            foreach (SynapseForm form in FormList)
            {
                form.initForm(SynapseCore.Security.Tools.SecureAndTranslateMode.Transalte);
                if (form.LanguageMenu != null)
                {
                    form.LanguageMenu.Text  = _CurrentLanguage.LABEL;
                    form.LanguageMenu.Tag   = _CurrentLanguage.CULTURE;
                    form.LanguageMenu.Image = (Image)Resource1.ResourceManager.GetObject(_CurrentLanguage.CODE);
                }
            }
        }
        private void usersToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            FormUser FU = new FormUser();

            FU.MdiParent = this;
            FU.Show();
        }
Beispiel #5
0
        public async Task FormParticipateAsyncP(int id, PFormViewModel obj)
        {
            var v = await _db.Users.Where(u => u.UserName.Equals(HttpContext.Current.User.Identity.Name)).FirstOrDefaultAsync();

            FormUser fu = new FormUser();

            fu.QFormID = id;
            fu.UserID  = v.Id;
            _db.FormUsers.Add(fu);
            await _db.SaveChangesAsync();


            var p = await(_db.Questions.Where(u => u.QFormID.Equals(id)).Distinct()).ToListAsync();

            Question q = new Question();


            for (var i = 0; i < obj.Ques.Count(); i++)
            {
                int a = obj.Ques[i].SelectedAnswerId;
                p[i].SelectedAnswerId = a;


                var h = await _db.Answers.Where(u => u.AnswerID.Equals(a)).FirstOrDefaultAsync();

                h.AnsCount = h.AnsCount + 1;

                await _db.SaveChangesAsync();
            }
        }
Beispiel #6
0
        public void OpenForm()
        {
            switch (User.levelAccess)
            {
            case LevelAccess.banned:
                break;

            case LevelAccess.user:
                FormUser formUser = new FormUser();
                formLogin.Hide();
                formUser.Show();
                break;

            case LevelAccess.seller:

                break;

            case LevelAccess.zavhoz:

                break;

            case LevelAccess.admin:
                FormAdmin formAdmin = new FormAdmin();
                formLogin.Hide();
                formAdmin.Show();
                break;
            }
        }
 private void btnAddUser_Click(object sender, EventArgs e)
 {
     using (FormUser user = new FormUser())
     {
         user.ShowDialog();
     }
 }
        private void buttonGoBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormUser userF = new FormUser();

            userF.ShowDialog();
            this.Close();
        }
Beispiel #9
0
        private void btnTambah_Click(object sender, RoutedEventArgs e)
        {
            FormUser formUser = new FormUser();

            formUser.ShowDialog();

            RefreshDataGrid();
        }
Beispiel #10
0
        private void Refresh_List(object sender, EventArgs e)
        {
            FormUser.ReloadModulesAndGroups();

            loadModules();
            loadCategories();
            loadFavorites();
        }
        private void AddUser()
        {
            //   User user = MediApp.Instance.Users.Add();
            FormUser formUser = new FormUser();
            // formUser.Execute(user);
            int num = (int)formUser.ShowDialog();

            this.RefreshUsersGrid();
        }
Beispiel #12
0
        /// <summary>
        /// Edit current item
        /// </summary>
        ///
        public override void Edit()
        {
            UserInfo info = FocusedEntity;

            if (info != null)
            {
                using (FormUser frm = new FormUser())
                {
                    frm.Entity = info.User;
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (info.User.IsNew)
                        {
                            try
                            {
                                User usr = ClientEnvironment.UserService.Save(info.User);
                                UserList.Add(new UserInfo(usr));
                            }
                            catch (EntityException ex)
                            {
                                // 2think: what details should we show?
                                // 2think: how to localize?
                                using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                                {
                                    form.Text = GetLocalized("CannotSaveUser");
                                    form.ShowDialog(this);
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                User usr = ClientEnvironment.UserService.SaveOrUpdate(info.User);
                                UserList.ResetItemById(usr.ID);
                            }
                            catch (EntityException ex)
                            {
                                // 2think: what details should we show?
                                // 2think: how to localize?
                                using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                                {
                                    form.Text = GetLocalized("CannotSaveUser");
                                    form.ShowDialog(this);
                                }
                            }
                        }
                    }
                }

                UserList.ResetItemById(info.User.ID);
            }
            RefreshData();
        }
Beispiel #13
0
        public async Task <long> AddUserToForm(long userId, long formId, int tenantId, Role role)
        {
            using (var context = CreateContext(tenantId))
            {
                var fu = new FormUser {
                    UserId = userId, FormId = formId, UserRole = role
                };
                context.FormUsers.Add(fu);
                await context.SaveChangesAsync();

                return(fu.FormId);
            }
        }
Beispiel #14
0
        private void btnUsersAdd_Click(object sender, System.EventArgs e)
        {
            // show the form user
            FormUser formUser = new FormUser(String.Empty);

            formUser.Text = "Add User";
            formUser.SetGroups(userPresenter.GetGroupsList());
            if (formUser.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                // add to database
                userPresenter.AddUser(formUser.DisplayName, formUser.UserName, formUser.Password, formUser.SelectedGroupId);
            }
        }
Beispiel #15
0
 private void qRibbonPanel2_ItemActivated(object sender, QCompositeEventArgs e)
 {
     if (usr == null)
     {
         usr             = new FormUser();
         usr.MdiParent   = this;
         usr.FormClosed += new FormClosedEventHandler(FormUser_FormClosed);
         usr.Show();
     }
     else
     {
         usr.Activate();
     }
 }
        private void EditUser()
        {
            if (this.dataGridViewUsers.CurrentRow == null && this.dataGridViewUsers.CurrentRow.DataBoundItem == null)
            {
                return;
            }
            User     dataBoundItem = this.dataGridViewUsers.CurrentRow.DataBoundItem as User;
            FormUser formUser      = new FormUser();

            formUser.Execute(dataBoundItem);
            int num = (int)formUser.ShowDialog();

            this.RefreshUsersGrid();
        }
Beispiel #17
0
        //Déclaration de la fonction qui va exécuter la connexion
        public void Connexion()
        {
            FormConnexion PageConnexion = new FormConnexion();
            FormUser      AcceuilAdmin  = new FormUser();

            GestionnaireConnexion connect = new GestionnaireConnexion();

            if (connect.verifySecretaire(Login.Text, Password.Text) == false)
            {
                transitionErreur.ShowSync(Erreur);
                Erreur.Visible = true;

                Login.Text = "";
                if ((Password.Text == "") || (Password.Text == "Saisir le Password"))
                {
                    Password.Text = "Saisir le Password";
                }

                Password.Text = "";
                if ((Login.Text == "") || (Login.Text == "Saisir le Login"))
                {
                    Login.Text = "Saisir le Login";
                }
            }
            else
            {
                Secretaire curSecretaire = connect.OneSecretaire(Login.Text);
                transition.HideSync(PageConnexion);
                System.Windows.Forms.Form.ActiveForm.Visible = false;
                transition.ShowSync(AcceuilAdmin);
                AcceuilAdmin.Activate();

                AcceuilAdmin.NomUser.Text       = curSecretaire.nomSecretaire;
                AcceuilAdmin.PrenomUser.Text    = curSecretaire.prenomSecretaire;
                AcceuilAdmin.EmailUser.Text     = curSecretaire.emailSecretaire;
                AcceuilAdmin.TelephoneUser.Text = curSecretaire.telSecretaire;

                //Remplisage des composants
                AcceuilAdmin.Taux.Value = (connect.countTotalEntrant() * 100) / connect.countTotalCourrier();

                AcceuilAdmin.EffectifC.Value = connect.countTotalCourrier();

                AcceuilAdmin.nbre.Text = connect.countTotalCourrier().ToString();
            }
        }
        private void ViewUser(int rowIndex)
        {
            int?    intKey = null;
            DataRow row    = dataTableUser.Rows[rowIndex];

            if (row != null)
            {
                int outIntKey;
                if (int.TryParse(row.ItemArray[0].ToString(), out outIntKey))
                {
                    intKey = outIntKey;
                }
            }

            FormUser frm = new FormUser(intKey);

            frm.ShowDialog();
            LoadGridUtenze(UsersDB.SetQueryUser(string.Empty));
        }
Beispiel #19
0
        /// <summary>
        /// Va chercher tout les workcenter présent en db et les ajoutes à la combobox
        /// </summary>
        private void GetWorkCenter()
        {
            lblName.Text    = $"Bonjour {FormUser.ToString()}";
            lblMessage.Text = "Merci de sélectionner une section.";

            List <ADR_WorkCenter> WorkCenters;

            using (WorkCenterRepository WorkCenterRepository = new WorkCenterRepository())
            {
                WorkCenters = WorkCenterRepository.Get().ToList();
            }

            cbWorkCenter.DataSource    = WorkCenters;
            cbWorkCenter.DisplayMember = "WorkCenter";
            cbWorkCenter.ValueMember   = "Id";

            if (WorkCenterUser != null)
            {
                cbWorkCenter.Text = WorkCenters.Where((wk) => wk.Id == WorkCenterUser.WorkCenterId).Select((wk) => wk.WorkCenter).FirstOrDefault();
            }
        }
        public void login(String username, String password)
        {
            //UsersDAL usersDAL = UsersDAL.getInstance();
            UserService userService = UserService.getInstance();
            String      passMD5     = getMd5Hash(password);

            UserDAO u = userService.getUser(username, passMD5);

            if (u != null)
            {
                if (u.getRole() == "user")
                {
                    FormUser formUser = new FormUser();
                    formUser.Show();
                }
                else if (u.getRole() == "admin")
                {
                    FormAdmin formAdmin = new FormAdmin();
                    formAdmin.Show();
                }
            }
        }
Beispiel #21
0
        public async Task <ActionResult> Login(FormUser model)
        {
            Logger.Init();
            try
            {
                if (!UserValidator.UserIsValid(model, ignoreEmail: true, message: out var message))
                {
                    ModelState.AddModelError("", message);
                    return(View(model));
                }

                var user = await AuthUserManager.FindAsync(model.UserName,
                                                           Cryptography.Sha256(
                                                               model.Password + Salt));

                if (user == null)
                {
                    ModelState.AddModelError("", "Пользователь не найден.");
                    return(View(model));
                }

                var ident =
                    await AuthUserManager.CreateIdentityAsync(
                        user, DefaultAuthenticationTypes.ApplicationCookie);

                AuthenticationManager.SignOut();
                AuthenticationManager.SignIn(new AuthenticationProperties {
                    IsPersistent = false
                },
                                             ident);
                return(Redirect("/ControlPanel"));
            }
            catch (Exception e)
            {
                Logger.Log.Error(e);
                return(Redirect("/ControlPanel"));
            }
        }
Beispiel #22
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;
                FormUser    formUser    = new FormUser("Edit", Convert.ToInt32(dataRowView[1].ToString()));


                formUser.txtNama.Text          = dataRowView[2].ToString();
                formUser.txtUsername.Text      = dataRowView[3].ToString();
                formUser.txtEmail.Text         = dataRowView[5].ToString();
                formUser.cmbRole.SelectedValue = dataRowView[6].ToString();
                formUser.txtFileName.Text      = dataRowView[7].ToString();

                formUser.ShowDialog();

                RefreshDataGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #23
0
        public async Task <ActionResult> Register(FormUser model)
        {
            Logger.Init();
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                if (!UserValidator.UserIsValid(model, ignoreEmail: false, message: out var message))
                {
                    ModelState.AddModelError("", message);
                    return(View(model));
                }

                var user   = model.ToUser(Salt);
                var result =
                    await AuthUserManager.CreateAsync(
                        user, Cryptography.Sha256(model.Password + Salt));

                if (result.Succeeded)
                {
                    return(Redirect("/Account/Login"));
                }

                AddErrorsFromResult(result);

                return(View(model));
            }
            catch (Exception e)
            {
                Logger.Log.Error(e);
                return(Redirect("/ControlPanel"));
            }
        }
Beispiel #24
0
        /// <summary>
        /// 用户管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmUser_Click(object sender, EventArgs e)
        {
            FormUser form = new FormUser();

            form.ShowDialog();
        }
Beispiel #25
0
        /// <summary>
        /// Add new item
        /// </summary>
        public override void Add()
        {
            User usr = ClientEnvironment.UserService.CreateEntity();

            using (FormUser frm = new FormUser())
            {
                frm.Entity = usr;
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (usr.IsNew)
                    {
                        try
                        {
                            usr = ClientEnvironment.UserService.Save(usr);
                            UserList.Add(new UserInfo(usr));
                            for (int row = 0; row < UserList.Count; row++)
                            {
                                if (UserList[row].User.ID == usr.ID)
                                {
                                    focusedRow = row;
                                    break;
                                }
                            }
                            focusedUser   = new UserInfo(usr);
                            isRowNotFixed = true;
                            fixedTimes    = 3;
                            fixFocusedEntity();
                        }
                        catch (EntityException ex)
                        {
                            // 2think: what details should we show?
                            // 2think: how to localize?
                            using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                            {
                                form.Text = GetLocalized("CannotSaveUser");
                                form.ShowDialog(this);
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            usr = ClientEnvironment.UserService.SaveOrUpdate(usr);
                            UserList.ResetItemById(usr.ID);
                        }
                        catch (EntityException ex)
                        {
                            // 2think: what details should we show?
                            // 2think: how to localize?
                            using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                            {
                                form.Text = GetLocalized("CannotSaveUser");
                                form.ShowDialog(this);
                            }
                        }
                    }
                }
            }
            //   RefreshData(); //******************!!!!!!!!!
        }
Beispiel #26
0
        private void treeViewLeft_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.panelRight.Hide();
            this.panelRight.SuspendLayout();
            if (treeViewLeft.SelectedNode.Text == "用户管理")
            {
                this.panelRight.Controls.Clear();                                            //清空
                FormUser l = new FormUser(this.user.ID, this.project.ID, this.warehouse.ID); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = DockStyle.Fill;                                          //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                                    //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "供应商管理")
            {
                this.panelRight.Controls.Clear();                                                         //清空
                FormBaseSupplier l = new FormBaseSupplier(user.Authority, this.supplierid, this.user.ID); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;                                  //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                                                 //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "供货管理")
            {
                this.panelRight.Controls.Clear();                                                                                         //清空
                FormBaseSupply l = new FormBaseSupply(user.Authority, this.supplierid, this.project.ID, this.warehouse.ID, this.user.ID); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;                                                                  //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                                                                                 //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "零件管理")
            {
                this.panelRight.Controls.Clear();                                                                                               //清空
                FormBaseComponent l = new FormBaseComponent(user.Authority, this.supplierid, this.project.ID, this.warehouse.ID, this.user.ID); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;                                                                        //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                                                                                       //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "其他")
            {
                this.setitem = 0;
                this.LoadSubWindow(new FormOtherInfo(this.setitem));
            }
            if (treeViewLeft.SelectedNode.Text == "项目管理")
            {
                this.panelRight.Controls.Clear();                        //清空
                this.setitem = 1;
                FormBaseProject l = new FormBaseProject();               //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill; //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "人员管理")
            {
                this.panelRight.Controls.Clear();                          //清空
                FormBase.FormBasePerson l = new FormBase.FormBasePerson(); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;   //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                  //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "到货单管理")
            {
                this.panelRight.Controls.Clear();                                                                                 //清空
                FormReceiptArrival l = new FormReceiptArrival(this.project.ID, this.warehouse.ID, this.user.ID, this.supplierid); //实例化子窗口
                l.SetActionTo(0, new Action <string, string>((string key, string value) =>
                {
                    this.panelRight.Controls.Clear();
                    FormSubmissionManage s = new FormSubmissionManage(this.project.ID, this.warehouse.ID, this.user.ID, key, value);
                    s.setActionTo(new Action <string, string>((string key1, string value1) =>
                    {
                        this.panelRight.Controls.Clear();
                        FormReceiptShelves t = new FormReceiptShelves(this.project.ID, this.warehouse.ID, this.user.ID, key1, value1);
                        t.TopLevel           = false;
                        t.Dock            = System.Windows.Forms.DockStyle.Fill;
                        t.FormBorderStyle = FormBorderStyle.None;
                        //s.Dock = System.Windows.Forms.DockStyle.Fill;
                        this.panelRight.Controls.Add(t);

                        t.Show();
                        SetTreeViewSelectedNodeByText("上架单管理");
                        Utilities.SendMessage(this.panelRight.Handle, Utilities.WM_SETREDRAW, 1, 0);
                    }));

                    s.TopLevel = false;
                    s.Dock     = System.Windows.Forms.DockStyle.Fill;
                    this.panelRight.Controls.Clear();//清空
                    s.FormBorderStyle = FormBorderStyle.None;
                    this.panelRight.Controls.Add(s);
                    s.Show();
                    SetTreeViewSelectedNodeByText("送检单管理");
                    //treeViewLeft.SelectedNode = treeViewLeft.Nodes.Find("送检单管理", true)[0];
                    Utilities.SendMessage(this.panelRight.Handle, Utilities.WM_SETREDRAW, 1, 0);
                }));
                l.SetActionTo(1, new Action <string, string>((key, value) =>
                {
                    this.panelRight.Controls.Clear();
                    FormReceiptShelves s = new FormReceiptShelves(this.project.ID, this.warehouse.ID, this.user.ID, key, value);
                    s.TopLevel           = false;
                    s.Dock            = System.Windows.Forms.DockStyle.Fill;
                    s.FormBorderStyle = FormBorderStyle.None;
                    //s.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.panelRight.Controls.Add(s);

                    s.SetToPutaway(new Action <string, string>((key1, value1) =>
                    {
                        this.panelRight.Controls.Clear();
                        FormShelvesItem a = new FormShelvesItem(this.project.ID, this.warehouse.ID, this.user.ID, key1, value1);
                        a.TopLevel        = false;
                        a.Dock            = System.Windows.Forms.DockStyle.Fill;
                        a.FormBorderStyle = FormBorderStyle.None;
                        //s.Dock = System.Windows.Forms.DockStyle.Fill;
                        this.panelRight.Controls.Add(a);
                        a.Show();
                        //this.treeViewLeft.SelectedNode = treeViewLeft.Nodes.Find("上架零件管理", true)[0];
                        Utilities.SendMessage(this.panelRight.Handle, Utilities.WM_SETREDRAW, 1, 0);
                    }));

                    s.Show();
                    SetTreeViewSelectedNodeByText("上架单管理");
                    Utilities.SendMessage(this.panelRight.Handle, Utilities.WM_SETREDRAW, 1, 0);
                }));
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill; //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }

            if (treeViewLeft.SelectedNode.Text == "上架单管理")
            {
                this.panelRight.Controls.Clear();                                                                //清空
                FormReceiptShelves l = new FormReceiptShelves(this.project.ID, this.warehouse.ID, this.user.ID); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;                                         //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                                                        //没有标题栏
                l.SetToPutaway(new Action <string, string>((key, value) =>
                {
                    this.panelRight.Controls.Clear();
                    FormShelvesItem s = new FormShelvesItem(this.project.ID, this.warehouse.ID, this.user.ID, key, value);
                    s.TopLevel        = false;
                    s.Dock            = System.Windows.Forms.DockStyle.Fill;
                    s.FormBorderStyle = FormBorderStyle.None;
                    //s.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.panelRight.Controls.Add(s);
                    s.Show();
                    SetTreeViewSelectedNodeByText("上架零件管理");
                    //this.treeViewLeft.SelectedNode = treeViewLeft.Nodes.Find("上架零件管理", true)[0];
                    Utilities.SendMessage(this.panelRight.Handle, Utilities.WM_SETREDRAW, 1, 0);
                }));
                this.panelRight.Controls.Add(l);
                l.Show();
            }

            if (treeViewLeft.SelectedNode.Text == "上架零件管理")
            {
                this.panelRight.Controls.Clear();
                FormShelvesItem l = new FormShelvesItem(this.project.ID, this.warehouse.ID, this.user.ID, null, null);
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;
                l.FormBorderStyle = FormBorderStyle.None;
                this.panelRight.Controls.Add(l);
                l.Show();
            }

            if (treeViewLeft.SelectedNode.Text == "工作任务单管理")
            {
                this.panelRight.Controls.Clear();                                                                                 //清空
                FormShipmentTicket formShipmentTicket = new FormShipmentTicket(this.user.ID, this.project.ID, this.warehouse.ID); //实例化子窗口
                formShipmentTicket.SetToJobTicketCallback(this.ToJobTicketCallback);
                formShipmentTicket.TopLevel        = false;
                formShipmentTicket.Dock            = System.Windows.Forms.DockStyle.Fill; //窗口大小
                formShipmentTicket.FormBorderStyle = FormBorderStyle.None;                //没有标题栏
                this.panelRight.Controls.Add(formShipmentTicket);
                formShipmentTicket.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "翻包作业单管理")
            {
                this.panelRight.Controls.Clear();                                                      //清空
                FormJobTicket l = new FormJobTicket(this.user.ID, this.project.ID, this.warehouse.ID); //实例化子窗口
                l.SetToPutOutStorageTicketCallback(this.ToPutOutStorageTicketCallback);
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill; //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "出库单管理")
            {
                this.panelRight.Controls.Clear();                                                                          //清空
                FormPutOutStorageTicket l = new FormPutOutStorageTicket(this.user.ID, this.project.ID, this.warehouse.ID); //实例化子窗口
                l.TopLevel        = false;
                l.Dock            = System.Windows.Forms.DockStyle.Fill;                                                   //窗口大小
                l.FormBorderStyle = FormBorderStyle.None;                                                                  //没有标题栏
                this.panelRight.Controls.Add(l);
                l.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "库存批次")
            {
                this.panelRight.Controls.Clear();                                                        //清空
                var formBaseStock = new FormStockInfo(this.user.ID, this.project.ID, this.warehouse.ID); //实例化子窗口
                formBaseStock.TopLevel        = false;
                formBaseStock.Dock            = DockStyle.Fill;                                          //窗口大小
                formBaseStock.FormBorderStyle = FormBorderStyle.None;                                    //没有标题栏
                this.panelRight.Controls.Add(formBaseStock);
                formBaseStock.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "库存盘点")
            {
                this.panelRight.Controls.Clear();                                                                   //清空
                var formBaseStock = new FormStockInfoCheckTicket(this.project.ID, this.warehouse.ID, this.user.ID); //实例化子窗口
                formBaseStock.TopLevel        = false;
                formBaseStock.Dock            = DockStyle.Fill;                                                     //窗口大小
                formBaseStock.FormBorderStyle = FormBorderStyle.None;                                               //没有标题栏
                this.panelRight.Controls.Add(formBaseStock);
                formBaseStock.Show();
            }
            if (treeViewLeft.SelectedNode.Text == "送检单管理")
            {
                this.panelRight.Controls.Clear();                                                                      //清空
                var formSubmissionManage = new FormSubmissionManage(this.project.ID, this.warehouse.ID, this.user.ID); //实例化子窗口
                formSubmissionManage.setActionTo(new Action <string, string>((string key, string value) =>
                {
                    this.panelRight.Controls.Clear();
                    FormReceiptShelves t = new FormReceiptShelves(this.project.ID, this.warehouse.ID, this.user.ID, key, value);
                    t.TopLevel           = false;
                    t.Dock            = System.Windows.Forms.DockStyle.Fill;
                    t.FormBorderStyle = FormBorderStyle.None;
                    //s.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.panelRight.Controls.Add(t);

                    t.Show();
                    SetTreeViewSelectedNodeByText("上架单管理");
                    Utilities.SendMessage(this.panelRight.Handle, Utilities.WM_SETREDRAW, 1, 0);
                }));
                formSubmissionManage.TopLevel        = false;
                formSubmissionManage.Dock            = DockStyle.Fill;       //窗口大小
                formSubmissionManage.FormBorderStyle = FormBorderStyle.None; //没有标题栏
                this.panelRight.Controls.Add(formSubmissionManage);
                formSubmissionManage.Show();
            }
            this.panelRight.ResumeLayout();
            this.panelRight.Show();
        }
Beispiel #27
0
        public void AddOrUpdate(ManagerUserFilterViewModel managerUserFilterViewModel)
        {
            var ph = new Microsoft.AspNet.Identity.PasswordHasher();

            try
            {
                if (managerUserFilterViewModel.userViewModel.UserID > 0)
                {
                    if (!CheckDuplicateByEmailAndUser(managerUserFilterViewModel.userViewModel.Email, managerUserFilterViewModel.userViewModel.UserID))
                    {
                        User user = _userRepo.GetById(managerUserFilterViewModel.userViewModel.UserID);
                        user.UserName      = managerUserFilterViewModel.userViewModel.FirstName + managerUserFilterViewModel.userViewModel.LastName;
                        user.FirstName     = managerUserFilterViewModel.userViewModel.FirstName;
                        user.LastName      = managerUserFilterViewModel.userViewModel.LastName;
                        user.Telephone     = managerUserFilterViewModel.userViewModel.Telephone;
                        user.Address1      = managerUserFilterViewModel.userViewModel.Address1;
                        user.Address2      = managerUserFilterViewModel.userViewModel.Address2;
                        user.City          = managerUserFilterViewModel.userViewModel.City;
                        user.State         = managerUserFilterViewModel.userViewModel.State;
                        user.PostalCode    = managerUserFilterViewModel.userViewModel.PostalCode;
                        user.EMail         = managerUserFilterViewModel.userViewModel.Email;
                        user.UserType      = managerUserFilterViewModel.userViewModel.UserType;
                        user.dashboardUser = managerUserFilterViewModel.userViewModel.IsDashboardUser;
                        user.Active        = managerUserFilterViewModel.userViewModel.IsActive;
                        user.ManagerUserID = managerUserFilterViewModel.userViewModel.ManagerUserId > 0 ? managerUserFilterViewModel.userViewModel.ManagerUserId : null;
                        user.UserAccess    = managerUserFilterViewModel.userViewModel.AccessLevelId;
                        _userRepo.Update(user);
                        _userClientRepo.DeleteByUserId(managerUserFilterViewModel.userViewModel.UserID);
                        if (managerUserFilterViewModel.userViewModel.ClientId != null)
                        {
                            foreach (var itemId in managerUserFilterViewModel.userViewModel.ClientId)
                            {
                                UserClient uClient = new UserClient()
                                {
                                    UserID   = managerUserFilterViewModel.userViewModel.UserID,
                                    ClientID = Convert.ToInt32(itemId)
                                };
                                _userClientRepo.Add(uClient);
                            }
                        }
                        _userLevelsRepo.DeleteByUserId(managerUserFilterViewModel.userViewModel.UserID);
                        if (managerUserFilterViewModel.userViewModel.RegionId != null)
                        {
                            foreach (var itemId in managerUserFilterViewModel.userViewModel.RegionId)
                            {
                                UserLevel userLevel = new UserLevel()
                                {
                                    UserID  = managerUserFilterViewModel.userViewModel.UserID,
                                    LevelID = Convert.ToInt32(itemId)
                                };
                                _userLevelsRepo.Add(userLevel);
                            }
                        }
                        _formUsersRepo.DeleteByUserId(managerUserFilterViewModel.userViewModel.UserID);
                        if (managerUserFilterViewModel.userViewModel.FormId != null)
                        {
                            foreach (var itemId in managerUserFilterViewModel.userViewModel.FormId)
                            {
                                FormUser uClient = new FormUser()
                                {
                                    UserID = managerUserFilterViewModel.userViewModel.UserID,
                                    FormID = Convert.ToInt32(itemId)
                                };
                                _formUsersRepo.Add(uClient);
                            }
                        }
                        managerUserFilterViewModel.IsSuccess = true;
                        managerUserFilterViewModel.Message   = "Record Updated Successfully.";
                    }
                    else
                    {
                        managerUserFilterViewModel.IsSuccess = false;
                        managerUserFilterViewModel.Message   = "Email address already exist.";
                    }
                }
                else
                {
                    if (!CheckDuplicateByEmail(managerUserFilterViewModel.userViewModel.Email))
                    {
                        User user = new User()
                        {
                            UserName               = managerUserFilterViewModel.userViewModel.FirstName + managerUserFilterViewModel.userViewModel.LastName,
                            Password               = ph.HashPassword(managerUserFilterViewModel.userViewModel.Password),
                            FirstName              = managerUserFilterViewModel.userViewModel.FirstName,
                            LastName               = managerUserFilterViewModel.userViewModel.LastName,
                            Telephone              = managerUserFilterViewModel.userViewModel.Telephone,
                            Address1               = managerUserFilterViewModel.userViewModel.Address1,
                            Address2               = managerUserFilterViewModel.userViewModel.Address2,
                            City                   = managerUserFilterViewModel.userViewModel.City,
                            State                  = managerUserFilterViewModel.userViewModel.State,
                            PostalCode             = managerUserFilterViewModel.userViewModel.PostalCode,
                            EMail                  = managerUserFilterViewModel.userViewModel.Email,
                            UserType               = managerUserFilterViewModel.userViewModel.UserType,
                            dashboardUser          = managerUserFilterViewModel.userViewModel.IsDashboardUser,
                            Active                 = managerUserFilterViewModel.userViewModel.IsActive,
                            DateAdded              = DateTime.Now,
                            PasswordExpirationDate = DateTime.Now.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["ExpiryDays"])),
                            IsPasswordHashed       = false,
                            ManagerUserID          = managerUserFilterViewModel.userViewModel.ManagerUserId > 0? managerUserFilterViewModel.userViewModel.ManagerUserId:null,
                            UserAccess             = managerUserFilterViewModel.userViewModel.AccessLevelId
                        };
                        _userRepo.Add(user);
                        if (user.UserID > 0 && (managerUserFilterViewModel.userViewModel.ClientId != null))
                        {
                            foreach (var itemId in managerUserFilterViewModel.userViewModel.ClientId)
                            {
                                UserClient dClient = new UserClient()
                                {
                                    UserID   = user.UserID,
                                    ClientID = Convert.ToInt32(itemId)
                                };
                                _userClientRepo.Add(dClient);
                            }
                        }
                        if (user.UserID > 0 && (managerUserFilterViewModel.userViewModel.RegionId != null))
                        {
                            foreach (var itemId in managerUserFilterViewModel.userViewModel.RegionId)
                            {
                                UserLevel userLevel = new UserLevel()
                                {
                                    UserID  = user.UserID,
                                    LevelID = Convert.ToInt32(itemId)
                                };
                                _userLevelsRepo.Add(userLevel);
                            }
                        }
                        if (user.UserID > 0 && (managerUserFilterViewModel.userViewModel.FormId != null))
                        {
                            foreach (var itemId in managerUserFilterViewModel.userViewModel.FormId)
                            {
                                FormUser formUser = new FormUser()
                                {
                                    UserID = user.UserID,
                                    FormID = Convert.ToInt32(itemId)
                                };
                                _formUsersRepo.Add(formUser);
                            }
                        }

                        managerUserFilterViewModel.IsSuccess = true;
                        managerUserFilterViewModel.Message   = "Record Inserted Successfully.";
                    }
                    else
                    {
                        managerUserFilterViewModel.IsSuccess = false;
                        managerUserFilterViewModel.Message   = "Email address already exist.";
                    }
                }
            }
            catch (Exception ex)
            {
                managerUserFilterViewModel.IsSuccess = false;
                managerUserFilterViewModel.Message   = "Sorry, An error occurred!";
            }
        }
Beispiel #28
0
 public void LeaveAccount(FormUser form)
 {
     form.FormClosing -= form.FormUser_FormClosing;
     form.FormClosing += ShowFormLogin;
     form.Close();
 }
Beispiel #29
0
 private void FormUser_FormClosed(object sender, FormClosedEventArgs e)
 {
     usr = null;
 }
Beispiel #30
0
        private void SecurizeForm(bool AddMenu)
        {
            bool   UserHaveAccess      = false;
            string UserID              = string.Empty;
            bool   ScanControl         = false;
            bool   ShowTestEnvironment = true;

            if (_allModules == null)
            {
                _allModules = SynapseModule.Load();
            }
            try
            {
                ShowTestEnvironment = bool.Parse(ConfigurationManager.AppSettings["ShowTestEnvironment"]);
            }
            // TODO: Replace by more specific exception
            catch (Exception)
            {
                // TODO: Log exception
            }

            if (System.ComponentModel.LicenseManager.UsageMode != System.ComponentModel.LicenseUsageMode.Designtime)
            {
                if (log4net.LogManager.GetRepository().Configured == false)
                {
                    XmlConfigurator.Configure();
                }

                if (_formUser == null)
                {
                    UserID   = WindowsIdentity.GetCurrent().Name;
                    FormUser = new SynapseCore.Security.User(UserID, this.ModuleID);
                }

                if (_language == null)
                {
                    string languageFilter = null;
                    try
                    {
                        languageFilter = ConfigurationManager.AppSettings["ModuleLanguages"];
                    }
                    catch
                    {
                        SynapseLogger.Debug("ModuleLanguage not defined in app.config");
                    }
                    if (languageFilter != null && languageFilter != string.Empty && languageFilter != "")
                    {
                        _language = SynapseLanguage.Load("where CODE in (" + languageFilter + ")");
                    }
                    else
                    {
                        _language = SynapseLanguage.Load();
                    }
                }

                SynapseLogger.Debug("ModuleLanguage not defined in app.config");
                if (Control.ModifierKeys == (Keys.Control | Keys.Shift) && FormUser.IsMemberOf("SYNAPSE_SECURITY_USER_IMPERSONATE"))
                {
                    frm_EnterUser UserDialog = new frm_EnterUser();
                    UserDialog.ShowDialog();
                    UserID = UserDialog.UserID;
                    if (UserID != string.Empty)
                    {
                        FormUser = new SynapseCore.Security.User(UserID, this.ModuleID);
                    }
                }

                SynapseLogger.Debug("Check key modifier");
                if (FormUser.UserCulture != string.Empty && FormUser.UserCulture != null)
                {
                    _CurrentLanguage.CULTURE = FormUser.UserCulture;
                }
                else
                {
                    _CurrentLanguage.CULTURE = Thread.CurrentThread.CurrentCulture.Name;
                }

                SynapseLogger.Debug("Set Current Language");
                foreach (SynapseLanguage lang in _language)
                {
                    if (lang.CULTURE == _CurrentLanguage.CULTURE)
                    {
                        _CurrentLanguage = lang;
                    }
                }

                SynapseLogger.Debug("Set Current Language Label");
                if (_CurrentLanguage.LABEL == null)
                {
                    _CurrentLanguage = _language[0];
                }

                Security.Tools.SetCulture(_CurrentLanguage.CULTURE);
                SynapseLogger.Debug("Configure Resource Manager");
                ConfigureResourceManager();

                SynapseLogger.Debug("Set Current Module access");
                if (FormUser != null)
                {
                    foreach (SynapseModule Module in _allModules) //FormUser.Modules
                    {
                        if (_CurrentSynapse == null && Module.ID == 1)
                        {
                            _CurrentSynapse = Module;
                        }
                        if (_CurrentModule == null && Module.ID == _ModuleID)
                        {
                            _CurrentModule = Module;
                        }
                    }
                    if (FormUser.Modules.Select(m => m.ID).Contains(_CurrentModule.ID))
                    {
                        UserHaveAccess = true;
                    }
                }

                SynapseLogger.Debug("Check Module Mode");
                if (CurrentModule.ID == 1)
                {
                    if (SynapseCore.Database.DBFunction.ConnectionName != "Default")
                    {
                        Mode = SynapseModule.SynapseModuleMode.Development;
                    }
                    else
                    {
                        Mode = SynapseModule.SynapseModuleMode.Production;
                    }
                }
                else
                {
                    Mode = Application.ExecutablePath.Contains("\\Dev\\") ? SynapseModule.SynapseModuleMode.Development : SynapseModule.SynapseModuleMode.Production;
                }

                //redify
                List <Control> menupoint = Controls.OfType <ToolStrip>().Cast <Control>().ToList();
                if (menupoint.Count > 0)
                {
                    foreach (Control Ctrl in menupoint)
                    {
                        if (SynapseCore.Database.DBFunction.FormBackColor != SystemColors.Control && ShowTestEnvironment)
                        {
                            ((ToolStrip)Ctrl).BackColor = SynapseCore.Database.DBFunction.FormBackColor;
                        }
                    }
                }
                //end refify

                SynapseLogger.Debug("Add Menu");
                if (this.ShowMenu && AddMenu)
                {
                    ConfigureMenu();
                }

                SynapseLogger.Debug("Language Message");
                string LangMessage = "en";
                try
                {
                    LangMessage = _CurrentLanguage.CULTURE.Substring(0, 2).ToUpper();
                }
                // TODO: Replace by more specific exception
                catch (Exception)
                {
                    SynapseLogger.Error("Unable to determine language of message");
                }

                SynapseLogger.Debug("Message No Access");
                if (!UserHaveAccess && ModuleID != 1)
                {
                    MessageBox.Show(Properties.Resources.ResourceManager.GetString(LangMessage + "_NoAccess"));
                    Application.Exit();
                }

                SynapseLogger.Debug("Message Not Active");
                if (!CurrentModule.IS_ACTIVE && Mode == SynapseModule.SynapseModuleMode.Production)
                {
                    MessageBox.Show("(" + Mode.ToString() + ") " + Properties.Resources.ResourceManager.GetString(LangMessage + "_Maintenance"));
                    Application.Exit();
                }

                SynapseLogger.Debug("Message Not Up To Date");
                if (!CurrentModule.is_uptodate(Application.StartupPath, Mode) && !System.Diagnostics.Debugger.IsAttached)
                {
                    try
                    {
                        MessageBox.Show(Properties.Resources.ResourceManager.GetString(LangMessage + "_UpdateNeeded"));
                        string file = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf(Mode == SynapseModule.SynapseModuleMode.Production ? "\\Prod\\" : "\\Dev\\")) + "\\Synapse.exe";
                        if (file != null)
                        {
                            SynapseCore.Controls.SynapseForm.SynapseLogger.Debug("starting " + file);
                            System.Diagnostics.Process proc = new System.Diagnostics.Process();
                            proc.EnableRaisingEvents        = false;
                            proc.StartInfo.WindowStyle      = System.Diagnostics.ProcessWindowStyle.Normal;
                            proc.StartInfo.FileName         = file;
                            proc.StartInfo.WorkingDirectory = Path.GetFullPath(file);
                            proc.StartInfo.Arguments        = Mode == SynapseModule.SynapseModuleMode.Production ? "" : "/con:ACC";
                            proc.Start();
                        }
                        else
                        {
                            SynapseCore.Controls.SynapseForm.SynapseLogger.Debug("Not exist " + file);
                        }
                        Application.Exit();
                    }
                    // TODO: Replace by more specific exception
                    catch (Exception)
                    {
                        if (!FormUser.IsMemberOf("SYNAPSE_SECURITY_ADMIN"))
                        {
                            MessageBox.Show("Application not in right location !");
                            Application.Exit();
                        }
                    }
                }

                SynapseLogger.Debug("Message Development");
                if (Mode == SynapseModule.SynapseModuleMode.Development && !DevACK)
                {
                    MessageBox.Show(Properties.Resources.ResourceManager.GetString(LangMessage + "_DevelopmentMode"));
                    DevACK = true;
                }
                try
                {
                    ScanControl = bool.Parse(ConfigurationManager.AppSettings["ScanControl"]);
                }
                // DONE: Replaced by more specific exception (see http://msdn.microsoft.com/en-us/library/vstudio/system.configuration.configurationmanager.appsettings(v=vs.90).aspx)
                catch (ConfigurationErrorsException)
                {
                    // TODO: Remove swallowing of Exception
                }

                if (UpdateControls && ModuleID != 0 && ScanControl)
                {
                    System.IO.TextWriter w = new System.IO.StreamWriter(Application.StartupPath + "\\" + this.Name + "_res.SynapseResource", false, System.Text.Encoding.Unicode);
                    w.Write(SynapseCore.Security.Tools.UpdateControlsInDB(this.Controls, this.ModuleID, null).ToString());

                    w.Flush();
                    w.Close();
                }

                SynapseLogger.Debug("Init Form");
                initForm(Security.Tools.SecureAndTranslateMode.Secure | Security.Tools.SecureAndTranslateMode.Transalte);
            }
        }