//testes por turma protected void BtnSelectTur_Click(object sender, EventArgs e) { DBConnectMySQL ligacao = new DBConnectMySQL(); LblMsg.Text = ligacao.Bind(ref GridView1, TxBAno.Text, TxBTurma.Text, TxBEscola.Text, LblData1.Text, LblData2.Text); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //Carregar datas if (!IsPostBack) { int i; for (i = 1; i <= 31; i++) { DropDownListDia.Items.Add(i.ToString()); } for (i = 1; i <= 12; i++) { DropDownListMes.Items.Add(i.ToString()); } for (i = DateTime.Today.Year; i >= 1900; i--) { DropDownListAno.Items.Add(i.ToString()); } DropDownListAno.Items.FindByText("2000").Selected = true; } //nº de registos DBConnectMySQL ligacao = new DBConnectMySQL(); LblMsg.Text = "Existem registos de " + ligacao.Count().ToString() + " testes. "; }
//testes por disciplina protected void BtnSelectDisc_Click(object sender, EventArgs e) { DBConnectMySQL ligacao = new DBConnectMySQL(); LblMsg.Text = ligacao.Bind(ref GridView1, TxBDisciplina.Text, LblData1.Text, LblData2.Text); GridView1.DataBind(); }
/// <summary> /// 写入数据库 /// </summary> /// <param name="cmdStr"></param> /// <returns></returns> protected static bool WriteToDB(string cmdStr) { try { if (E_DB_CONNECT_MODE.DIRECT == Db_connect_mode) { // 直接写入数据库 DBConnectMySQL mysql_object = new DBConnectMySQL(DbServerInfo); mysql_object.ExecuteMySqlCommand(cmdStr); } else if (E_DB_CONNECT_MODE.RELAY == Db_connect_mode) { // 通过中继服务器 lock (SendBufferQueue) { SendBufferQueue.Enqueue(cmdStr); //LogOutput.LogAppend("WriteToDB SendBufferQueue.Enqueue : " + cmdStr); } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); LogOutput.LogAppend(ex.ToString()); return(false); } return(true); }
//seleciona teste por ID protected void BtnSelect_Click(object sender, EventArgs e) { DBConnectMySQL ligacao = new DBConnectMySQL(); TxBID.Text.Trim(); if (ligacao.DevolverTeste(TxBID.Text, ref LblData1, ref TxBAno, ref TxBTurma, ref TxBEscola, ref TxBDisciplina)) { LblMsg.Text = "Seleção completada! "; } else { LblMsg.Text = "Erro a Seleccionar! "; } }
//atualiza e mostra lista de testes protected void BtnUpdate_Click(object sender, EventArgs e) { DBConnectMySQL ligacao = new DBConnectMySQL(); if (ligacao.Update(TxBID.Text, LblData1.Text, TxBDisciplina.Text, TxBAno.Text, TxBTurma.Text, TxBEscola.Text)) { LblMsg.Text = ligacao.Bind(ref GridView1, TxBAno.Text, TxBTurma.Text, TxBEscola.Text, LblData1.Text, LblData2.Text); LblMsg.Text = "Existem registos de " + ligacao.Count().ToString() + " testes. "; GridView1.DataBind(); } else { LblMsg.Text = "Erro na Atualização! "; } }
/// <summary> /// 写入数据库 /// </summary> /// <param name="cmdStr"></param> /// <returns></returns> protected static bool WriteToDB(string cmdStr) { try { if (E_DB_CONNECT_MODE.DIRECT == Db_connect_mode) { // 直接写入数据库 DBConnectMySQL mysql_object = new DBConnectMySQL(DbServerInfo); mysql_object.ExecuteMySqlCommand(cmdStr); } else if (E_DB_CONNECT_MODE.RELAY == Db_connect_mode) { // 通过中继服务器 lock (SendBufferQueue) { SendBufferQueue.Enqueue(cmdStr); //LogOutput.LogAppend("WriteToDB SendBufferQueue.Enqueue : " + cmdStr); } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); LogOutput.LogAppend(ex.ToString()); return false; } return true; }