急求高手帮忙~~~
请先看一下这段代码:
private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBox2.DataSource!=null)
{
string sql="select year(enrolmenttime) from classinfo where classid="+comboBox2.SelectedValue;
OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
int rxnf=Int32.Parse(cmd.ExecuteScalar().ToString());
sql="select length from classinfo where classid="+comboBox2.SelectedValue;
cmd.CommandText=sql;
int nianzhi=Int32.Parse(cmd.ExecuteScalar().ToString());
comboBox3.Items.Clear();
int nf=rxnf;
Object item=new object();
for (int i=1;i<=nianzhi*2;i++)
{
comboBox3.Items.Add(nf + "" + ((i + 1) % 2 + 1));
if (i%2==0) nf++;
}
}
else
{
comboBox3.SelectedIndex=-1;
comboBox3.Items.Clear();
}
其中 nf代表年份,nianzhi就是年制。这是学生信息系统中添加课程的一段代码,程序会自动产生班级的每一个学期。利用for循环生成班级学期代码。比如,年制为3年的班级会自动产生6个学期代码。
这段程序运行的结果比如是20062,就代表2006-2007年度第一学期。我想把运行结果换为“2006-2007年度第一学期”,这种表示方式。请高手帮忙看看,急用~~~~~~