Пример #1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (chbJoinData.Checked)
            {
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    dialog.RestoreDirectory = true;
                    dialog.Filter           = "*.xml|*.xml| all files (*.*)|*.*";

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        string buffPath = LogicCore.Path;
                        LogicCore.Path = dialog.FileName;

                        LogicCore buffLogicCore = LogicCore.DeserializeFromFile();

                        LogicCore.Path = buffPath;

                        for (int i = 0; i < buffLogicCore.departments.Count; i++)
                        {
                            if (!LogicCore.CoreHook.departments.Exists(x => x.Text == buffLogicCore.departments[i].Text))
                            {
                                LogicCore.CoreHook.departments.Add(new StringModulToDGV(buffLogicCore.departments[i].Text));
                            }
                        }

                        uint buffIndex = ((List <Employee>)(LogicCore.CoreHook.employees.OrderByDescending(x => x.EmployeeID)))[0].EmployeeID + 1;

                        for (int i = 0; i < buffLogicCore.employees.Count; i++)
                        {
                            if (!LogicCore.CoreHook.employees.Exists(x => x.FakeIdentity() == buffLogicCore.employees[i].FakeIdentity()))
                            {
                                buffLogicCore.employees[i].EmployeeID = buffIndex;
                                buffIndex++;
                                LogicCore.CoreHook.employees.Add(buffLogicCore.employees[i]);
                            }
                        }
                    }
                }
            }
            else
            {
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    dialog.RestoreDirectory = true;
                    dialog.Filter           = "*.xml|*.xml| all files (*.*)|*.*";

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        string buffPath = LogicCore.Path;
                        LogicCore.Path = dialog.FileName;

                        LogicCore.Init();

                        LogicCore.Path = buffPath;
                    }
                }
            }
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LogicCore.Init();

            Application.Run(new MainForm());
        }
Пример #3
0
        static public void SerializeToFile(LogicCore students)
        {
            var serializer = new XmlSerializer(typeof(LogicCore));

            using (var streamWriter = new StreamWriter(_path))
            {
                serializer.Serialize(streamWriter, students);
                streamWriter.Close();
            }
        }
Пример #4
0
        public static void Init()
        {
            _path = Properties.Settings.Default.DataPath;

            CoreHook = DeserializeFromFile();

            for (int i = 0; i < CoreHook.employees.Count; i++)
            {
                CoreHook.employees[i].ValidateDismissal();
            }
        }
Пример #5
0
        private static LogicCore InitDefoult()
        {
            LogicCore buff = new LogicCore();

            buff.employees   = new List <Employee>();
            buff.departments = new List <StringModulToDGV>()
            {
                new StringModulToDGV("All"), new StringModulToDGV("---")
            };
            return(buff);
        }
Пример #6
0
        private void btnDismissal_Click(object sender, EventArgs e)
        {
            if (dgvEmployees.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select the person to dismissal", "Please select", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            new DismissalForm((Employee)dgvEmployees.SelectedRows[0].DataBoundItem).ShowDialog(this);
            LogicCore.SerializeToFile(LogicCore.CoreHook);
            RefreshDGV();
        }
Пример #7
0
        private void btnDeleteDepartment_Click(object sender, EventArgs e)
        {
            if (dgvDepartments.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select the group to be deleted", "Please select", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            LogicCore.CoreHook.departments.RemoveAt(LogicCore.CoreHook.departments.FindIndex(x => x == ((StringModulToDGV)dgvDepartments.SelectedRows[0].DataBoundItem)));
            RefreshDGVDepartments();
            LogicCore.SerializeToFile(LogicCore.CoreHook);
        }
Пример #8
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.FileName         = LogicCore.Path;
                dialog.RestoreDirectory = true;
                dialog.Filter           = "*.xml|*.xml| all files (*.*)|*.*";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    LogicCore.Path        = dialog.FileName;
                    lbPathToSaveData.Text = LogicCore.Path;
                    LogicCore.SerializeToFile(LogicCore.CoreHook);
                }
            }
        }
Пример #9
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.FileName         = LogicCore.Path;
                dialog.RestoreDirectory = true;
                dialog.Filter           = "*.xml|*.xml| all files (*.*)|*.*";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string buffPath = LogicCore.Path;
                    LogicCore.Path = dialog.FileName;

                    LogicCore.SerializeToFile(LogicCore.CoreHook);

                    LogicCore.Path = buffPath;
                }
            }
        }
Пример #10
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     new AddEditInfoForm().ShowDialog(this);
     LogicCore.SerializeToFile(LogicCore.CoreHook);
     RefreshDGV();
 }
Пример #11
0
 private void btnResetPath_Click(object sender, EventArgs e)
 {
     LogicCore.Path        = Properties.Settings.Default.DataPathDefault;
     lbPathToSaveData.Text = LogicCore.Path;
     LogicCore.SerializeToFile(LogicCore.CoreHook);
 }
Пример #12
0
 private void dgvDepartments_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     cbxDepartmentRefresh();
     LogicCore.SerializeToFile(LogicCore.CoreHook);
 }