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; } } } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LogicCore.Init(); Application.Run(new MainForm()); }
static public void SerializeToFile(LogicCore students) { var serializer = new XmlSerializer(typeof(LogicCore)); using (var streamWriter = new StreamWriter(_path)) { serializer.Serialize(streamWriter, students); streamWriter.Close(); } }
public static void Init() { _path = Properties.Settings.Default.DataPath; CoreHook = DeserializeFromFile(); for (int i = 0; i < CoreHook.employees.Count; i++) { CoreHook.employees[i].ValidateDismissal(); } }
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); }
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(); }
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); }
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); } } }
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; } } }
private void btnAdd_Click(object sender, EventArgs e) { new AddEditInfoForm().ShowDialog(this); LogicCore.SerializeToFile(LogicCore.CoreHook); RefreshDGV(); }
private void btnResetPath_Click(object sender, EventArgs e) { LogicCore.Path = Properties.Settings.Default.DataPathDefault; lbPathToSaveData.Text = LogicCore.Path; LogicCore.SerializeToFile(LogicCore.CoreHook); }
private void dgvDepartments_CellEndEdit(object sender, DataGridViewCellEventArgs e) { cbxDepartmentRefresh(); LogicCore.SerializeToFile(LogicCore.CoreHook); }