private void siBOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cBESave.Text.Trim())) { MessageBox.Show("错误信息:\n输出结果的值:是必需的"); } else { frmWaitDialog frmWait = new frmWaitDialog("正在生成...", "提示信息"); try { DataTable ExtandTable = new DataTable(); SampleSimulation Sim = new SampleSimulation(); int sampleSum = SamplingSum - sampleNum; //第一次抽样,剩余的样本总量 int sampleExtandNum = 0; //扩充的样本量 //每次抽样得到的样本 sampleTable = SampleZones[gridView1.FocusedRowHandle]; if (string.IsNullOrEmpty(tEExtend.Text.Trim()) && string.IsNullOrEmpty(tEScale.Text.Trim())) { ExtandTable = sampleTable; } else { if (cEExtend.Checked == true) { sampleExtandNum = Convert.ToInt32(tEExtend.Text); } else { sampleExtandNum = Convert.ToInt32(sampleSum * (Convert.ToDouble(tEScale.Text) / 100)); } if (0 > sampleExtandNum || sampleExtandNum > sampleSum) { MessageBox.Show("输入的扩充样本量超出范围,请重新输入!"); return; } else if (sampleExtandNum == 0) { ExtandTable = sampleTable; } else { ExtandTable = Sim.ExtendSample(sampleSumTable, sampleTable, sampleExtandNum, cBELayer.Text, cBEBasis.Text); } } if (ExtandTable != null) { if (Sim.CreateShpFile(cBFile.Text, ExtandTable, cBESave.Text)) { BLL.ProductMeta meta = new ProductMeta(cBESave.Text.TrimEnd(), "", "", "一级样本村", "抽样和面积推算结果"); meta.WriteShpMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(cBESave.Text.TrimEnd()); view.Create(); System.Windows.Forms.DialogResult dialogResult = XtraMessageBox.Show("保存样本成功,是否加载结果?", "提示信息", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { //添加结果到主地图视图 IFeatureClass pFC = EngineAPI.OpenFeatureClass(cBESave.Text); if (pFC != null) { IFeatureLayer pFLyr = new FeatureLayerClass(); pFLyr.FeatureClass = pFC; pFLyr.Name = (pFC as IDataset).Name; MapAPI.UniqueValueRender(pFLyr, "KC"); EnviVars.instance.MapControl.AddLayer(pFLyr); } } } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(frmSampleSimulation), ex); } finally { frmWait.Close(); this.Close(); } } }
private void siBOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cBESave.Text.Trim())) { MessageBox.Show("错误信息:\n输出结果的值:是必需的"); } else { WaitDialogForm frmWait = new WaitDialogForm("正在生成...", "提示信息"); try { DataTable ExtandTable = new DataTable(); SampleSimulation Sim = new SampleSimulation(); int sampleSum = SamplingSum - sampleNum; //第一次抽样,剩余的样本总量 int sampleExtandNum = 0; //扩充的样本量 if (string.IsNullOrEmpty(tEExtend.Text.Trim()) && string.IsNullOrEmpty(tEScale.Text.Trim())) { ExtandTable = sampleTable; } else { if (cEExtend.Checked == true) { sampleExtandNum = Convert.ToInt32(tEExtend.Text); } else { sampleExtandNum = Convert.ToInt32(sampleSum * (Convert.ToDouble(tEScale.Text) / 100)); } if (0 > sampleExtandNum || sampleExtandNum > sampleSum) { MessageBox.Show("输入的扩充样本量超出范围,请重新输入!"); return; } else if (sampleExtandNum == 0) { ExtandTable = sampleTable; } else { ExtandTable = Sim.ExtendSample(sampleSumTable, sampleTable, sampleExtandNum, cBELayer.Text, cBEBasis.Text); } } if (ExtandTable != null) { if (Sim.CreateShpFile(cBFile.Text, ExtandTable, cBESave.Text)) { System.Windows.Forms.DialogResult dialogResult = XtraMessageBox.Show("保存样本成功,是否加载结果?", "提示信息", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { //添加结果到主地图视图 //MapAPI.AddShpFileToMap(cBESave.Text); MapAPI.AddShpFileToMap(cBESave.Text); } } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(frmSampleSimulation), ex); } finally { frmWait.Close(); this.Close(); } } }