private static void fileSaveDialog(string fileName, FdcSectionA fdcSectionA, List <FdcSectionB> fdcSectionBList, FdcSectionC fdcSectionC, int type, int relativesCount) { ///* SaveFileDialog savefile = new SaveFileDialog(); savefile.FileName = fileName; savefile.Filter = "Excel files (*.xls)|*.xls"; //|Excel 2007 files (*.xlsx)|*.xlsx"; if (savefile.ShowDialog() == DialogResult.OK) { FdcFormTemplate fdcForm = type == 1 ? new FdcFormTemplate(savefile.FileName, fdcSectionA, fdcSectionBList, fdcSectionC) : new FdcFormTemplate(savefile.FileName, relativesCount); } //*/ /* * for (int i = 0; i < 61; i++) * { * new FdcFormTemplate(fileName + "-" + i + ".xls", i); * } */ }
private void SectionEndButton_Clicked(object sender, EventArgs e) { List <int> checker = new List <int>(); for (int rc = 1; rc <= int.Parse(relativesCount); rc++) { int check = 0; Control sectionBgroupBox1 = Controls["sectionB" + rc + "groupBox" + "1"]; for (int i = 0; i < contentSectionB.Count; i++) { Control control = sectionBgroupBox1.Controls["sectionB" + rc + "radioButton" + i]; if (control is RadioButtonGrouped) { if ((control as RadioButtonGrouped).Checked) { check++; } ; } } if (check == 5) { checker.Add(check); } } if (checker.Count == int.Parse(relativesCount)) { List <string> temp = new List <string>(); //SectionA Control sectionAgroupBox1 = Controls["sectionAgroupBox1"]; for (int i = 0; i < contentSectionA.Count; i++) { Control control = sectionAgroupBox1.Controls["sectionAtextBox" + i]; temp.Add(control.Text); } FdcSectionA fdcSectionA = new FdcSectionA(DateTime.Now.ToString("ddMMyyyy"), temp[0], temp[1], temp[2]); //SectionB List <FdcSectionB> fdcSectionBList = new List <FdcSectionB>(); for (int rc = 1; rc <= int.Parse(relativesCount); rc++) { temp = new List <string>(); Control sectionBgroupBox1 = Controls["sectionB" + rc + "groupBox" + "1"]; for (int i = 0; i < contentSectionB.Count; i++) { Control control; control = sectionBgroupBox1.Controls["sectionB" + rc + "dateTimePicker" + i]; if (control is DateTimePicker) { string birth = (control as DateTimePicker).Value.ToString("ddMMyyyy") != DateTime.Now.ToString("ddMMyyyy") ? (control as DateTimePicker).Value.ToString("ddMMyyyy") : ""; temp.Add(birth); } control = sectionBgroupBox1.Controls["sectionB" + rc + "radioButton" + i]; if (control is RadioButtonGrouped) { if ((control as RadioButtonGrouped).Checked) { temp.Add((control as RadioButtonGrouped).Text); } ; } control = sectionBgroupBox1.Controls["sectionB" + rc + "textBox" + i]; if (control is TextBox) { temp.Add((control as TextBox).Text); } } Control sectionBgroupBox2 = sectionBgroupBox1.Controls["sectionB" + rc + "groupBox" + "2"]; for (int c = 0; c < contentSectionC.Count; c++) { Control control; control = sectionBgroupBox2.Controls["sectionC" + rc + "textBox" + c]; if (control is TextBox) { temp.Add((control as TextBox).Text); } } FdcSectionB fdcSectionB = new FdcSectionB(temp[0], temp[1], temp[5] == (string)contentSectionB[10][0] ? temp[6] : "", temp[2], temp[3], temp[5] == (string)contentSectionB[10][0] ? "" : temp[5] == (string)contentSectionB[11][0] ? "1" : "2", temp[5] != (string)contentSectionB[10][0] ? temp[5] : "", temp[5] != (string)contentSectionB[10][0] ? temp[6] : "", temp[7], temp[7] == (string)contentSectionB[15][0]?"01":temp[7] == (string)contentSectionB[16][0]?"11": temp[7] == (string)contentSectionB[17][0]?"21":temp[7] == (string)contentSectionB[18][0]?"30": temp[7] == (string)contentSectionB[19][0]?"31":temp[7] == (string)contentSectionB[20][0]?"32": temp[7] == (string)contentSectionB[21][0]?"33":temp[7] == (string)contentSectionB[22][0]?"40": temp[7] == (string)contentSectionB[23][0]?"41":temp[7] == (string)contentSectionB[24][0]?"50": temp[7] == (string)contentSectionB[25][0]?"60":"", temp[8], temp[8] == (string)contentSectionB[27][0]?"0":temp[8] == (string)contentSectionB[28][0]?"1": temp[8] == (string)contentSectionB[29][0]?"2":temp[8] == (string)contentSectionB[30][0]?"3": temp[8] == (string)contentSectionB[31][0]?"4":"", temp[9], temp[10], temp[11], temp[12], temp[13], temp[14], temp[15], temp[16]); fdcSectionBList.Add(fdcSectionB); } //SectionC Control sectionDgroupBox1 = Controls["sectionDgroupBox1"]; temp = new List <string>(); for (int i = 0; i < contentSectionD.Count; i++) { Control control = sectionDgroupBox1.Controls["sectionDtextBox" + i]; temp.Add(control.Text); } FdcSectionC fdcSectionC = new FdcSectionC(DateTime.Now.ToString("ddMMyyyy"), temp[0]); fileSaveDialog("FormularzZDanymi", fdcSectionA, fdcSectionBList, fdcSectionC, 1, int.Parse(relativesCount)); } else { MessageBox.Show("Proszę zaznaczyć wszystkie opcje"); } }