DataTable planDt; //工单数据流 /// <summary> /// 刷新DataGridView组件的数据 /// </summary> public void ReflshDataGridView() { planDt = null; planDt = AsmPlan_BLL.GetFinishPlansByCondition(" ORDER BY PPP.DT DESC "); DGV_Plan.DataSource = planDt; DGV_Plan.ClearSelection(); }
/// <summary> /// 向上移动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BT_Down_Click(object sender, EventArgs e) { if (this.DGV_Plan.CurrentRow == null) { MessageBox.Show("请选择要需要操作的步序所在行"); } else { int row = DGV_Plan.SelectedRows[0].Index; if (row <= 0) { MessageBox.Show("此步序已在顶端,不能再上移!"); } else { AsmPlanObject apo = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString())); apo.PLAN_LEVEL = apo.PLAN_LEVEL - 1; AsmPlanObject apo_1 = AsmPlan_BLL.GetPlanObjectByCondition("WHERE ID=" + Convert.ToInt32(planDt.Rows[row - 1]["ID"].ToString())); apo_1.PLAN_LEVEL = apo_1.PLAN_LEVEL + 1; if (AsmPlan_BLL.UpdatePlan(apo) > 0 && AsmPlan_BLL.UpdatePlan(apo_1) > 0) { ReflshDataGridView(); DGV_Plan.ClearSelection(); DGV_Plan.Rows[row - 1].Selected = true; } else { MessageBox.Show("上移失败!"); } } } }
/// <summary> /// 点击查询按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BT_Query_Click(object sender, EventArgs e) { try { string sql; //SQL搜索语句 strCondition = getCondition(); //返回搜索条件语句 sql = strCondition + " ORDER BY PPP.DT DESC "; //注意:RPP为运行时表(要更换)、“1”为开始,到时候要换成“4” planDt = null; planDt = AsmPlan_BLL.GetFinishPlansByCondition(sql); DGV_Plan.DataSource = planDt; //DataGridView数据流 DGV_Plan.ClearSelection(); } catch (Exception ex) { Log.InformationLog.Error("查询出错:" + ex.Message); MessageBoxEx.Show("查询出错:" + ex.Message); } }