📄 mark.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1.Datachaxun
{
public partial class Mark : Form
{
baseclass.BaseOperate boperate = new baseclass.BaseOperate();
public Mark()
{
InitializeComponent();
}
#region 点击gV单元格,改变选中行的颜色
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White;
dataGridView1.CurrentRow.DefaultCellStyle.BackColor = Color.LightSlateGray;
}
#endregion
private void btnOk_Click(object sender, EventArgs e)
{
//将gV中数据导出到excel中
boperate.ExportDataGridview(dataGridView1, true, "mark.xls");
}
private void Mark_Load(object sender, EventArgs e)
{
//加载成绩表中的数据
DataSet myds = boperate.getds(
"select student.s_number as 学号,s_name as 姓名,department as 院系,profession as 专业,class as 班级, A as 选择题,B as 判断题,C as 程序设计题, score as 总成绩 from student , marks where marks.s_number= student.s_number ",
"student");
dataGridView1.DataSource = myds.Tables[0];
if(myds.Tables[0].Rows.Count <= 0)
{
dataGridView1.AllowUserToAddRows = true;
MessageBox.Show("成绩表为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.btnOk.Enabled = false;
}
}
private void btnQuit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -