private void button4_Click(object sender, EventArgs e) { try { ExelWork ex = new ExelWork(); ex.Paint(label5.Text, label8.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// составление списков оборудования и их количества private void button1_Click(object sender, EventArgs e) { string name = null; // название элемента string opora = null; // выбранная опора string str = null; string kol = null; // количество if (ListNameELement.Count != 0) { ListNameELement.Clear(); } if (ColELement.Count != 0) { ColELement.Clear(); } foreach (ComboBox com in this.Controls.OfType <ComboBox>()) { if (com.SelectedItem != null) { opora = com.SelectedItem.ToString(); name = com.Name.Substring(5); str = "textbox" + name; ListNameELement.Add(com.SelectedItem.ToString()); foreach (TextBox text in this.Controls.OfType <TextBox>()) { if (text.Name == str) { ColELement.Add(Convert.ToInt32(text.Text)); } } } } SearchOborud(); SearchOborud11m(); SearchOborud13m(); SearchOborud16m(); SearchOborudPP(); ExelWork exel = new ExelWork(); exel.Element(ListNameELement, ColELement); exel.ListName(CurrentOpory, CurrentRZ); exel.ListName11m(CurrentOpory11m, CurrentRZ11m); exel.ListName13m(CurrentOpory13m, CurrentRZ13m); exel.ListName16m(CurrentOpory16m); exel.ListNamePP(CurrentOporyPP); exel.Specification(); }
//формирование кабельно-трубного журнала private void button2_Click(object sender, EventArgs e) { int max = 0; //номер первого элемента int loc = 0; // локация первого элемента SearchMaxNumberName(out max, out loc); List <KabLine> lines = new List <KabLine>(); for (int i = 0; i < max + 1; i++) { string obozn_prov = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "textb_" + i).Text; string trassa_nach = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "tttt1_" + i).Text; string trassa_kon = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text2_" + i).Text; string truba_obozn = ""; var textBox_1 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text8_" + i);//текстбокс тип трубы if (textBox_1.Visible == true) { truba_obozn = textBox_1.Text; } else { var ob = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "combo_" + i); if (ob.SelectedItem == null) { truba_obozn = ""; } else { truba_obozn = ob.SelectedItem.ToString(); } } string truba_diam = ""; var textBox_2 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text9_" + i);//текстбокс диаметр трубы if (textBox_2.Visible == true) { truba_diam = textBox_2.Text; } else { var diam = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "comb1_" + i); if (diam.SelectedItem == null) { truba_diam = ""; } else { truba_diam = diam.SelectedItem.ToString(); } } string truba_dlin = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text3_" + i).Text; string mett_tip = ""; //тип металлорукава var textBox_3 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text10_" + i); //текстбокс тип металлорукава if (textBox_3.Visible == true) { mett_tip = textBox_3.Text; } else { var mett = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "comb2_" + i); if (mett.SelectedItem == null) { mett_tip = ""; } else { mett_tip = mett.SelectedItem.ToString(); } } string mett_dlin = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text4_" + i).Text; string protyazh_yash = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text5_" + i).Text; string kab_proekt = ""; var textBox_4 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text11_" + i);// кабель проект if (textBox_4.Visible == true) { kab_proekt = textBox_4.Text; } else { var kab = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "comb3_" + i); if (kab.SelectedItem == null) { kab_proekt = ""; } else { kab_proekt = kab.SelectedItem.ToString(); } } string zhil_proekt = ""; var textBox_5 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text12_" + i);//текстбокс сечение проект if (textBox_5.Visible == true) { zhil_proekt = textBox_5.Text; } else { var zhil = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "comb4_" + i); if (zhil.SelectedItem == null) { zhil_proekt = ""; } else { zhil_proekt = zhil.SelectedItem.ToString();// кабель сечение проект } } string kab_dlin = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text6_" + i).Text; string provod_fact = ""; var textBox_6 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text13_" + i);//текстбокс кабель тип факт if (textBox_6.Visible == true) { provod_fact = textBox_6.Text; } else { var prov = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "comb5_" + i); if (prov.SelectedItem == null) { provod_fact = ""; } else { provod_fact = prov.SelectedItem.ToString();// кабель тип факт } } string provod_sech_fact = ""; var textBox_7 = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text14_" + i);//текстбокс кабель сечен факт if (textBox_7.Visible == true) { provod_sech_fact = textBox_7.Text; } else { var prov = Controls.OfType <ComboBox>().FirstOrDefault(x => x.Name == "comb6_" + i); if (prov.SelectedItem == null) { provod_sech_fact = ""; } else { provod_sech_fact = prov.SelectedItem.ToString();// кабель сечен факт } } string fact_dlin = Controls.OfType <TextBox>().FirstOrDefault(x => x.Name == "text7_" + i).Text;//текстбокс длина кабель факт KabLine line = new KabLine() { Obozn_provoda = obozn_prov, Trassa_nachalo = trassa_nach, Trassa_konec = trassa_kon, Truba_oboznach = truba_obozn, Truba_diametr = truba_diam, Truba_dlina = truba_dlin, Metalloruk_tip = mett_tip, Metalloruk_dlina = mett_dlin, Protyazh_yashik = protyazh_yash, Provod_Proekt_marka = kab_proekt, Provod_Proekt_kol_zhil = zhil_proekt, Provod_Proekt_dlina = kab_dlin, Provod_Fakt_marka = provod_fact, Provod_Fakt_kol_zhil = provod_sech_fact, Provod_Fakt_dlina = fact_dlin }; lines.Add(line); } ExelWork work = new ExelWork(); work.Kab_Trub(lines); }