private void LoadData() { System.IO.StreamReader file = new System.IO.StreamReader( new System.IO.IsolatedStorage.IsolatedStorageFileStream("Duom.txt",System.IO.FileMode.OpenOrCreate, System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())); Employees.Items.Clear(); Indicators.Items.Clear(); Tasks.Items.Clear(); if (AEC == null) { AEC = new List<ArchyvedEmployeeClass>(); } else { AEC.Clear(); } Boolean NeraTuscias = false; while (file.EndOfStream != true) { NeraTuscias = true; string eilute = file.ReadLine(); if (eilute == "Darbuotoju lentele:") { int index = Convert.ToInt32(file.ReadLine()); for (int i = 0; i < index; i++) { string[] reiksmes = file.ReadLine().Split(Skirtukas); EmployeeClass EC = new EmployeeClass(); EC.NameLine = reiksmes[0]; EC.BALine = ParseDouble(reiksmes[1]); EC.RODLine = ParseDouble(reiksmes[2]); EC.UZDLine = ParseDouble(reiksmes[3]); EC.VisoLine = ParseDouble(reiksmes[4]); EC.IsChecked = false; EC.index = i; reiksmes = file.ReadLine().Split(Skirtukas); int rod = Convert.ToInt32(reiksmes[0]); int uzd = Convert.ToInt32(reiksmes[1]); EC.MaxKDP = ParseDouble(reiksmes[2]); EC.RodList = new List<IndicatorsClass>(); EC.UzdList = new List<TasksClass>(); for (int j = 0; j < rod; j++) { reiksmes = file.ReadLine().Split(Skirtukas); IndicatorsClass ind = new IndicatorsClass(); ind.INDPAVLine = reiksmes[0]; ind.BRLine = ParseDouble(reiksmes[1]); ind.FRLine = ParseDouble(reiksmes[2]); ind.TRLine = ParseDouble(reiksmes[3]); ind.MKDLine = ParseDouble(reiksmes[4]); ind.IsChecked = false; ind.index = j; EC.RodList.Add(ind); } for (int j = 0; j < uzd; j++) { reiksmes = file.ReadLine().Split(Skirtukas); TasksClass tsk = new TasksClass(); tsk.UZDPAVLine = reiksmes[0]; tsk.MaxIvert = ParseDouble(reiksmes[1]); tsk.Ivert = ParseDouble(reiksmes[2]); tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = j; EC.UzdList.Add(tsk); } Employees.Items.Add(EC); } } else if (eilute == "Rodikliu lentele:") { int index = Convert.ToInt32(file.ReadLine()); for (int i = 0; i < index; i++) { string[] reiksmes = file.ReadLine().Split(Skirtukas); IndicatorsClass ind = new IndicatorsClass(); ind.INDPAVLine = reiksmes[0]; ind.BRLine = ParseDouble(reiksmes[1]); ind.FRLine = ParseDouble(reiksmes[2]); ind.TRLine = ParseDouble(reiksmes[3]); ind.MKDLine = ParseDouble(reiksmes[4]); ind.IsChecked = false; ind.index = i; Indicators.Items.Add(ind); } } else if (eilute == "Uzduociu lentele:") { int index = Convert.ToInt32(file.ReadLine()); for (int i = 0; i < index; i++) { string[] reiksmes = file.ReadLine().Split(Skirtukas); TasksClass tsk = new TasksClass(); tsk.UZDPAVLine = reiksmes[0]; tsk.MaxIvert = ParseDouble(reiksmes[1]); tsk.Ivert = ParseDouble(reiksmes[2]); tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = i; Tasks.Items.Add(tsk); } } else if (eilute == "Archyvo lentele:") { int index = Convert.ToInt32(file.ReadLine()); AEC = new List<ArchyvedEmployeeClass>(); for (int i = 0; i < index; i++) { string[] reiksmes = file.ReadLine().Split(Skirtukas); ArchyvedEmployeeClass EC = new ArchyvedEmployeeClass(); EC.NameLine = reiksmes[0]; EC.BALine = ParseDouble(reiksmes[1]); EC.RODLine = ParseDouble(reiksmes[2]); EC.UZDLine = ParseDouble(reiksmes[3]); EC.VisoLine = ParseDouble(reiksmes[4]); EC.Date = reiksmes[5]; EC.IsChecked = false; EC.index = i; reiksmes = file.ReadLine().Split(Skirtukas); int rod = Convert.ToInt32(reiksmes[0]); int uzd = Convert.ToInt32(reiksmes[1]); EC.MaxKDP = ParseDouble(reiksmes[2]); EC.RodList = new List<IndicatorsClass>(); EC.UzdList = new List<TasksClass>(); for (int j = 0; j < rod; j++) { reiksmes = file.ReadLine().Split(Skirtukas); IndicatorsClass ind = new IndicatorsClass(); ind.INDPAVLine = reiksmes[0]; ind.BRLine = ParseDouble(reiksmes[1]); ind.FRLine = ParseDouble(reiksmes[2]); ind.TRLine = ParseDouble(reiksmes[3]); ind.MKDLine = ParseDouble(reiksmes[4]); ind.IsChecked = false; ind.index = j; EC.RodList.Add(ind); } for (int j = 0; j < uzd; j++) { reiksmes = file.ReadLine().Split(Skirtukas); TasksClass tsk = new TasksClass(); tsk.UZDPAVLine = reiksmes[0]; tsk.MaxIvert = ParseDouble(reiksmes[1]); tsk.Ivert = ParseDouble(reiksmes[2]); tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = j; EC.UzdList.Add(tsk); } AEC.Add(EC); } } } file.Close(); if (Employees.Items.Count == 0 && Tasks.Items.Count == 0 && Indicators.Items.Count == 0 && AEC.Count == 0 && NeraTuscias == false) { EmployeeClass EC = new EmployeeClass(); EC.index = 0; EC.IsChecked = false; EC.NameLine = "Marko"; EC.BALine = 1000.00; EC.RODLine = 0; EC.UZDLine = 0; EC.VisoLine = 1000.00; EC.MaxKDP = 0; EC.RodList = new List<IndicatorsClass>() { }; EC.UzdList = new List<TasksClass>() { }; Employees.Items.Add(EC); EC = new EmployeeClass(); EC.index = 1; EC.IsChecked = false; EC.NameLine = "Employee 2"; EC.BALine = 2000.00; EC.RODLine = 0; EC.UZDLine = 0; EC.VisoLine = 2000.00; EC.MaxKDP = 0; EC.RodList = new List<IndicatorsClass>() { }; EC.UzdList = new List<TasksClass>() { }; Employees.Items.Add(EC); EC = new EmployeeClass(); EC.index = 2; EC.IsChecked = false; EC.NameLine = "Employee 3"; EC.BALine = 3000.00; EC.RODLine = 0; EC.UZDLine = 0; EC.VisoLine = 3000.00; EC.MaxKDP = 0; EC.RodList = new List<IndicatorsClass>() { }; EC.UzdList = new List<TasksClass>() { }; Employees.Items.Add(EC); IndicatorsClass ind = new IndicatorsClass(); ind.INDPAVLine = "PROFIT"; ind.BRLine = 100000.0; ind.FRLine = 121000.0; ind.TRLine = 130000.00; ind.MKDLine = 1200.0; ind.IsChecked = false; ind.index = 0; Indicators.Items.Add(ind); ind = new IndicatorsClass(); ind.INDPAVLine = "COSTS"; ind.BRLine = 500000.0; ind.FRLine = 480000.0; ind.TRLine = 450000.00; ind.MKDLine = 800.0; ind.IsChecked = false; ind.index = 1; Indicators.Items.Add(ind); ind = new IndicatorsClass(); ind.INDPAVLine = "Indicator 3"; ind.BRLine = 2.0; ind.FRLine = 2.4; ind.TRLine = 4.0; ind.MKDLine = 2.0; ind.IsChecked = false; ind.index = 2; Indicators.Items.Add(ind); ind = new IndicatorsClass(); ind.INDPAVLine = "Indicator 4"; ind.BRLine = 3.00; ind.FRLine = 3.6; ind.TRLine = 6.00; ind.MKDLine = 3.00; ind.IsChecked = false; ind.index = 3; Indicators.Items.Add(ind); TasksClass tsk = new TasksClass(); tsk.UZDPAVLine = "RELATIONSHIP WITH..."; tsk.MaxIvert = 11.0; tsk.Ivert = 9.0; tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = 0; Tasks.Items.Add(tsk); tsk = new TasksClass(); tsk.UZDPAVLine = "CUTTING ON THE RET..."; tsk.MaxIvert = 9.0; tsk.Ivert = 5.0; tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = 1; Tasks.Items.Add(tsk); tsk = new TasksClass(); tsk.UZDPAVLine = "IMPROVING PROFESS..."; tsk.MaxIvert = 7.0; tsk.Ivert = 6.0; tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = 2; Tasks.Items.Add(tsk); tsk = new TasksClass(); tsk.UZDPAVLine = "TASK 4"; tsk.MaxIvert = 8.0; tsk.Ivert = 7.0; tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = 3; Tasks.Items.Add(tsk); tsk = new TasksClass(); tsk.UZDPAVLine = "TASK 5"; tsk.MaxIvert = 9.0; tsk.Ivert = 8.0; tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = 3; Tasks.Items.Add(tsk); AEC.Clear(); ArchyvedEmployeeClass ECA = new ArchyvedEmployeeClass(); ECA.NameLine = "Marko"; ECA.BALine = 1000.00; ECA.RODLine = 0; ECA.UZDLine = 0; ECA.VisoLine = 1000.00; ECA.Date = "2014.06.16"; ECA.IsChecked = false; ECA.index = 0; ECA.RodList = new List<IndicatorsClass>() { }; ECA.UzdList = new List<TasksClass>() { }; AEC.Add(ECA); ECA = new ArchyvedEmployeeClass(); ECA.NameLine = "Employee 2"; ECA.BALine = 2000.00; ECA.RODLine = 0; ECA.UZDLine = 0; ECA.VisoLine = 2000.00; ECA.Date = "2014.06.16"; ECA.IsChecked = false; ECA.index = 1; ECA.RodList = new List<IndicatorsClass>() { }; ECA.UzdList = new List<TasksClass>() { }; AEC.Add(ECA); ECA = new ArchyvedEmployeeClass(); ECA.NameLine = "Employee 3"; ECA.BALine = 3000.00; ECA.RODLine = 0; ECA.UZDLine = 0; ECA.VisoLine = 3000.00; ECA.Date = "2014.06.16"; ECA.IsChecked = false; ECA.index = 2; ECA.RodList = new List<IndicatorsClass>() { }; ECA.UzdList = new List<TasksClass>() { }; AEC.Add(ECA); } }
private void Read_Workers(ref List<ArchyvedEmployeeClass> ECC, EmployeeClass emp) { int i = 0; System.IO.StreamReader file = new System.IO.StreamReader(new System.IO.IsolatedStorage.IsolatedStorageFileStream("Excel.txt", System.IO.FileMode.OpenOrCreate, System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())); while (file.EndOfStream != true) { i = Convert.ToInt32(file.ReadLine()); ECC = new List<ArchyvedEmployeeClass>(); for (int n = 0; n < i; n++) { string[] reiksmes = file.ReadLine().Split(Skirtukas); ArchyvedEmployeeClass EC = new ArchyvedEmployeeClass(); EC.NameLine = reiksmes[0]; EC.BALine = ParseDouble(reiksmes[1]); EC.RODLine = ParseDouble(reiksmes[2]); EC.UZDLine = ParseDouble(reiksmes[3]); EC.VisoLine = ParseDouble(reiksmes[4]); EC.Date = reiksmes[5]; EC.IsChecked = false; EC.index = n; reiksmes = file.ReadLine().Split(Skirtukas); int rod = Convert.ToInt32(reiksmes[0]); int uzd = Convert.ToInt32(reiksmes[1]); EC.MaxKDP = ParseDouble(reiksmes[2]); EC.RodList = new List<IndicatorsClass>(); EC.UzdList = new List<TasksClass>(); for (int j = 0; j < rod; j++) { reiksmes = file.ReadLine().Split(Skirtukas); IndicatorsClass ind = new IndicatorsClass(); ind.INDPAVLine = reiksmes[0]; ind.BRLine = ParseDouble(reiksmes[1]); ind.FRLine = ParseDouble(reiksmes[2]); ind.TRLine = ParseDouble(reiksmes[3]); ind.MKDLine = ParseDouble(reiksmes[4]); ind.IsChecked = false; ind.index = j; EC.RodList.Add(ind); } for (int j = 0; j < uzd; j++) { reiksmes = file.ReadLine().Split(Skirtukas); TasksClass tsk = new TasksClass(); tsk.UZDPAVLine = reiksmes[0]; tsk.MaxIvert = ParseDouble(reiksmes[1]); tsk.Ivert = ParseDouble(reiksmes[2]); tsk.IVERTLine = (tsk.Ivert + " / " + tsk.MaxIvert).ToString(); tsk.IsChecked = false; tsk.index = j; EC.UzdList.Add(tsk); } ECC.Add(EC); } } file.Close(); ArchyvedEmployeeClass empp = new ArchyvedEmployeeClass(); empp.BALine = emp.BALine; empp.Date = DateTime.UtcNow.Date.ToString("yyyy.MM.dd"); empp.index = i; empp.IsChecked = false; empp.MaxKDP = emp.MaxKDP; empp.NameLine = emp.NameLine; empp.RODLine = emp.RODLine; empp.RodList = new List<IndicatorsClass>(emp.RodList); empp.UZDLine = emp.UZDLine; empp.UzdList = new List<TasksClass>(emp.UzdList); empp.VisoLine = emp.VisoLine; ECC.Add(empp); ArchyvedEmployeeClass em = new ArchyvedEmployeeClass(); em.BALine = emp.BALine; em.Date = DateTime.UtcNow.Date.ToString("yyyy.MM.dd"); em.index = AEC.Count; em.IsChecked = false; em.MaxKDP = emp.MaxKDP; em.NameLine = emp.NameLine; em.RODLine = emp.RODLine; em.RodList = new List<IndicatorsClass>(emp.RodList); em.UZDLine = emp.UZDLine; em.UzdList = new List<TasksClass>(emp.UzdList); em.VisoLine = emp.VisoLine; AEC.Add(em); System.IO.StreamWriter fileW = new System.IO.StreamWriter(new System.IO.IsolatedStorage.IsolatedStorageFileStream("Excel.txt", System.IO.FileMode.Create, System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())); fileW.WriteLine(ECC.Count); for (int n = 0; n < ECC.Count; n++) { fileW.WriteLine(ECC[n].NameLine + Skirtukas + ECC[n].BALine.ToString() + Skirtukas + ECC[n].RODLine.ToString() + Skirtukas + ECC[n].UZDLine.ToString() + Skirtukas + ECC[n].VisoLine.ToString() + Skirtukas + ECC[n].Date); if (ECC[n].RodList == null) { ECC[n].RodList = new List<IndicatorsClass>(); } if (ECC[n].UzdList == null) { ECC[n].UzdList = new List<TasksClass>(); } fileW.WriteLine(ECC[n].RodList.Count.ToString() + Skirtukas + ECC[n].UzdList.Count.ToString() + Skirtukas + ECC[n].MaxKDP.ToString()); for (int j = 0; j < ECC[n].RodList.Count; j++) { fileW.WriteLine(ECC[n].RodList[j].INDPAVLine + Skirtukas + ECC[n].RodList[j].BRLine.ToString() + Skirtukas + ECC[n].RodList[j].FRLine.ToString() + Skirtukas + ECC[n].RodList[j].TRLine.ToString() + Skirtukas + ECC[n].RodList[j].MKDLine.ToString()); } for (int j = 0; j < ECC[n].UzdList.Count; j++) { fileW.WriteLine(ECC[n].UzdList[j].UZDPAVLine + Skirtukas + ECC[n].UzdList[j].MaxIvert.ToString() + Skirtukas + ECC[n].UzdList[j].Ivert.ToString()); } } fileW.Close(); }
private void CreateNewEmployee_Click(object sender, RoutedEventArgs e) { Boolean proceed = true; this.Focus(); TextboxInFocus = false; LastSelectedTextbox = new TextBox(); AddBarEmployee.Height = 280; AddBarIndicator.Height = 545; AddBarTask.Height = 380; AddBarEmployee.VerticalAlignment = AddBarIndicator.VerticalAlignment = AddBarTask.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; AddBarEmployee.ScrollToVerticalOffset(0); AddBarIndicator.ScrollToVerticalOffset(0); AddBarTask.ScrollToVerticalOffset(0); DoubleClickOnTextbox = false; if (NameBox.Text == "") { MessageBox.Show(AppResources.error_employee_name_empty); proceed = false; } else if (BABox.Text == "") { MessageBox.Show(AppResources.error_salary_empty); proceed = false; } else { double rezult = 0; try { rezult = double.Parse(BABox.Text); } catch (Exception) { MessageBox.Show(AppResources.error_salary_number); proceed = false; } } if (proceed == true) { if(double.Parse(BABox.Text) < 0) { MessageBox.Show(AppResources.error_salary_number); proceed = false; } } if(proceed == true) { if (AddNewItem == true) { EmployeeClass EC = new EmployeeClass(); EC.NameLine = NameBox.Text; EC.BALine = double.Parse(BABox.Text); EC.RODLine = 0; EC.UZDLine = 0; EC.VisoLine = EC.BALine + EC.RODLine + EC.UZDLine; EC.IsChecked = false; EC.index = Employees.Items.Count; Employees.Items.Add(EC); } else { EmployeeClass EC = (EmployeeClass)Employees.Items[Employees.SelectedIndex]; EC.NameLine = NameBox.Text; EC.BALine = double.Parse(BABox.Text); EC.VisoLine = EC.BALine + EC.RODLine + EC.UZDLine; Employees.Items[Employees.SelectedIndex] = EC; } KillAll(); NameBox.Text = ""; BABox.Text = ""; } }