private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count > 0) { ListViewItem item = this.listView1.SelectedItems[0]; if (item.Tag != null && item.Tag is Fire_ImportantUnits) { this.currentFireIUnits = item.Tag as Fire_ImportantUnits; this.navigationControl1.BtnEdit.Enabled = true; this.navigationControl1.BtnDelete.Enabled = true; } else { this.currentFireIUnits = null; this.navigationControl1.BtnDelete.Enabled = false; this.navigationControl1.BtnEdit.Enabled = false; } } else { this.currentFireIUnits = null; this.navigationControl1.BtnDelete.Enabled = false; this.navigationControl1.BtnEdit.Enabled = false; } }
public FormFireImportantUnits(OperationType type, Fire_ImportantUnits fireImportantUnits = null) { InitializeComponent(); this.m_OperationType = type; this.m_FireImportantUnits = fireImportantUnits; this.m_FireIUnitsController = new FireImportantUnitsController(); this.m_FireIUnitsController.AddEvent += M_ServiceController_AddEvent; this.m_FireIUnitsController.EditEvent += M_ServiceController_EditEvent; this.m_FireIUnitsController.AddMediaEvent += M_FireIUnitsController_AddMediaEvent; this.m_FireIUnitsController.DeleteMediaEvent += M_FireIUnitsController_DeleteMediaEvent; this.mediaControl1.AddEvent += MediaControl1_AddEvent; this.mediaControl1.DeleteEvent += MediaControl1_DeleteEvent; }
private void btnOK_Click(object sender, EventArgs e) { if (!IsCondition()) { return; } IDictionary <string, string> dict = new Dictionary <string, string>(); try { this.tabControl1.SelectedTab = this.tabPage_baseInfo; dict = m_FireImportantUnits.ObjectDescriptionToDict(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (!SmartForm.Validator(this.tabPage_baseInfo.Controls, dict)) { return; } if (m_OperationType == OperationType.Add) { this.m_FireImportantUnits = new Fire_ImportantUnits(); } this.m_FireImportantUnits.longitude = this.coordinatesInputControl1.Longitude; this.m_FireImportantUnits.latitude = this.coordinatesInputControl1.Latitude; this.m_FireImportantUnits.pac = this.pacControl11.LocalPac; this.m_FireImportantUnits.SHAPE = Converters.LngLatToWKT(this.m_FireImportantUnits.longitude, this.m_FireImportantUnits.latitude); //自动从窗体控件上取值 m_FireImportantUnits = SmartForm.GetEntity <Fire_ImportantUnits>(this.tabPage_baseInfo.Controls, this.m_FireImportantUnits); this.m_FireImportantUnits.mediaByteDict = this.mediaControl1.MediaByteDict; if (m_OperationType == OperationType.Add) { this.m_FireIUnitsController.Add(this.m_FireImportantUnits); } else if (m_OperationType == OperationType.Edit) { this.m_FireIUnitsController.Edit(this.m_FireImportantUnits); } }
public void EditTest() { FireImportantUnitsController fireImportantUnitsController; //用例测试1 fireImportantUnitsController = new FireImportantUnitsController(); fireImportantUnitsController.Edit((Fire_ImportantUnits)null); Assert.IsNotNull((object)fireImportantUnitsController); Assert.AreEqual <string> ("127.0.0.1", ((BaseService)fireImportantUnitsController).Server); Assert.AreEqual <int>(8080, ((BaseService)fireImportantUnitsController).Port); // 用例测试2 fireImportantUnitsController = new FireImportantUnitsController(); Fire_ImportantUnits s0 = new Fire_ImportantUnits(); s0.OBJECTID = 0; s0.SHAPE = (string)null; s0.name = (string)null; s0.address = (string)null; s0.manager = (string)null; s0.phone = (string)null; s0.num_people = 0; s0.build_area = 0; s0.type = (string)null; s0.status = (string)null; s0.longitude = 0; s0.latitude = 0; s0.picture1 = (string)null; s0.picture2 = (string)null; s0.video = (string)null; s0.note = (string)null; s0.id = (string)null; s0.management_unit = (string)null; s0.pac = (string)null; s0.city_name = (string)null; s0.county_name = (string)null; s0.mediaByteDict = (Dictionary <string, object>)null; s0.mediaFiles = (List <MediaFile>)null; fireImportantUnitsController.Edit(s0); Assert.IsNotNull((object)fireImportantUnitsController); Assert.AreEqual <string> ("127.0.0.1", ((BaseService)fireImportantUnitsController).Server); Assert.AreEqual <int>(8080, ((BaseService)fireImportantUnitsController).Port); }
private void FillData(List <Fire_ImportantUnits> fireIUnitsList) { this.pagerControl1.Bind(); this.pagerControl1.bindingSource.DataSource = fireIUnitsList; this.pagerControl1.bindingNavigator.BindingSource = this.pagerControl1.bindingSource; this.listView1.Items.Clear(); if (fireIUnitsList != null) { for (int i = 0; i < fireIUnitsList.Count; i++) { Fire_ImportantUnits fireImportantUnits = fireIUnitsList[i]; ListViewItem item = new ListViewItem(); item.SubItems.Add(fireImportantUnits.name); AreaCodeInfo county = null; try { if (this.navigationControl1.AreaList != null) { county = this.navigationControl1.AreaList.Where(a => a.code == fireImportantUnits.pac).First(); } } catch { } item.SubItems.Add((county == null) ? "" : county.name); item.SubItems.Add(fireImportantUnits.manager); item.SubItems.Add(fireImportantUnits.longitude.ToString()); item.SubItems.Add(fireImportantUnits.latitude.ToString()); item.Tag = fireImportantUnits; this.listView1.Items.Add(item); } } }