private void DisplayRows(long?WTP_ID) { if (WTP_ID != null) { WtpPresenter _presenter = new WtpPresenter(); //_presenter.Load(21355); _presenter.Load((long)WTP_ID); var plan = _presenter.Plan; formEducLabel.Text = "Программа: " + plan.DataRow.FORMEDUC_NAME; modeEducLabel.Text = "Форма обучения: " + plan.DataRow.MODEEDUC_NAME; specialityNameLabel.Text = "Специальность: " + plan.DataRow.SPECIALITY_NAME; specialityNumbLabel.Text = "Код направления: " + plan.DataRow.SPECIALITY_NUMB; studYearLabel.Text = "Год обучения: " + plan.DataRow.STUDYEAR_NAME; facultyNameLabel.Text = "Факультет :" + plan.DataRow.FACULTY_FULLNAME; qualificationLabel.Text = "Квалификация: " + plan.DataRow.QUALIFICATION_NAME; formEducLabel.Visible = true; modeEducLabel.Visible = true; specialityNameLabel.Visible = true; specialityNumbLabel.Visible = true; studYearLabel.Visible = true; facultyNameLabel.Visible = true; qualificationLabel.Visible = true; addDiscipButton.Visible = true; MoveDownButton.Visible = true; MoveUpButton.Visible = true; tabPane1.Visible = true; List <WTPGridRow> list = new List <WTPGridRow>(); //BindingList<WTPGridRow> grid = new BindingList<WTPGridRow>(); foreach (WTPComponent parentComponent in plan.Components.Where(q => q.DataRow.WTPCOMPONENT_PARENTID == null).Where(q => q.DataRow.STUDDISCIPCICLE_ID != null)) { if (parentComponent.GetAllChildComponents().Count() == 0) { foreach (WTPRow wtprow in plan.Rows.Where(r => r.DataRow.WTPCOMPONENT_ID == parentComponent.DataRow.WTPCOMPONENT_ID).OrderBy(r => r.DataRow.WTPROW_SORTINDEX)) { foreach (WTPSemester semestr in wtprow.Semesters) { if (semestr.DataRow.WTPSEMESTER_NUM != null) { var WTPROWValues = wtprow.Values.Where(r => r.DataRow.WTPROWVALUES_SEMNUM == semestr.DataRow.WTPSEMESTER_NUM).ToList(); list.Add(new WTPGridRow(parentComponent, wtprow, WTPROWValues, semestr.DataRow.WTPSEMESTER_NUM)); } } } } else { foreach (WTPComponent childComponent in plan.Components.Where(q => q.DataRow.WTPCOMPONENT_PARENTID == parentComponent.DataRow.WTPCOMPONENT_ID)) { //foreach (WTPComponent module in plan.Components.Where(q => q.DataRow.WTPCOMPONENT_PARENTID == childComponent.DataRow.WTPCOMPONENT_ID))// plan.Components.Where(q => q.DataRow.WTPCOMPONENT_PARENTID == childComponent.DataRow.WTPCOMPONENT_ID)) //{ // foreach (WTPRow wtprow in plan.Rows.Where(r => r.DataRow.WTPCOMPONENT_ID == module.DataRow.WTPCOMPONENT_ID)) // { // foreach (WTPSemester semestr in wtprow.Semesters) // { // var WTPROWValues = wtprow.Values.Where(r => r.DataRow.WTPROWVALUES_SEMNUM == semestr.DataRow.WTPSEMESTER_NUM).ToList(); // list.Add(new WTPGridRow(parentComponent, childComponent, module, wtprow, WTPROWValues, semestr.DataRow.WTPSEMESTER_NUM)); // } // } //} foreach (WTPRow wtprow in plan.Rows.Where(r => r.DataRow.WTPCOMPONENT_ID == childComponent.DataRow.WTPCOMPONENT_ID).OrderBy(r => r.DataRow.WTPROW_SORTINDEX)) { foreach (WTPSemester semestr in wtprow.Semesters) { if (semestr.DataRow.WTPSEMESTER_NUM != null) { var WTPROWValues = wtprow.Values.Where(r => r.DataRow.WTPROWVALUES_SEMNUM == semestr.DataRow.WTPSEMESTER_NUM).ToList(); list.Add(new WTPGridRow(parentComponent, childComponent, wtprow, WTPROWValues, semestr.DataRow.WTPSEMESTER_NUM)); } } } } } } var grid = new BindingList <WTPGridRow>(list.OrderBy(r => r.SortIndex).ThenBy(r => r.SemNum).ToList()); gridControl1.DataSource = null; gridControl1.DataSource = grid; gridControl1.Refresh(); gridView1.ExpandAllGroups(); } }
private void importButton_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() != DialogResult.OK) { return; } var SpecialFaculty = 1231; //var Speciality = 50; var StudYear = 22; var FormEduc = 1; var ModeEduc = 1; var StudYearIDVersion = 22; //var WTP = DBManager.GetDataSourse<IWTP>().Rows.Cast<IWTP>(). // Where(r => r.SPECIALFACULTY_ID == SpecialFaculty). // Where(r => r.STUDYEAR_ID == StudYear). // Where(r => r.FORMEDUC_ID == FormEduc). // Where(r => r.MODEEDUC_ID == ModeEduc). // Where(r => r.STUDYEAR_ID_VERSION == StudYearIDVersion); WtpPresenter planPresenter = new WtpPresenter(); //if (WTP.Count() == 0) { } //{ //WTP_ID = planPresenter.WTPDuplicationCheck(SpecialFaculty, StudYear, FormEduc, ModeEduc, StudYearIDVersion); if (WTP_ID == null) { Wtp plan = planPresenter.CreateWtp(); plan.DataRow.SPECIALFACULTY_ID = 1231; //plan.DataRow.SPECIALITY_ID = 50; plan.DataRow.STUDYEAR_ID = 22; plan.DataRow.FORMEDUC_ID = 1; plan.DataRow.MODEEDUC_ID = 1; plan.DataRow.STUDYEAR_ID_VERSION = 22; planPresenter.Save(); WTP_ID = (long)plan.DataRow.WTP_ID; } else { planPresenter.Load((long)WTP_ID); var plan = planPresenter.Plan; } ImportPlanExample importer = new ImportPlanExample(); XDocument xdoc = XDocument.Load(ofd.FileName); //planPresenter.Load(1297); if (importer.CheckImportFile(planPresenter.Plan, xdoc, out string ErrorMessage)) { if (MessageBox.Show(ErrorMessage + " Продолжить?", "Импорт УП", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { return; } } if (!importer.Import(planPresenter, xdoc, out string ErrorMessage2)) { MessageBox.Show(ErrorMessage); } //WTPCoreExample.ImportForm importForm = new WTPCoreExample.ImportForm(); //importForm.ShowDialog(); ////MessageBox.Show(importForm.WTPID().ToString()); //WTP_ID = importForm.WTPID(); DisplayRows(WTP_ID); }