Esempio n. 1
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_UserName.Text != "" && txt_Password.Text != "")
         {
             if (UserComponent.checkAtiranUserName(txt_UserName.Text) == 0)
             {
                 if (txt_Password.Text.Trim().Equals(txt_ConfPassword.Text.Trim()))
                 {
                     int result = 0;
                     result = UserComponent.InserToUser(txt_UserName.Text, txt_Password.Text);
                     if (result > 0)
                     {
                         txt_UserName.Text = "";
                         txt_Password.Text = "";
                         txt_ConfPassword.Clear();
                         CustomMessageForm.CustomMessageBox.Show("پیغام", "ثبت اطلاعات با موفقیت انجام شد");
                         dataGridView1.DataSource = UserComponent.GetUsers();
                         setgridview();
                         // new by sharafzade
                         DialogResult x = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيغام", "آيا ميخواهيد براي كاربر تعريف شده، زير سيستم اختصاص دهيد؟", "w");
                         if (x == DialogResult.Yes)
                         {
                             ModuleAccessControl UAC    = new ModuleAccessControl(true, result);
                             UserControlLoader   loader = new UserControlLoader(UAC);
                         }
                     }
                     else
                     {
                         CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ثبت اطلاعات");
                     }
                 }
                 else
                 {
                     CustomMessageForm.CustomMessageBox.Show("پیغام", "كلمه هاي عبور وارد شده مطابقت ندارد", "e");
                     txt_Password.Clear();
                     txt_ConfPassword.Clear();
                     txt_Password.Focus();
                 }
             }
             else
             {
                 CustomMessageForm.CustomMessageBox.Show("پیغام", "نام کاربری تکراری می باشد، لطفا نام کاربری دیگری انتخاب نمایید.");
             }
         }
         else
         {
             CustomMessageForm.CustomMessageBox.Show("پیغام", "نام، نام خانوادگی، نام کاربری و کلمه عبور نمی تواند خالی باشد");
         }
     }
     catch (Exception ex)
     {
         CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ثبت اطلاعات");
     }
 }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (cb_User.SelectedValue == null)
            {
                Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("هشدار", "نام كاربر را انتخاب نماييد", "e");
                cb_User.Focus();
                cb_User.DroppedDown = true;
                return;
            }
            Atiran.Connections.Operaions.SubSystemPermissionOp.SubSystemPermissionOperaion.DeleteModulePermission(int.Parse(cb_User.SelectedValue.ToString()));
            Atiran.Connections.Operaions.SubSystemPermissionOp.SubSystemPermissionOperaion.insertToModulePermission(int.Parse(cb_User.SelectedValue.ToString()), ModuleNodes.Distinct().ToList(), ModuleNodesOrginal.Distinct().ToList());
            CustomMessageForm.CustomMessageBox.Show("پیغام", " ثبت با موفقیت انجام گرفت ");
            DialogResult x = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيغام", "آيا ميخواهيد براي كاربر تعريف شده، تعيين سطوح دسترسي زير سيستم‌ها را مشخص كنيد؟", "w");

            if (x == DialogResult.Yes)
            {
                UserAccessControl UAC    = new UserAccessControl(true, int.Parse(cb_User.SelectedValue.ToString()));
                UserControlLoader loader = new UserControlLoader(UAC);
            }
            if (status)
            {
                this.ParentForm.Close();
            }
        }
