/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gv_train_CellContentClick(object sender, DataGridViewCellEventArgs e) { Log("点击行列:" + e.RowIndex + "" + e.ColumnIndex); if (e.ColumnIndex == gv_train.Columns["buttonTextInfo"].Index && e.RowIndex >= 0) { string trainCode = gv_train.Rows[e.RowIndex].Cells["train"].Value.ToString(); Log("开始预订车票" + trainCode + "......."); if (!GetSelectedPassager()) { Log("乘客信息提取失败........"); MessageBox.Show("请选择乘车人"); return; } ots.Passagers = this.pList; //生成订单信息 this.orderInfo = new TrainOrder(); this.orderInfo.TrainDate = dtp_date.Text; this.orderInfo.TrainNo = gv_train.Rows[e.RowIndex].Cells["train"].Value.ToString(); this.orderInfo.TrainCode = gv_train.Rows[e.RowIndex].Cells["trainNo"].Value.ToString(); this.orderInfo.FromCode = gv_train.Rows[e.RowIndex].Cells["fromCode"].Value.ToString(); this.orderInfo.FromName = gv_train.Rows[e.RowIndex].Cells["from"].Value.ToString(); this.orderInfo.ToCode = gv_train.Rows[e.RowIndex].Cells["toCode"].Value.ToString(); this.orderInfo.ToName = gv_train.Rows[e.RowIndex].Cells["to"].Value.ToString(); this.orderInfo.SeatType = "1";//默认硬座 string orderInfoStr = OrderInfoStr(); if (MessageBox.Show(orderInfoStr, "订票确认", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { PreOrder(); } Log("取消订票.........."); } }
/// <summary> /// 自动查询预订 /// </summary> private void AutoRefresh() { Log("开始自动查询,时间间隔" + this.inteval); int time = 0; string fromCode = this.fromTeleCode; string toCode = this.toTeleCode; string trainNo = this.trainCode; while (this.refresh) { time++; Log("开始第" + time + "次查询======================================================================================="); JArray jData = query(this.date, fromCode, toCode); foreach (JObject jobj in jData) { if (isOrder(jobj, trainNo)) { Log("开始预订........"); this.orderInfo = new TrainOrder(); this.orderInfo.TrainDate = dtp_date.Text; this.orderInfo.TrainNo = jobj["queryLeftNewDTO"]["train_no"].ToString(); this.orderInfo.TrainCode = jobj["queryLeftNewDTO"]["station_train_code"].ToString(); this.orderInfo.FromCode = jobj["queryLeftNewDTO"]["from_station_telecode"].ToString(); this.orderInfo.FromName = jobj["queryLeftNewDTO"]["from_station_name"].ToString(); this.orderInfo.ToCode = jobj["queryLeftNewDTO"]["to_station_telecode"].ToString(); this.orderInfo.ToName = jobj["queryLeftNewDTO"]["to_station_name"].ToString(); this.orderInfo.SeatType = this.seatItem.Code;//默认硬座 this.orderInfo.SecretStr = jobj["secretStr"].ToString(); string orderInfoStr = OrderInfoStr(); Log(orderInfoStr); this.refresh = false; //开始订票 PreAutoOrder(); break; } } SetRefresh(time.ToString()); Thread.Sleep(this.inteval * 1000); } }