/// <summary> /// 查看源数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void 查看原数据ToolStripMenuItem_Click(object sender, EventArgs e) { this.ptbMainForm.Visible = false; this.ptbMFzhifangtu.Visible = false; this.ptbXS.Visible = false; this.dgvMainForm.Visible = true; //ParametersSetting pa = new ParametersSetting(); //.cmbState.Text; string where =""; switch (sy) { case null: where = where + ""; break; default: //where += " where 年 between '"+sy+"' and '"+ey+"'"; break; where += " where 年 >='" + sy + "' and 年 <= '" + ey + "'"; break; } switch (state) { case "All": where = where + ""; break; case "请选择结果": where = where + ""; break; case "NG": where = where + " and 状态 like 'NG%'"; break; case "GO": where = where + " and 状态 like 'Go%'"; break; default: break; } //OdbcConnection conn = new Connection().ConnDBF(); //conn.Open(); Connection con = new Connection(); string sql = "select * from " + con.table + where; GetDatatable gdt = new GetDatatable(); DataTable dt = gdt.getDt(sql); //OdbcDataAdapter da = new OdbcDataAdapter(sql, conn); //DataTable dt = new DataTable(); //da.Fill(dt); this.dgvMainForm.DataSource = dt.DefaultView; for (int i = 0; i <= this.dgvMainForm.RowCount - 2; i++) { DataRowView mydrv = dt.DefaultView[i]; string score = Convert.ToString(mydrv["状态"]); if (score == "NG/0") { this.dgvMainForm.Rows[i].Cells["状态"].Style.ForeColor = System.Drawing.Color.Red; } } all = dt.Rows.Count;//查询结果的总数 ng = dt.Select(" 状态 = 'NG'").Count();//查询结果中不合格的总数; go = all - ng;//合格的总数; //conn.Close(); }