Esempio n. 3
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case (Keys.Menu | Keys.Alt):
            {
                List <HubButton> buttons = hubItem.Controls.OfType <HubButton>().ToList();

                buttons.ForEach(i =>
                    {
                        if (i.SubSystemID == 8 | i.SubSystemID == 12)
                        {
                            i.Title.Select(1, 1);
                        }
                        else
                        {
                            i.Title.Select(0, 1);
                        }

                        i.Title.SelectionColor = Color.Crimson;
                    });
                timer.Start();
                return(true);
            }

            case (Keys.Alt | Keys.H):
            {
                HubButton button = new HubButton(Definitions.EnvironmentNames.BasicInformation, this);
                button.RunModule(Definitions.EnvironmentNames.BasicInformation);
                button.Dispose();
                return(true);
            }

            case (Keys.Alt | Keys.J):
            {
                HubButton button = new HubButton(Definitions.EnvironmentNames.Settings, this);
                button.RunModule(Definitions.EnvironmentNames.Settings);
                button.Dispose();
                return(true);
            }

            case (Keys.Alt | Keys.A):
            {
                HubButton button = new HubButton(Definitions.EnvironmentNames.BackupAndRestore, this);
                button.RunModule(Definitions.EnvironmentNames.BackupAndRestore);
                button.Dispose();
                return(true);
            }

            case ((Keys)Atiran.Connections.Enums.ShortcutKeyEnum.HelpKey):
            {
                Help H = new Help();
                UserControlLoader u = new UserControlLoader(H, true, false, true, false);
                return(true);
            }

            case (Keys.Alt | Keys.F4):
            {
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 0;
                DialogResult close =
                    Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام سيستم",
                                                                                                "آيا مي خواهيد از سيستم خارج شويد؟", "w");
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 1;
                if (close == DialogResult.Yes)
                {
                    if (Connections.Operaions.UserFormPermissionOp.FormPermission.CheckBackupPermission())
                    {
                        DialogResult res =
                            Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show(
                                "پيام سيستم", "آيا مي خواهيد از اطلاعات پشتيبان بگيريد؟", "w");
                        if (res == DialogResult.Yes)
                        {
                            // backup
                            UI.WindowsForms.Controls.FastBackup c = new UI.WindowsForms.Controls.FastBackup();
                            UserControlLoader(c);
                        }
                    }

                    Application.Exit();
                }

                return(true);
            }

            case (Keys)Atiran.Connections.Enums.ShortcutKeyEnum.SearchFormsKey:
            {
                try
                {
                    List <Atiran.Connections.AtiranAccModel.Menu> menu = new List <Connections.AtiranAccModel.Menu>();
                    AtiranSpotlight spotlight = new AtiranSpotlight(menu);
                    new UserControlLoader(spotlight, true, false, true);
                    if (menu.Count > 0)
                    {
                        if (FormPermission.AccessUserForm((int?)menu[0].FormID ?? 0))
                        {
                            RunnerFromHub((Definitions.EnvironmentNames)menu[0].SubSystemID - 1, menu[0], true);
                        }
                        else
                        {
                            UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام", "شما به اين فرم دسترسي نداريد", "i");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                return(true);
            }

            //case (Keys.Alt | Keys.F7):
            //    {
            //        try
            //        {
            //            List<Atiran.Connections.AtiranAccModel.Menu> menu = new List<Connections.AtiranAccModel.Menu>();
            //            UI.WindowsForms.Shortcuts.AtiranShortcuts ShortCutHere = new UI.WindowsForms.Shortcuts.AtiranShortcuts(menu);
            //            ShortCutHere.pnlLeft.Visible = false;
            //            ShortCutHere.Width = 470;
            //            Atiran.UI.WindowsForms.UIElements.Form frm = new Atiran.UI.WindowsForms.UIElements.Form
            //            {
            //                KeyPreview = true,
            //                StartPosition = System.Windows.Forms.FormStartPosition.Manual,
            //                Width = ShortCutHere.Width,
            //                Height = ShortCutHere.Height,
            //                MaximumSize = new Size(ShortCutHere.Width, ShortCutHere.Height)
            //            };
            //            ShortCutHere.Dock = System.Windows.Forms.DockStyle.Fill;
            //            frm.WindowState = System.Windows.Forms.FormWindowState.Normal;
            //            frm.Controls.Add(ShortCutHere);
            //            frm.Deactivate += (sender, e) => { ShortCutHere.ParentForm.Close(); };
            //            frm.Location = new Point(750, 39);
            //            frm.ShowDialog();
            //            if (menu.Count > 0)
            //            {
            //                if (Connections.Operaions.UserFormPermissionOp.FormPermission.AccessUserForm((int?)menu[0].FormID ?? 0))
            //                {
            //                    RunnerFromHub((Definitions.EnvironmentNames)menu[0].SubSystemID - 1, menu[0], true);
            //                }
            //                else
            //                {
            //                    UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام", "شما به اين فرم دسترسي نداريد", "i");
            //                }
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            MessageBox.Show(ex.ToString());
            //            throw;
            //        }
            //        return true;
            //    }
            case (Keys)Atiran.Connections.Enums.ShortcutKeyEnum.ActivatedFormKey:
            {
                try
                {
                    if (Atiran.UI.WindowsForms.UIElements.TabBar.StaticTabs == null || Atiran.UI.WindowsForms.UIElements.TabBar.StaticTabs.Count == 0)
                    {
                        Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيغام", "هيچ فرمي باز نشده است");
                        return(true);
                    }
                    List <Guid>          menu       = new List <Guid>();
                    AtiranActivatedForms ActiveHere = new AtiranActivatedForms(menu)
                    {
                        Width = 470
                    };
                    Atiran.UI.WindowsForms.UIElements.Form frm = new Atiran.UI.WindowsForms.UIElements.Form
                    {
                        KeyPreview    = true,
                        StartPosition = System.Windows.Forms.FormStartPosition.Manual,
                        Width         = ActiveHere.Width,
                        Height        = ActiveHere.Height,
                        MaximumSize   = new Size(ActiveHere.Width, ActiveHere.Height)
                    };
                    ActiveHere.Dock = System.Windows.Forms.DockStyle.Fill;
                    frm.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    frm.Controls.Add(ActiveHere);
                    frm.Deactivate += (sender, e) => { ActiveHere.ParentForm.Close(); };
                    //  frm.Location = new Point(MousePosition.X - 190, MousePosition.Y + 15);
                    frm.Location = new Point(800, 39);
                    // System.Windows.Forms.MessageBox.Show("X = " + MousePosition.X.ToString() + " Y = " + MousePosition.Y.ToString());
                    frm.ShowDialog();
                    if (menu.Count > 0)
                    {
                        foreach (Tab item in Atiran.UI.WindowsForms.UIElements.TabBar.StaticTabs)
                        {
                            if (item.control.UcGuid == menu.FirstOrDefault())
                            {
                                if (item.control.ProjectName == "Atiran.Accounting")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Accounting, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Accounting, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.BasicInformation")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.BasicInformation, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.BasicInformation, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.KalaGostaran")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.KalaGostaran, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.KalaGostaran, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Management")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.SalesManagement, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.SalesManagement, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Rahyab")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Rahyab, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Rahyab, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Reporting")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Reporting, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Reporting, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Sale")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Sales, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Sales, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Settings")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Settings, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Settings, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.SMS")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.SMS, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.SMS, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.TaskManager")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.EMS, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.EMS, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Treasury")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Treasury, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Treasury, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.BackupAndRestore")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.BackupAndRestore, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.BackupAndRestore, TabGUID: item.control.UcGuid);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                return(true);
            }
            }

            if (keyData == Keys.Escape)
            {
                // new by sharafzade
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 0;
                DialogResult res = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام سيستم", "آيا مي خواهيد آتيران را ترك كنيد؟", "w");
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 1;
                if (res == DialogResult.Yes)
                {
                    if (Connections.Operaions.UserFormPermissionOp.FormPermission.CheckBackupPermission())
                    {
                        DialogResult res1 = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام سيستم", "آيا مي خواهيد از اطلاعات پشتيبان بگيريد؟", "w");
                        if (res1 == DialogResult.Yes)
                        {
                            // backup
                            UI.WindowsForms.Controls.FastBackup c = new UI.WindowsForms.Controls.FastBackup();
                            UserControlLoader(c);
                        }
                    }

                    Application.Exit();
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }