private void Window_Loaded(object sender, RoutedEventArgs e) { //Создаем таймер для обновления времени и даты DispatcherTimer t = new DispatcherTimer(); t.Tick += new EventHandler(timerTick); t.Interval = TimeSpan.FromMilliseconds(500); t.Start(); getData = rwList.readData(); iter = getData.prj.Count(); for (int i = 0; i < 10; i++) { notes.Add(new Note() { dateT = getData.dateT[i], project = getData.prj[i], description = getData.descr[i], taskTime = getData.taskTime[i] }); } DG1.ItemsSource = notes; DGPrj.ItemsSource = readPrList(); dateSelect.SelectedDate = DateTime.Today; prjComboBox(); WrapPanel WP = new WrapPanel(); ProjInfo prInf = new ProjInfo(filePath); WP = prInf.prjInfo(); grWP.Children.Add(WP); grWP.Height = WP.Height; }
private void SaveProj_Click(object sender, RoutedEventArgs e) { ExcelApp = new Excel.Application(); ExcelApp.Visible = true; WorkBookExcel = ExcelApp.Workbooks.Open(_filePath, false); WorkSheetExcel = (Excel.Worksheet)WorkBookExcel.Sheets["Processes"]; List<string> row = new List<string>(); int n = 6; int count = 0; row = new List<string>(); row.Add(Convert.ToString(prjSelect2.SelectedValue)); row.Add(prjHour.Text); int statSpendHour1=0; int statOstHour1=0; float statOstDay1=0; getData = rwList.readData(); for (int i = 0; i < getData.prj.Count; i++) { notes.Add(new Note() { dateT = getData.dateT[i], project = getData.prj[i], description = getData.descr[i], taskTime = getData.taskTime[i] }); } //notes = rwList.readData(); for (int i = 0; i < notes.Count; i++) { if (Convert.ToString(prjSelect2.SelectedValue) == notes[i].project) { statSpendHour1 = statSpendHour1 + Convert.ToInt16(notes[i].taskTime); } //statSpendHour1 = statSpendHour1 + Convert.ToInt16(getData.taskTime[i]); } statOstHour1 = Convert.ToInt32(prjHour.Text) - statSpendHour1; statOstDay1 = statOstHour1 / 8; row.Add(Convert.ToString(statSpendHour1)); row.Add(Convert.ToString(statOstHour1)); row.Add(Convert.ToString(statOstDay1)); Mas2.Add(row); count++; for (int i = 2; WorkSheetExcel.Cells[i, 1].Text.ToString() != ""; i++) { row = new List<string>(); for (int j = 1; j < n; j++) row.Add(WorkSheetExcel.Cells[i, j].Text.ToString()); //строка массива заполняется просто суммой i и j Mas2.Add(row); //строка добавляется в массив count++; } for (int i = 0; i<count; i++) { RangeExcel = (Excel.Range)WorkSheetExcel.Cells[i + 2, 1]; RangeExcel.Value = Mas2[i][0]; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[i + 2, 2]; RangeExcel.Value = Mas2[i][1]; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[i + 2, 3]; RangeExcel.Value = Mas2[i][2]; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[i + 2, 4]; RangeExcel.Value = Mas2[i][3]; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[i + 2, 5]; RangeExcel.Value = Mas2[i][4]; } WorkBookExcel.Close(true, Type.Missing, Type.Missing); ExcelApp.Quit(); GC.Collect(); this.Close(); }
private void excelWrite() { notes.Clear(); iter += 2; ExcelApp = new Excel.Application(); ExcelApp.Visible = true; WorkBookExcel = ExcelApp.Workbooks.Open(filePath, false); //открываем книгу WorkSheetExcel = (Excel.Worksheet)WorkBookExcel.Sheets[1]; //Получаем ссылку на лист 1 RangeExcel = (Excel.Range)WorkSheetExcel.Cells[iter, 1]; RangeExcel.Value = dateSelect.Text; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[iter, 2]; RangeExcel.Value = prjSelect.Text; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[iter, 3]; RangeExcel.Value = descrAdd.Text; RangeExcel = (Excel.Range)WorkSheetExcel.Cells[iter, 4]; RangeExcel.Value = timeAdd.Text; WorkBookExcel.Close(true, Type.Missing, Type.Missing); ExcelApp.Quit(); GC.Collect(); DG1.ItemsSource = null; getData = rwList.readData(); iter = getData.prj.Count(); for (int i = 0; i < 10; i++) { notes.Add(new Note() { dateT = getData.dateT[i], project = getData.prj[i], description = getData.descr[i], taskTime = getData.taskTime[i] }); } DG1.ItemsSource = notes; //excelRead(); cleanFilds(); }