/// <summary>
 /// 更新提交的实验
 /// </summary>
 /// <param name="experiments"></param>
 public void UpdateExperiment(Experiments experiments)
 {
     try
     {
         string cmdstring = "UPDATE [USTA].[dbo].[usta_Experiments] SET [experimentResourceId] = @experimentResourceId,[studentNo] = @studentNo,[isCheck] = @isCheck,[updateTime] = @updateTime,[checkTime] = @checkTime,[attachmentId] = @attachmentId WHERE [email protected]";
         //   SqlParameter[] parameters = new SqlParameter[7]{
         //  new SqlParameter("@experimentResourceId",experiments.experimentResourceId),
         //  new SqlParameter("@studentNo",experiments.studentNo),
         //  new SqlParameter("@isCheck",experiments.isCheck),
         //  new SqlParameter("@updateTime",experiments.updateTime.ToString()),
         //  new SqlParameter("@checkTime",experiments.checkTime),
         //  new SqlParameter("@attachmentId",experiments.attachmentId),
         //  new SqlParameter("@experimentId",experiments.experimentId)
         //};
         SqlParameter[] parameters = {
             new SqlParameter("@experimentId", SqlDbType.Int,4),
             new SqlParameter("@experimentResourceId", SqlDbType.Int,4),
             new SqlParameter("@studentNo", SqlDbType.NChar,10),
             new SqlParameter("@isCheck", SqlDbType.Bit,1),
             new SqlParameter("@updateTime", SqlDbType.DateTime),
             new SqlParameter("@checkTime", SqlDbType.DateTime),
             new SqlParameter("@attachmentId", SqlDbType.Int,4)
             };
         parameters[0].Value = experiments.experimentId;
         parameters[1].Value = experiments.experimentResourceId;
         parameters[2].Value = experiments.studentNo;
         parameters[3].Value = experiments.isCheck;
         parameters[4].Value = experiments.updateTime;
         parameters[5].Value = experiments.checkTime;
         parameters[6].Value = experiments.attachmentId;
         ;
         SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
     }
     catch (Exception ex)
     {
         MongoDBLog.LogRecord(ex);
         CommonUtility.RedirectUrl();
     }
     finally
     {
         conn.Close();
     }
 }
        /// <summary>
        /// 插入一条实验提交
        /// </summary>
        /// <param name="experiments"></param>
        public void InsertExperiment(Experiments experiments)
        {
            try
            {
                string cmdstring = "INSERT INTO [USTA].[dbo].[usta_Experiments] ([experimentResourceId],[studentNo] ,[updateTime] ,[attachmentId]) VALUES ( @experimentResourceId,@studentNo,@updateTime,@attachmentId)";

                //   SqlParameter[] parameters = new SqlParameter[4]{
                //  new SqlParameter("@experimentResourceId",experiments.experimentResourceId),
                //  new SqlParameter("@studentNo",experiments.studentNo),

                //  new SqlParameter("@updateTime",experiments.updateTime.ToString()),

                //  new SqlParameter("@attachmentId",experiments.attachmentId)
                //};
                SqlParameter[] parameters = {
                    new SqlParameter("@experimentResourceId", SqlDbType.Int,4),
                    new SqlParameter("@studentNo", SqlDbType.NChar,10),
                    new SqlParameter("@updateTime", SqlDbType.DateTime),
                    new SqlParameter("@attachmentId", SqlDbType.Int,4),
                    };
                parameters[0].Value = experiments.experimentResourceId;
                parameters[1].Value = experiments.studentNo;
                parameters[2].Value = experiments.updateTime;
                parameters[3].Value = experiments.attachmentId;
                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
        /// <summary>
        /// 更新实验提交
        /// </summary>
        /// <param name="experiments"></param>
        public void SubmitExperiment(Experiments experiments)
        {
            try
            {
                string cmdstring = "UPDATE [USTA].[dbo].[usta_Experiments] SET [email protected],[email protected],isSubmit='1'  WHERE [email protected] AND [email protected]";

                //   SqlParameter[] parameters = new SqlParameter[4]{
                //  new SqlParameter("@experimentResourceId",experiments.experimentResourceId),
                //  new SqlParameter("@studentNo",experiments.studentNo),

                //  new SqlParameter("@updateTime",experiments.updateTime.ToString()),

                //  new SqlParameter("@attachmentId",experiments.attachmentId)
                //};
                SqlParameter[] parameters = {

                    new SqlParameter("@experimentResourceId", SqlDbType.Int,4),
                    new SqlParameter("@studentNo", SqlDbType.NChar,10),

                    new SqlParameter("@updateTime", SqlDbType.DateTime),

                    new SqlParameter("@attachmentId", SqlDbType.NVarChar,50),
                    };

                parameters[0].Value = experiments.experimentResourceId;
                parameters[1].Value = experiments.studentNo;

                parameters[2].Value = experiments.updateTime;

                parameters[3].Value = experiments.attachmentId;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, cmdstring, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
        /// <summary>
        /// 通过提交的实验主键获得提交的实验
        /// </summary>
        /// <param name="experimentId"></param>
        /// <returns></returns>
        public Experiments GetExperimentById(int experimentId)
        {
            Experiments experiments = null;
            string cmdstring = "SELECT [experimentId],[experimentResourceId],[studentNo] ,[isCheck] ,[updateTime] ,[checkTime],[attachmentId],[remark],[excellentTime],[isExcellent],[score] FROM [USTA].[dbo].[usta_Experiments] WHERE [email protected]";
            SqlParameter[] parameters = new SqlParameter[1]{
                new SqlParameter("@experimentId",experimentId)
            };
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, cmdstring, parameters);
            if (dr.Read())
            {
                string attachId = string.Empty;
                if (dr["attachmentId"].ToString() != "") attachId = dr["attachmentId"].ToString().Trim();
                experiments = new Experiments
             {
                 experimentId = int.Parse(dr["experimentId"].ToString()),
                 experimentResourceId = int.Parse(dr["experimentResourceId"].ToString()),
                 studentNo = dr["studentNo"].ToString().Trim(),
                 isCheck = bool.Parse(dr["isCheck"].ToString()),
                 updateTime = Convert.ToDateTime(dr["updateTime"].ToString()),
                 attachmentId = attachId,
                 remark = dr["remark"].ToString().Trim(),
                 isExcellent = bool.Parse(dr["isExcellent"].ToString()),
                 //excellentTime = Convert.ToDateTime(dr["excellentTime"].ToString())
             };
                if (dr["checkTime"].ToString() != "") experiments.checkTime = Convert.ToDateTime(dr["checkTime"].ToString());
                if (dr["excellentTime"].ToString() != "") experiments.excellentTime = Convert.ToDateTime(dr["excellentTime"].ToString());

            }
            dr.Close();
            conn.Close();
            return experiments;
        }