/// <summary> /// 预定 /// </summary> void dgvQuery_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 15) { DataGridViewDisableButtonCell cell = this.dgvQuery[e.ColumnIndex, e.RowIndex] as DataGridViewDisableButtonCell; if (cell != null && cell.Enabled) { if (AppContext.LoginUser != null) { this.Reservation(cell.OwningRow.Tag as QueryTrainData); } else { DialogResult result = MessageBox.Show(this, "请先登录。", "提示", MessageBoxButtons.OKCancel); if (result == DialogResult.OK && this.Login() == DialogResult.OK) { this.dgvQuery_CellContentClick(sender, e); } } } } } catch (Exception ex) { MessageBox.Show(this, "错误:" + ex.Message, "系统错误"); } return; }
// Override the Clone method so that the Enabled property is copied. public override object Clone() { DataGridViewDisableButtonCell cell = (DataGridViewDisableButtonCell)base.Clone(); cell.Enabled = this.Enabled; return(cell); }
/// <summary> /// 加载查询数据 /// </summary> /// <param name="dataArray"></param> private void LoadQueryData(QueryTrainData[] dataArray) { this.dgvQuery.Rows.Clear(); if (dataArray != null && dataArray.Length > 0) { foreach (QueryTrainData item in dataArray) { if (item.QueryLeftNewDTO != null) { int index = this.dgvQuery.Rows.Add( item.QueryLeftNewDTO.station_train_code, item.QueryLeftNewDTO.from_station_name + "-" + item.QueryLeftNewDTO.to_station_name, item.QueryLeftNewDTO.start_time + "-" + item.QueryLeftNewDTO.arrive_time, item.QueryLeftNewDTO.lishi, item.QueryLeftNewDTO.swz_num, item.QueryLeftNewDTO.tz_num, item.QueryLeftNewDTO.zy_num, item.QueryLeftNewDTO.ze_num, item.QueryLeftNewDTO.gr_num, item.QueryLeftNewDTO.rw_num, item.QueryLeftNewDTO.yw_num, item.QueryLeftNewDTO.rz_num, item.QueryLeftNewDTO.yz_num, item.QueryLeftNewDTO.wz_num, item.QueryLeftNewDTO.qt_num, item.buttonTextInfo); DataGridViewRow row = this.dgvQuery.Rows[index]; for (int i = 4; i < row.Cells.Count; i++) { DataGridViewCell cell = row.Cells[i]; if (cell.Value.ToString() != "*" && cell.Value.ToString() != "--" && cell.Value.ToString() != "无") { cell.Style.ForeColor = Color.Green; } } if (item.QueryLeftNewDTO.canWebBuy == "Y") { DataGridViewDisableButtonCell cell = row.Cells[15] as DataGridViewDisableButtonCell; cell.Enabled = true; } else { DataGridViewDisableButtonCell cell = row.Cells[15] as DataGridViewDisableButtonCell; cell.Enabled = false; } row.Tag = item; } } } }