//загрузка связанных источников для списка выключателей void CbrDataSourceLoad() { //для карточки проекта txtProjectNumber.Text = ProjectServices.GetProjectNumber(_project); //общее bs_EquipNote.DataSource = EquipServices.GetAllProjectNote(); ////аналоги bs_CbrAn.DataSource = EquipServices.GetProjectCbr(_project, true); bs_AnalogEquip.DataSource = EquipServices.GetAllEquipCbr(_project, true); bs_cbrCCbrAn.DataSource = EquipServices.GetAllCbCur(); bs_disCCbrAn.DataSource = EquipServices.GetAllDisCur(); bs_disMCbrAn.DataSource = EquipServices.GetAllDisModel(); bs_icuLCbrAn.DataSource = EquipServices.GetAllIcuLiteral(); bs_seriaCbrAn.DataSource = EquipServices.GetAllSeria(); //основное bs_CbrPrj.DataSource = EquipServices.GetProjectCbr(_project, false); bs_CbrEquip.DataSource = EquipServices.GetAllEquipCbr(_project, false); bs_cbrCCbrPrj.DataSource = EquipServices.GetAllCbCur(); bs_disCCbrPrj.DataSource = EquipServices.GetAllDisCur(); bs_disMCbrPrj.DataSource = EquipServices.GetAllDisModel(); bs_icuLCbrPrj.DataSource = EquipServices.GetAllIcuLiteral(); bs_seriaCbrPrj.DataSource = EquipServices.GetAllSeria(); //для истории проекта bs_ProjectLog.DataSource = ProjectServices.GetProjectHistory(_project); bs_ProjectNumber.DataSource = ProjectServices.GetAllProjectNum(); bs_ProjectStage.DataSource = ProjectServices.GetAllProjectStage(); bs_ProjectState.DataSource = ProjectServices.GetAllProjectState(); bs_User.DataSource = AuthServices.GetAllUser(); }
//нажатие клавиш в области dataGridViewProject private void dataGridView_KeyDown(object sender, KeyEventArgs e) { DataGridView dgv = sender as DataGridView; if (dgv.Name.Contains("Project")) { if (e.KeyCode == Keys.Delete) //удалить { RemoveFromProject(bs_CbrEquip, bs_AnalogEquip, _project); bs_CbrPrj.DataSource = EquipServices.GetProjectCbr(_project, false); bs_CbrAn.DataSource = EquipServices.GetProjectCbr(_project, true); tsAnalogCount.Text = "0"; } if (e.KeyCode == Keys.F2) { itemEdit_Project.PerformClick(); } } else if (dgv.Name.Contains("Analog")) { if (e.KeyCode == Keys.Delete) //удалить { RemoveFromProject(null, bs_AnalogEquip, _project); bs_CbrAn.DataSource = EquipServices.GetProjectCbr(_project, true); } } }
//тип расцепителя private void pbxClearDisType_Click(object sender, EventArgs e) { dgvcCmbDisTyp.DefaultCellStyle.BackColor = System.Drawing.Color.White; if (disCurrent == null) { bs_disTCbr.DataSource = EquipServices.GetAllDisType(); } disType = null; cboCbrDisType.ResetText(); if (disModel == null) { if (manufacturer == null) { bs_disMCbr.DataSource = EquipServices.GetAllDisModel(); cboCbrDisModel.ResetText(); } else { bs_disMCbr.DataSource = EquipServices.GetAllDisModel(manufacturer.Id); cboCbrDisModel.ResetText(); } } SearchCbr(null); }
//Заменить в проекте private void itemReplace_Click(object sender, EventArgs e) { string connectionNumber; using (frmInputBox frm = new frmInputBox(_project, 2 /*замена*/)) { if (frm.ShowDialog() == DialogResult.OK) { connectionNumber = frm.GetTxtValue; ProjectEquipment pe = EquipServices.ReplaceProjectCbr(_project, connectionNumber, bs_Cbr.Current as CurrentBreaker); bs_CbrPrj.DataSource = EquipServices.GetProjectCbr(_project, false); if (EquipServices.GetCbrAnalog(pe, bs_Cbr.Current as CurrentBreaker)) { AnalogDataSourceLoad(DefaultForeColor, bs_CbrAn.Count.ToString()); } else { AnalogDataSourceLoad(Color.Red, "не найдено"); } } else { return; } } }
/* [ Изменить состав оборудования ] */ private void btnConfig_Click(object sender, EventArgs e) { Button bt = sender as Button; if (tabControl.Controls.Count > 0) { if (bt.Text.Contains(btnText[0])) { using (frmEquipment frm = new frmEquipment(_project, tabControl.SelectedTab.Name, 1 /* редактирование существующего списка оборудования */)) { MessageBox.Show("Изменения в базе данных при редактировании списка оборудования " + "фиксируются без подтверждения.\r\n\r\nБудьте внимательны!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); if (frm.ShowDialog() == DialogResult.OK) { bs_CbrPrj.DataSource = EquipServices.GetProjectCbr(_project, false); bs_CbrEquip.DataSource = EquipServices.GetAllEquipCbr(_project, false); bs_CbrAn.DataSource = EquipServices.GetProjectCbr(_project, true); bs_AnalogEquip.DataSource = EquipServices.GetAllEquipCbr(_project, true); bs_EquipNote.DataSource = EquipServices.GetAllProjectNote(); UpdateTabPageInfo(); } } } } else if (bt.Text.Contains(btnText[2])) { this.Hide(); this.Close(); using (frmEquipment frm = new frmEquipment(_project, string.Empty, 0 /*создание нового списка*/)) { frm.ShowDialog(); } } }
private void frmInputBox_FormClosing(object sender, FormClosingEventArgs e) { if (this.DialogResult == DialogResult.OK) { if (!String.IsNullOrEmpty(txtValue.Text)) { if (_mode == 1 /*добавление или редактирование*/) { if (EquipServices.CheckDuplicate(_project, txtValue.Text)) { MessageBox.Show("Присоединение " + txtValue.Text + " уже существует в списке\r\n Повторение не допускается.", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtValue.Focus(); txtValue.SelectAll(); e.Cancel = true; } } } else { MessageBox.Show("Необходимо заполнить поле ввода!"); txtValue.Focus(); e.Cancel = true; } } }
//поиск выключателей в базе private void SearchCbr(DataGridViewColumn dgvCol) { object[] filters = new object[6]; //формирование фильтра if (manufacturer != null) { filters[0] = manufacturer.Id; } if (disCurrent != null) { filters[1] = disCurrent.Id; } if (cbCurrent != null) { filters[2] = cbCurrent.Id; } if (icuValue != null) { filters[3] = icuValue.Id; } if (disType != null) { filters[4] = disType.Id; } if (disModel != null) { filters[5] = disModel.Id; } bs_Cbr.DataSource = EquipServices.GetCbrByParams(filters); //найти с указанным фильтром if (dgvCol != null) { dgvCol.DefaultCellStyle.BackColor = Color.FromArgb(253, 255, 216 /*светло-жёлтый*/); //выделить цветом } }
//тепловое реле private void pbxClearMtPrRelay_Click(object sender, EventArgs e) { dgvcCmbRelayMtPr.DefaultCellStyle.BackColor = Color.White; bs_relayMtPr.DataSource = EquipServices.GetHasRealy(); hasRelayMtPr = null; cboMtPrRelay.ResetText(); SearchContByParams(null); }
//тип координации private void pbxClearMtPrType_Click(object sender, EventArgs e) { dgvcCmbRelayMtPr.DefaultCellStyle.BackColor = Color.White; bs_typeMtPr.DataSource = EquipServices.GetCoordType(); coordTypeMtPr = null; cboMtPrType.ResetText(); SearchContByParams(null); }
//мощность двигателя private void pbxClearMtPrPower_Click(object sender, EventArgs e) { dgvcCmbPowMtPr.DefaultCellStyle.BackColor = Color.White; bs_mtPowMtPr.DataSource = EquipServices.GetAllMotorPow(); motorPowerMtPr = null; cboMtPrPower.ResetText(); SearchContByParams(null); }
//тип управления private void pbxClearContCoil_Click(object sender, EventArgs e) { dgvcCmbCoilCont.DefaultCellStyle.BackColor = Color.White; bs_coilCont.DataSource = EquipServices.GetCoilType(); coilCont = null; cboCoilCont.ResetText(); SearchContByParams(null); }
//загрузка источников для Contactor private void ContDataSourceLoad() { bs_manfCont.DataSource = EquipServices.GetAllManuf(); bs_seriaCont.DataSource = EquipServices.GetAllSeria(); bs_contCurCont.DataSource = EquipServices.GetAllContCur(); bs_coilCont.DataSource = EquipServices.GetCoilType(); bs_coordTypeCont.DataSource = EquipServices.GetCoordType(); ComboResetText(gbxFilterCont); }
//ток выключателя private void cboCbrCbCur_SelectionChangeCommitted(object sender, EventArgs e) { cbCurrent = cboCbrCbCur.SelectedItem as CbCurrent; if (cbCurrent != null) { SearchCbr(dgvcCmbCbCur); bs_icuVCbr.DataSource = EquipServices.GetAllIcu(cbCurrent.Id); cboCbrIcu.ResetText(); } }
//отключающая способность private void pbxClearIcu_Click(object sender, EventArgs e) { dgvcCmbIcuVal.DefaultCellStyle.BackColor = System.Drawing.Color.White; if (cbCurrent == null) { bs_icuVCbr.DataSource = EquipServices.GetAllIcu(); } icuValue = null; cboCbrIcu.ResetText(); SearchCbr(null); }
//удаление оборудования из проекта public static void RemoveFromProject(BindingSource bsBase, BindingSource bsAnalog, Project probject) { if (bsBase != null) { bsAnalog.DataSource = EquipServices.DisattachAnalog(bsBase.Current as ProjectEquipment, probject, false); //связанные аналоги bsBase.DataSource = EquipServices.DisattachBase(bsBase.Current as ProjectEquipment, probject); //базовые } else { bsAnalog.DataSource = EquipServices.DisattachAnalog(bsAnalog.Current as ProjectEquipment, probject, true);; //только аналоги } }
//Редактировать (наименование присоединения) private void itemEdit_Click(object sender, EventArgs e) { using (frmInputBox frm = new frmInputBox(_project, 1 /*добавление или редактирование*/)) { if (frm.ShowDialog() == DialogResult.OK) { bs_EquipNote.DataSource = EquipServices.UpdateTable(bs_CbrEquip.Current as ProjectEquipment, frm.GetTxtValue); bs_CbrEquip.DataSource = EquipServices.GetAllEquipCbr(_project, false); bs_AnalogEquip.DataSource = EquipServices.GetAllEquipCbr(_project, true); } } }
//ток расцепителя private void cboCbrDisCur_SelectionChangeCommitted(object sender, EventArgs e) { disCurrent = cboCbrDisCur.SelectedItem as DisCurrent; if (disCurrent != null) { SearchCbr(dgvcCmbDisCur); bs_cbrCCbr.DataSource = EquipServices.GetAllCbCur(disCurrent.Id); bs_disTCbr.DataSource = EquipServices.GetAllDisType(disCurrent.Id); cboCbrCbCur.ResetText(); cboCbrDisType.ResetText(); } }
//загрузка источников для MotorProtect private void MtPrDataSourceLoad() { bs_mtPowMtPr.DataSource = EquipServices.GetAllMotorPow(); bs_mtCurMtPr.DataSource = EquipServices.GetAllMotorCur(); bs_contCurMtPr.DataSource = EquipServices.GetAllContCur(); bs_relayMtPr.DataSource = EquipServices.GetHasRealy(); bs_coilMtPr.DataSource = EquipServices.GetCoilType(); bs_typeMtPr.DataSource = EquipServices.GetCoordType(); bs_manfMtPr.DataSource = EquipServices.GetAllManuf(); bs_seriaMtPr.DataSource = EquipServices.GetAllSeria(); bs_CbrMtPr.DataSource = EquipServices.GetAllCbr(); ComboResetText(gbxFilterMtPr); }
//тип расцепителя private void cboCbrDisType_SelectionChangeCommitted(object sender, EventArgs e) { disType = cboCbrDisType.SelectedItem as DisType; if (disType != null) { SearchCbr(dgvcCmbDisTyp); } if (manufacturer != null) { bs_disMCbr.DataSource = EquipServices.GetAllDisModel(manufacturer.Id, disType.Id); cboCbrDisModel.ResetText(); } }
//поиск контакторов в базе private void SearchContByParams(DataGridViewColumn dgvCol) { TabPage activeTab = tabControl.SelectedTab; object[] filters = new object[5]; //формирование фильтра if (activeTab.Name.Contains("Motor")) { if (motorPowerMtPr != null) { filters[0] = motorPowerMtPr.Id; } if (hasRelayMtPr != null) { filters[1] = hasRelayMtPr.Id; } if (coordTypeMtPr != null) { filters[2] = coordTypeMtPr.Id; } if (coilMtPr != null) { filters[3] = coilMtPr.Id; } bs_MtPr.DataSource = EquipServices.GetContByParams(filters); } else if (activeTab.Name.Contains("Contactor")) { if (coordTypeCont != null) { filters[2] = coordTypeCont.Id; } if (coilCont != null) { filters[3] = coilCont.Id; } if (contCurCont != null) { filters[4] = contCurCont.Id; } bs_Cont.DataSource = EquipServices.GetContByParams(filters); } if (dgvCol != null) { dgvCol.DefaultCellStyle.BackColor = Color.FromArgb(253, 255, 216 /*светло-жёлтый*/); //выделить цветом } }
//загрузка формы private void frmConfigurator_Load(object sender, EventArgs e) { using (frmInputBox frm = new frmInputBox(1 /*введите номер проекта*/)) { if (frm.ShowDialog() == DialogResult.Yes) { Project pr = ProjectServices.GetByNumber(frm.GetTxtValue); if (pr != null) { _project = pr; } } } rbtnGeneral.Checked = true; _blockNameMask = txtResult.Text; bs_ProjectCbr.DataSource = ConfigServices.GetProjectCbr(_project, false); bs_cbrCCbrPrj.DataSource = EquipServices.GetAllCbCur(); bs_disCCbrPrj.DataSource = EquipServices.GetAllDisCur(); bs_disMCbrPrj.DataSource = EquipServices.GetAllDisModel(); bs_icuLCbrPrj.DataSource = EquipServices.GetAllIcuLiteral(); bs_seriaCbrPrj.DataSource = EquipServices.GetAllSeria(); bs_Schema.DataSource = ConfigServices.GetAllSchema(); bs_BaseHeight.DataSource = ConfigServices.GetBaseSizes("H"); bs_BaseWidth.DataSource = ConfigServices.GetBaseSizes("B"); foreach (Control ctr in this.Controls) { if (ctr.GetType() == typeof(ComboBox)) { ctr.ResetText(); } } if (_project.IdNumber != 0) { tsProjectNumber.Text = ProjectServices.GetProjectNumber(_project); } else { tsProjectNumber.Text = "тестовый проект"; } }
//добавление выключателя в проект private void InsertCbr(string connectionNumber) { ProjectEquipment pe = EquipServices.AttachCbr(_project, bs_Cbr.Current as CurrentBreaker, connectionNumber); bs_CbrPrj.DataSource = EquipServices.GetProjectCbr(_project, false); bs_CbrEquip.DataSource = EquipServices.GetAllEquipCbr(_project, false); bs_EquipNote.DataSource = EquipServices.GetAllProjectNote(); if (EquipServices.GetCbrAnalog(pe, bs_Cbr.Current as CurrentBreaker)) { AnalogDataSourceLoad(DefaultForeColor, string.Empty); } else { AnalogDataSourceLoad(Color.Red, "не найдено"); } }
//загрузка источников для Current Breaker private void CbrDataSourceLoad() { //источники для таблицы поиска bs_manfCbr.DataSource = EquipServices.GetAllManuf(); bs_disCCbr.DataSource = EquipServices.GetAllDisCur(); bs_cbrCCbr.DataSource = EquipServices.GetAllCbCur(); bs_icuVCbr.DataSource = EquipServices.GetAllIcu(); bs_icuLCbr.DataSource = EquipServices.GetAllIcuLiteral(); bs_disTCbr.DataSource = EquipServices.GetAllDisType(); bs_disMCbr.DataSource = EquipServices.GetAllDisModel(); bs_seriaCbr.DataSource = EquipServices.GetAllSeria(); bs_poleCbr.DataSource = EquipServices.GetAllPoleNumber(); bs_voltCbr.DataSource = EquipServices.GetAllVoltage(); //источники для таблицы выбранных bs_manfCbrPrj.DataSource = EquipServices.GetAllManuf(); bs_disCCbrPrj.DataSource = EquipServices.GetAllDisCur(); bs_cbrCCbrPrj.DataSource = EquipServices.GetAllCbCur(); bs_icuVCbrPrj.DataSource = EquipServices.GetAllIcu(); bs_icuLCbrPrj.DataSource = EquipServices.GetAllIcuLiteral(); bs_disTCbrPrj.DataSource = EquipServices.GetAllDisType(); bs_disMCbrPrj.DataSource = EquipServices.GetAllDisModel(); bs_seriaCbrPrj.DataSource = EquipServices.GetAllSeria(); bs_poleCbrPrj.DataSource = EquipServices.GetAllPoleNumber(); bs_voltCbrPrj.DataSource = EquipServices.GetAllVoltage(); //источники для аналогов bs_manfCbrAn.DataSource = EquipServices.GetAllManuf(); bs_disCCbrAn.DataSource = EquipServices.GetAllDisCur(); bs_cbrCCbrAn.DataSource = EquipServices.GetAllCbCur(); bs_icuVCbrAn.DataSource = EquipServices.GetAllIcu(); bs_icuLCbrAn.DataSource = EquipServices.GetAllIcuLiteral(); bs_disTCbrAn.DataSource = EquipServices.GetAllDisType(); bs_disMCbrAn.DataSource = EquipServices.GetAllDisModel(); bs_seriaCbrAn.DataSource = EquipServices.GetAllSeria(); bs_poleCbrAn.DataSource = EquipServices.GetAllPoleNumber(); bs_voltCbrAn.DataSource = EquipServices.GetAllVoltage(); //номер проекта bs_ProjectNum.DataSource = ProjectServices.GetAllProjectNum(); //обозначения выключателей bs_EquipNote.DataSource = EquipServices.GetAllProjectNote(); ComboResetText(gbxFilterCbr); }
//Вывод списка аналогов void AnalogDataSourceLoad(Color color, string count) { bs_AnalogEquip.DataSource = EquipServices.GetAllEquipCbr(_project, true); bs_CbrAn.DataSource = EquipServices.GetProjectCbr(_project, true); btnAnalog.Enabled = true; tsAnalogCount.ForeColor = color; if (String.IsNullOrEmpty(count)) { bs_CbrAn.Count.ToString(); } else { tsAnalogCount.Text = count; } }
//производитель private void pbxClearManuf_Click(object sender, EventArgs e) { dgvcCmbManf.DefaultCellStyle.BackColor = Color.White; bs_manfCbr.DataSource = EquipServices.GetAllManuf(); manufacturer = null; disModel = null; bs_disMCbr.DataSource = EquipServices.GetAllDisModel(); cboCbrDisModel.ResetText(); cboCbrDisModel.Enabled = false; cboCbrManufact.ResetText(); if (disCurrent == null) { bs_disCCbr.DataSource = EquipServices.GetAllDisCur(); cboCbrDisCur.ResetText(); } SearchCbr(null); }
//отрисовка формы в режиме редактирования состава оборудования private void LoadFormInEditMode() { //foreach (TabPage tbp in tabControl.TabPages) //{ // if (!tbp.Name.Equals(tabControl.SelectedTab.Name)) // tabControl.TabPages.Remove(tbp); //} bs_CbrPrj.DataSource = EquipServices.GetProjectCbr(_project, false); bs_CbrEquip.DataSource = EquipServices.GetAllEquipCbr(_project, false); bs_EquipNote.DataSource = EquipServices.GetAllProjectNote(); bs_AnalogEquip.DataSource = EquipServices.GetAllEquipCbr(_project, true); bs_CbrAn.DataSource = EquipServices.GetProjectCbr(_project, true); itemReplaceInProject.Visible = true; this.Text = "Редактирование состава обоорудования"; this.btnAnalog.Enabled = true; tsAnalogText.Text = "Кол-во аналогов: "; tsAnalogCount.Text = bs_AnalogEquip.Count.ToString(); }
//производитель private void cboCbrManufact_SelectionChangeCommitted(object sender, EventArgs e) { manufacturer = cboCbrManufact.SelectedItem as Manufacturer; if (manufacturer != null) { SearchCbr(dgvcCmbManf); bs_disCCbr.DataSource = EquipServices.GetAllDisCur(manufacturer.Id); cboCbrDisCur.ResetText(); cboCbrDisModel.Enabled = true; if (disType != null) { bs_disMCbr.DataSource = EquipServices.GetAllDisModel(manufacturer.Id, disType.Id); cboCbrDisModel.ResetText(); } else { bs_disMCbr.DataSource = EquipServices.GetAllDisModel(manufacturer.Id); cboCbrDisModel.ResetText(); } } }
//ток расцепителя private void pbxClearDisCur_Click(object sender, EventArgs e) { dgvcCmbDisCur.DefaultCellStyle.BackColor = System.Drawing.Color.White; if (manufacturer == null) { bs_disCCbr.DataSource = EquipServices.GetAllDisCur(); } disCurrent = null; cboCbrDisCur.ResetText(); if (cbCurrent == null) { bs_cbrCCbr.DataSource = EquipServices.GetAllCbCur(); cboCbrCbCur.ResetText(); } if (disType == null) { bs_disTCbr.DataSource = EquipServices.GetAllDisType(); cboCbrDisType.ResetText(); } SearchCbr(null); }
public frmProjectCard(Project project) { InitializeComponent(); if (!Directory.Exists(tempFolder)) { Directory.CreateDirectory(tempFolder); } if (project != null) { _project = project; bs_Project.DataSource = _project; } /* для тестового запуска */ else { _project = new Project(); _project.Id = 1; _project.IdEditor = 1; _project.IdImplementer = 6; _project.IdManager = 3; _project.IdNumber = 0; _project.IdStage = 2; _project.IdState = 1; _project.Version = 2; _project.Date = DateTime.Now; bs_Project.DataSource = _project; } /* проверка наличия сконфигурированных блоков */ if (EquipServices.HasAnyBlocks(_project)) { btnConfig.Text = btnText[1]; //Редактировать блоки } }
//закрытие формы private void frmEquipment_FormClosing(object sender, FormClosingEventArgs e) { this.DialogResult = DialogResult.OK; EquipServices.RemoveTemp(EquipServices.GetAllTempEquip()); }