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_Artificiallake) { this.currentArtificiallake = item.Tag as Fire_Artificiallake; this.navigationControl1.BtnEdit.Enabled = true; this.navigationControl1.BtnDelete.Enabled = true; } else { this.currentArtificiallake = null; this.navigationControl1.BtnDelete.Enabled = false; this.navigationControl1.BtnEdit.Enabled = false; } } else { this.currentArtificiallake = null; this.navigationControl1.BtnDelete.Enabled = false; this.navigationControl1.BtnEdit.Enabled = false; } }
public FormArtificiallake(OperationType type, Fire_Artificiallake artificiallake = null) { InitializeComponent(); this.m_OperationType = type; this.m_Artificiallake = artificiallake; this.m_ArtificiallakeController = new ArtificiallakeController(); this.m_ArtificiallakeController.AddEvent += m_ArtificiallakeController_AddEvent; this.m_ArtificiallakeController.EditEvent += m_ArtificiallakeController_EditEvent; }
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_Artificiallake.ObjectDescriptionToDict(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (!SmartForm.Validator(this.tabPage_baseInfo.Controls, dict)) { return; } if (m_OperationType == OperationType.Add) { this.m_Artificiallake = new Fire_Artificiallake(); } if (m_OperationType == OperationType.Add) { this.m_Artificiallake = new Fire_Artificiallake(); } this.m_Artificiallake.longitude = this.coordinatesInputControl1.Longitude; this.m_Artificiallake.latitude = this.coordinatesInputControl1.Latitude; this.m_Artificiallake.pac = this.pacControl11.LocalPac; this.m_Artificiallake.city_name = this.pacControl11.City; this.m_Artificiallake.county_name = this.pacControl11.County; this.m_Artificiallake.shape = Converters.LngLatToWKT(this.m_Artificiallake.longitude, this.m_Artificiallake.latitude); //自动从窗体控件上取值 m_Artificiallake = SmartForm.GetEntity <Fire_Artificiallake>(this.tabPage_baseInfo.Controls, this.m_Artificiallake); this.m_Artificiallake.note = this.tbx_note.Text.Trim(); this.m_Artificiallake.mediaByteDict = this.mediaControl1.MediaByteDict; if (m_OperationType == OperationType.Add) { this.m_ArtificiallakeController.Add(this.m_Artificiallake); } else if (m_OperationType == OperationType.Edit) { this.m_ArtificiallakeController.Edit(this.m_Artificiallake); } }
public void EditTest() { ArtificiallakeController artificiallakeController; artificiallakeController = new ArtificiallakeController(); //测试用例1 实例化 Fire_Artificiallake实体 Fire_Artificiallake s0 = new Fire_Artificiallake(); s0.objectid = 0; s0.name = (string)null; s0.address = (string)null; s0.manager = (string)null; s0.phone = (string)null; s0.longitude = 0; s0.latitude = 0; s0.volume = 0; s0.cre_time = (string)null; s0.cre_pers = (string)null; s0.mod_time = (string)null; s0.mod_pers = (string)null; s0.shape = (string)null; s0.status = 0; s0.storage_area = 0; s0.storage_capacity = 0; s0.maximum_depth = 0; s0.management_unit = 0; s0.traffic_condition = (string)null; s0.is_cableway = (string)null; s0.is_take_water = (string)null; s0.picture1 = (string)null; s0.picture2 = (string)null; s0.video = (string)null; s0.note = (string)null; s0.id = (string)null; s0.pac = (string)null; s0.mediaByteDict = (Dictionary <string, object>)null; s0.mediaFiles = (List <MediaFile>)null; artificiallakeController.Edit(s0); Assert.IsNotNull((object)artificiallakeController); Assert.AreEqual <string> ("127.0.0.1", ((BaseService)artificiallakeController).Server); Assert.AreEqual <int>(8080, ((BaseService)artificiallakeController).Port); //测试用例2 artificiallakeController.Edit(null); Assert.IsNotNull((object)artificiallakeController); Assert.AreEqual <string> ("127.0.0.1", ((BaseService)artificiallakeController).Server); Assert.AreEqual <int>(8080, ((BaseService)artificiallakeController).Port); }
private void FillData(List <Fire_Artificiallake> artificiallakeList) { this.pagerControl1.Bind(); this.pagerControl1.bindingSource.DataSource = artificiallakeList; this.pagerControl1.bindingNavigator.BindingSource = this.pagerControl1.bindingSource; this.listView1.Items.Clear(); if (artificiallakeList != null) { for (int i = 0; i < artificiallakeList.Count; i++) { Fire_Artificiallake artificiallake = artificiallakeList[i]; ListViewItem item = new ListViewItem(); item.SubItems.Add(artificiallake.name); AreaCodeInfo county = null; try { if (this.navigationControl1.AreaList != null) { county = this.navigationControl1.AreaList.Where(a => a.code == artificiallake.pac).First(); } } catch { } item.SubItems.Add((county == null) ? "" : county.name); item.SubItems.Add(artificiallake.manager); item.SubItems.Add(artificiallake.longitude.ToString()); item.SubItems.Add(artificiallake.latitude.ToString()); item.Tag = artificiallake; this.listView1.Items.Add(item); } } }