/// <summary> /// 添加记录到数据库 /// </summary> /// <param name="recordObj"></param> /// <returns></returns> public static int AddRecord(DBRecord recordObj) { try { StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO review_record_tbl(tfs_id, group_name, coder, code_date, reviewer, review_date, code_line, content)"); sb.Append("VALUES(?tfs_id,?group_name,?coder,?code_date,?reviewer,?review_date,?code_line,?content)"); MySqlParameter[] parameters = { new MySqlParameter("?tfs_id", MySqlDbType.Int32), new MySqlParameter("?group_name", MySqlDbType.String), new MySqlParameter("?coder", MySqlDbType.String), new MySqlParameter("?code_date", MySqlDbType.Date), new MySqlParameter("?reviewer", MySqlDbType.String), new MySqlParameter("?review_date", MySqlDbType.Date), new MySqlParameter("?code_line", MySqlDbType.Int32), new MySqlParameter("?content", MySqlDbType.String) }; parameters[0].Value = recordObj.m_iTfsID; parameters[1].Value = recordObj.m_strGroupName; parameters[2].Value = recordObj.m_strCoder; parameters[3].Value = recordObj.m_strCodeDate; parameters[4].Value = recordObj.m_strReviewer; parameters[5].Value = recordObj.m_strReviewDate; parameters[6].Value = recordObj.m_iReviewLine; parameters[7].Value = recordObj.m_strContent; return(SQLHelper.ExecuteNonQuery(sb.ToString(), CommandType.Text, parameters)); } catch (System.Exception ex) { throw ex; } }
/// <summary> /// 确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ok_button_Click(object sender, EventArgs e) { // 内容检查 if (ReviewCheck() == false) { return; } try { // 注释信息 string strTemp = review_tfs_textBox.Text.Trim(); this.Cursor = System.Windows.Forms.Cursors.WaitCursor; // 信息添加到数据库 DBRecord dbRecord = new DBRecord(); dbRecord.m_iTfsID = MainForm.m_tagTFSWindowInfo.m_iID; dbRecord.m_strGroupName = MainForm.m_tagTFSWindowInfo.m_strGroupName; dbRecord.m_strCoder = MainForm.m_tagTFSWindowInfo.m_strCheckin; dbRecord.m_strCodeDate = MainForm.m_tagTFSWindowInfo.m_strCheckinDate; dbRecord.m_strReviewer = review_name_textBox.Text.Trim(); dbRecord.m_strReviewDate = DateTime.Now.ToShortDateString(); dbRecord.m_iReviewLine = int.Parse(review_line_textBox.Text); dbRecord.m_strContent = strTemp; DatabaseInterface.AddRecord(dbRecord); // 发送邮件 if (review_mail_checkBox.CheckState == CheckState.Checked) { SendMail(); } // 设置Review标签 string strTFSContent = MainForm.m_tagTFSWindowInfo.m_strContent; StringBuilder strContent = new StringBuilder(4096); strContent.Append(strTFSContent); if (strTFSContent.Length > 0 && strTFSContent[0] != '*') { WinAPI.SendMessage(MainForm.m_tagTFSWindowInfo.m_hContentCtrl, WinAPI.WM_SETTEXT, strContent.Capacity, strContent); WinAPI.SendMessage(MainForm.m_tagTFSWindowInfo.m_hContentCtrl, WinAPI.WM_CHAR, (IntPtr)'*', IntPtr.Zero); } this.Cursor = System.Windows.Forms.Cursors.Arrow; this.Close(); } catch (System.Exception ex) { this.Cursor = System.Windows.Forms.Cursors.Arrow; MainForm.ErrorMessage(ex.ToString()); } }