private void PathSegmentChanging(PathSegmentChangeArgs arg) { if (this.PathSegmentChanged != null) { this.PathSegmentChanged(arg); } }
private void btnClose_Click(object sender, EventArgs e) { PathSegmentChangeArgs arg = new PathSegmentChangeArgs { IsClose = true }; this.PathSegmentChanging(arg); }
private void btnClear_Click(object sender, EventArgs e) { try { foreach (DataGridViewRow row in (IEnumerable)this.dgvPathSegment.Rows) { row.Cells["HoldTime"].Value = DBNull.Value; row.Cells["DriEnough"].Value = DBNull.Value; row.Cells["TopSpeed"].Value = DBNull.Value; row.Cells["DriNoEnough"].Value = DBNull.Value; row.Cells["路宽"].Value = DBNull.Value; row.Cells["路段属性"].Value = DBNull.Value; } PathSegmentChangeArgs arg = new PathSegmentChangeArgs { IsClose = false, IsSet = false }; this.PathSegmentChanging(arg); } catch { } }
private void btnOK_Click(object sender, EventArgs e) { try { if (this._data.Rows.Count == 0) { MessageBox.Show("该路线没有路段信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { foreach (DataRow row in this._data.Rows) { int result = -111; int num2 = -111; int num3 = -999; int num4 = -999; int num5 = -999; if ((row["Flag"].ToString().IndexOf("行驶时间") >= 0) && ((row["DriEnough"].ToString().Trim().Length == 0) || !int.TryParse(row["DriEnough"].ToString(), out result))) { MessageBox.Show("请检查路段\"" + row["PathSegmentName"].ToString() + "\"的行驶最长时间数据是否正确且不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("行驶时间") >= 0) && ((row["DriNoEnough"].ToString().Trim().Length == 0) || !int.TryParse(row["DriNoEnough"].ToString(), out num2))) { MessageBox.Show("请检查路段\"" + row["PathSegmentName"].ToString() + "\"的行驶最短时间数据是否正确且不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("限速") >= 0) && ((row["TopSpeed"].ToString().Trim().Length == 0) || !int.TryParse(row["TopSpeed"].ToString(), out num4))) { MessageBox.Show("请检查路段\"" + row["PathSegmentName"].ToString() + "\"的最高时速数据是否正确且不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("限速") >= 0) && ((row["HoldTime"].ToString().Trim().Length == 0) || !int.TryParse(row["HoldTime"].ToString(), out num3))) { MessageBox.Show("请检查路段\"" + row["PathSegmentName"].ToString() + "\"的持续时长数据是否正确且不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } int.TryParse(row["DriEnough"].ToString(), out result); int.TryParse(row["DriNoEnough"].ToString(), out num2); int.TryParse(row["HoldTime"].ToString(), out num3); int.TryParse(row["TopSpeed"].ToString(), out num4); if (!int.TryParse(row["PathWidth"].ToString(), out num5)) { MessageBox.Show("请检查路段\"" + row["PathSegmentName"].ToString() + "\"参数输入是否正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("限速") >= 0) && ((num4 < 0) || (num4 > 255))) { MessageBox.Show("最高速度不能小于0且不能大于255!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("限速") >= 0) && ((num3 < 0) || (num3 > 255))) { MessageBox.Show("持续时长不能小于0且不能大于255!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((num5 <= 0) || (num5 > 255)) { MessageBox.Show("路宽不能小于0且不能大于255!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("行驶时间") >= 0) && ((result < 0) || (num2 < 0))) { MessageBox.Show("行驶最长时间和行驶最短时间不能小于0!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((row["Flag"].ToString().IndexOf("行驶时间") >= 0) && (result < num2)) { MessageBox.Show("行驶最长时间不能小于行驶最短时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } } PathSegmentChangeArgs arg = new PathSegmentChangeArgs { IsClose = false, IsSet = true }; this.PathSegmentChanging(arg); arg.IsClose = true; this.PathSegmentChanging(arg); } } catch { } }
private void btnClear_Click(object sender, EventArgs e) { try { foreach (DataGridViewRow row in (IEnumerable) this.dgvPathSegment.Rows) { row.Cells["HoldTime"].Value = DBNull.Value; row.Cells["DriEnough"].Value = DBNull.Value; row.Cells["TopSpeed"].Value = DBNull.Value; row.Cells["DriNoEnough"].Value = DBNull.Value; row.Cells["路宽"].Value = DBNull.Value; row.Cells["路段属性"].Value = DBNull.Value; } PathSegmentChangeArgs arg = new PathSegmentChangeArgs { IsClose = false, IsSet = false }; this.PathSegmentChanging(arg); } catch { } }