Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string courseId = Request.QueryString["courseId"];
                string sql      = "select * from CourseInfo inner join VideoInfo on CourseInfo.courseId = VideoInfo.CourseId where CourseInfo.courseId=" + courseId;

                SqlDataReader sdr = DataOperate.GetRow(sql);
                sdr.Read();
                video.Src            = sdr["VideoPath"].ToString();
                currentVideo.Text    = sdr["VideoId"].ToString();
                maininfo_top.Text    = sdr["intro"].ToString();
                maininfo_bottom.Text = sdr["target"].ToString();

                QABindData(sdr["VideoId"].ToString());
                SqlConnection  con = DataOperate.CreateCon();
                SqlCommand     cmd = new SqlCommand("select * from VideoInfo where CourseId=" + courseId, con);
                SqlDataAdapter ad  = new SqlDataAdapter(cmd);
                DataSet        ds  = new DataSet();
                ad.Fill(ds);
                DataList1.DataSource = ds;
                DataList1.DataBind();
                someIntro.Visible    = true;
                questionList.Visible = false;
                resdata.Visible      = false;
                introPart.ForeColor  = System.Drawing.Color.DodgerBlue;
                RBindData();
            }
        }
Пример #2
0
        public static string CurrentTime(float currentTime, string videoPath)
        {
            string courseId = "";
            string stuId    = "";

            if (HttpContext.Current.Session != null && HttpContext.Current.Session["courseId"] != null && HttpContext.Current.Session["userId"] != null)
            {
                courseId = HttpContext.Current.Session["courseId"].ToString();
                stuId    = HttpContext.Current.Session["userId"].ToString();
            }
            SqlConnection con  = DataOperate.CreateCon();
            string        sql1 = "select * from VideoInfo where CourseId=" + courseId + " and VideoPath='" + videoPath + "'";
            SqlDataReader sdr1 = DataOperate.GetRow(sql1);

            sdr1.Read();
            string videoId   = sdr1["VideoId"].ToString();
            string sql2      = "select count(*) from LearnRecord where stuId='" + stuId + "' and videoId=" + videoId;
            string sql3      = "";
            string updatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            if (DataOperate.SeleSQL(sql2) == 0)
            {
                sql3 = "insert into LearnRecord(stuId,courseId,videoId,currentTime,updatedAt) values('" + stuId + "','" + courseId + "'," + videoId + "," + currentTime + ",'" + updatedAt + "')";
            }
            else
            {
                sql3 = "update LearnRecord set currentTime = " + currentTime + ",updatedAt = '" + updatedAt + "' where stuId='" + stuId + "' and videoId=" + videoId;
            }
            DataOperate.ExecSQL(sql3);
            return("success");
        }
Пример #3
0
 protected void Infosave_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = DataOperate.CreateCon();
         coverimg.SaveAs(Server.MapPath("~/upload/image/") + Path.GetFileName(coverimg.FileName));
         string     coverName   = Path.GetFileName(coverimg.FileName);
         string     coverLink   = "~/upload/image/" + Path.GetFileName(coverimg.FileName);
         string     teacherName = Session["userName"].ToString();
         string     openDate    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         string     sql         = "insert into CourseInfo(courseId,courseName,courseType,teacher,cover,intro,target,part,courseLevel,openDate) values('" + courseid.Text + "','" + coursename.Text + "','" + coursetype.SelectedValue + "','" + teacherName + "','" + coverLink + "','" + intro.Text + "','" + target.Text + "','" + part.Text + "','" + courselevel.SelectedValue + "','" + openDate + "')";
         SqlCommand cmd         = new SqlCommand(sql, con);
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
         courseid.Text   = "";
         coursename.Text = "";
         part.Text       = "";
         target.Text     = "";
         intro.Text      = "";
         ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('成功新设课程')</script>");
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('新设课程失败')</script>");
     }
 }
Пример #4
0
        protected void find_Click(object sender, EventArgs e)
        {
            string        mail = txtMail.Text;
            SqlConnection con  = DataOperate.CreateCon();

            con.Open();
            string     sql1 = "select count(*) from TeacherInfo where TeachId = '" + mail + "'";
            string     sql2 = "select count(*) from StudentInfo where StuId = '" + mail + "'";
            SqlCommand cmd1 = new SqlCommand(sql1, con);
            SqlCommand cmd2 = new SqlCommand(sql2, con);

            Session["mail"] = mail;
            if ((Convert.ToInt32(cmd1.ExecuteScalar()) > 0) || (Convert.ToInt32(cmd2.ExecuteScalar()) > 0))
            {
                firstImg.Visible  = false;
                secondImg.Visible = true;
                thirdImg.Visible  = false;
                first.Visible     = false;
                second.Visible    = true;
                third.Visible     = false;
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('该邮箱未被注册')</script>");
            }
        }
Пример #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string        sql = "select * from TeacherInfo where TeachId ='" + Session["userId"].ToString() + "'";
         SqlDataReader sdr = DataOperate.GetRow(sql);
         sdr.Read();
         user.Text       = Session["userName"].ToString();
         person.ImageUrl = sdr["TeachPic"].ToString();
         img.ImageUrl    = sdr["TeachPic"].ToString();
         SqlConnection con = DataOperate.CreateCon();
         SqlCommand    cmd = new SqlCommand();
         cmd.Connection  = con;
         cmd.CommandText = "select * from CourseInfo where teacher ='" + user.Text + "'";
         SqlDataReader reader = null;
         if (con.State == ConnectionState.Closed)
         {
             con.Open();
         }
         reader = cmd.ExecuteReader();
         videocourse.DataSource     = reader;
         videocourse.DataTextField  = "courseName";
         videocourse.DataValueField = "courseId";
         videocourse.DataBind();
     }
 }
Пример #6
0
        protected void LBindData()
        {
            string         courseId = Request.QueryString["courseId"];
            SqlConnection  con      = DataOperate.CreateCon();
            SqlCommand     cmd      = new SqlCommand("select * from VideoInfo where CourseId=" + courseId, con);
            SqlDataAdapter ad       = new SqlDataAdapter(cmd);
            DataSet        ds       = new DataSet();

            ad.Fill(ds);
            DataList1.DataSource = ds;
            DataList1.DataBind();
        }
Пример #7
0
        protected void DropDownListBind()
        {
            SqlConnection con  = DataOperate.CreateCon();
            SqlCommand    cmd1 = new SqlCommand();

            cmd1.Connection = con;
            string teacher = Session["userName"].ToString();

            cmd1.CommandText = "select * from CourseInfo where teacher ='" + teacher + "'";
            SqlDataReader reader1 = null;

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            reader1 = cmd1.ExecuteReader();
            CourseName.DataSource     = reader1;
            CourseName.DataTextField  = "courseName";
            CourseName.DataValueField = "courseId";
            CourseName.DataBind();
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            SqlCommand cmd2 = new SqlCommand();

            cmd2.Connection  = con;
            cmd2.CommandText = "select * from VideoInfo where CourseId ='" + CourseName.SelectedValue + "'";
            SqlDataReader reader2 = null;

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            reader2 = cmd2.ExecuteReader();
            VideoName.DataSource     = reader2;
            VideoName.DataTextField  = "videoName";
            VideoName.DataValueField = "videoId";
            VideoName.DataBind();
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
Пример #8
0
        protected void change_Click(object sender, EventArgs e)
        {
            string        newpass = newone.Text.ToString();
            string        sql1    = "update TeacherInfo set TeachPassword ='******' where TeachId='" + Session["Mail"].ToString() + "'";
            string        sql2    = "update StudentInfo set StuPassword ='******' where StuId='" + Session["Mail"].ToString() + "'";
            SqlConnection con     = DataOperate.CreateCon();

            con.Open();
            SqlCommand cmd1 = new SqlCommand(sql1, con);
            SqlCommand cmd2 = new SqlCommand(sql2, con);

            if (cmd1.ExecuteNonQuery() > 0 || cmd2.ExecuteNonQuery() > 0)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "true", "<script>alert('密码重置成功 请重新登录');window.location.href='Index.aspx'</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('密码重置失败')</script>");
            }
        }
Пример #9
0
 protected void outerDataList_ItemCommand(object source, DataListCommandEventArgs e)
 {
     ((TextBox)e.Item.FindControl("AddAnswer")).Visible = true;
     ((Button)e.Item.FindControl("Submit")).Visible     = true;
     if (e.CommandName == "submit")
     {
         int questionId = Convert.ToInt32(e.CommandArgument);
         ((TextBox)e.Item.FindControl("AddAnswer")).Visible = false;
         ((Button)e.Item.FindControl("Submit")).Visible     = false;
         string        answerContent = ((TextBox)e.Item.FindControl("AddAnswer")).Text;
         string        answerBy      = Session["userName"].ToString();
         string        answerTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         SqlConnection con           = DataOperate.CreateCon();
         string        sql           = "insert into AnswerInfo(AnswerContent,AnswerBy,QuesId,AnswerTime) values('" + answerContent + "','" + answerBy + "'," + questionId + ",'" + answerTime + "')";
         SqlCommand    cmd           = new SqlCommand(sql, con);
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
         QABindData(getVideoIdByQuestionId(questionId));
     }
 }
Пример #10
0
 protected void filesave_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = DataOperate.CreateCon();
         filepath.SaveAs(Server.MapPath("~/upload/file/") + Path.GetFileName(filepath.FileName));
         string     fileLink = "~/upload/file/" + Path.GetFileName(filepath.FileName);
         string     upTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         string     sql      = "insert into FileInfo values('" + filename.Text + "','" + fileLink + "','" + filevideo.SelectedValue + "','" + remark.Text + "','" + upTime + "')";
         SqlCommand cmd      = new SqlCommand(sql, con);
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
         filename.Text = "";
         ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('文件上传成功')</script>");
     }
     catch
     {
         ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('文件上传失败')</script>");
     }
 }
Пример #11
0
        public static string ToRegister(string userId, string Pwd, string entryType, string mailCode)
        {
            string MailCode = mailCode;
            string str      = HttpContext.Current.Session["code"].ToString();
            string sql      = "";

            if (str == MailCode)
            {
                if ("teacher" == entryType)
                {
                    sql = "insert into TeacherInfo(TeachId,TeachPassword) values(@userId,@userPwd)";
                }
                else
                {
                    sql = "insert into StudentInfo(StuId,StuPassword) values(@userId,@userPwd)";
                }

                SqlConnection con = DataOperate.CreateCon();
                con.Open();
                SqlCommand com = new SqlCommand(sql, con);
                com = new SqlCommand(sql, con);
                com.Parameters.Add(new SqlParameter("@userId", SqlDbType.VarChar, 50));
                com.Parameters["@userId"].Value = userId;
                com.Parameters.Add(new SqlParameter("@userPwd", SqlDbType.VarChar, 50));
                com.Parameters["@userPwd"].Value = Pwd;
                if (com.ExecuteNonQuery() > 0)
                {
                    HttpContext.Current.Session["userId"] = userId;
                    return("success");
                }
                else
                {
                    return("fail"); //提示注册失败ToRegister
                }
            }
            else
            {
                return("wrong code");
            }
        }
Пример #12
0
        private void QABindData(string videoId)
        {
            SqlConnection con = DataOperate.CreateCon();
            SqlCommand    cmd = new SqlCommand("PROC_QA", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter ad = new SqlDataAdapter(cmd);

            SqlParameter param = new SqlParameter("@videoId", SqlDbType.VarChar);

            param.Direction = ParameterDirection.Input;
            param.Value     = videoId;
            cmd.Parameters.Add(param);

            DataSet ds = new DataSet();

            ad.Fill(ds);
            ds.Relations.Add(new DataRelation("QA_Relation", ds.Tables[0].Columns["quesId"],
                                              ds.Tables[1].Columns["quesId"], false));
            outerDataList.DataSource = ds;
            outerDataList.DataBind();
        }
Пример #13
0
        protected void CourseName_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection con  = DataOperate.CreateCon();
            SqlCommand    cmd2 = new SqlCommand();

            cmd2.Connection  = con;
            cmd2.CommandText = "select * from VideoInfo where CourseId ='" + CourseName.SelectedValue + "'";
            SqlDataReader reader2 = null;

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            reader2 = cmd2.ExecuteReader();
            VideoName.DataSource     = reader2;
            VideoName.DataTextField  = "videoName";
            VideoName.DataValueField = "videoId";
            VideoName.DataBind();
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
Пример #14
0
        protected void videosave_Click(object sender, EventArgs e)
        {
            string        videoName = videoname.Text;
            SqlConnection con       = DataOperate.CreateCon();

            videopath.SaveAs(Server.MapPath("~/upload/video/") + Path.GetFileName(videopath.FileName));
            string videoLink = "~/upload/video/" + Path.GetFileName(videopath.FileName);

            string[] sqlT = new string[2];
            int      i    = 0;

            sqlT[i++] = "insert into VideoInfo values('" + videoName + "','" + videoLink + "','" + videocourse.SelectedValue + "')";
            sqlT[i]   = "update CourseInfo set part = part+1 where courseId='" + videocourse.SelectedValue + "'";
            if (DataOperate.ExecTransaction(sqlT))
            {
                videoname.Text = "";
                ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('视频上传成功')</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", " <script>alert('视频上传失败')</script>");
            }
        }
Пример #15
0
        public static string SendEmail(string email, string userType)
        {
            string sql = "";

            if (userType == "student")
            {
                sql = "select count(*) from StudentInfo where StuId=@userId";
            }
            else
            {
                sql = "select count(*) from TeacherInfo where TeachId=@userId";
            }

            SqlConnection con = DataOperate.CreateCon();

            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add(new SqlParameter("@userId", SqlDbType.VarChar, 50));
            cmd.Parameters["@userId"].Value = email;
            if (Convert.ToInt32(cmd.ExecuteScalar()) == 0)
            {
                String to      = email;
                Random random  = new Random(Guid.NewGuid().GetHashCode());
                int    code    = random.Next(100000, 1000000);
                string content = "您正在使用邮箱安全验证服务,您本次操作的验证码是:" + code;

                string strSmtpServer = ConfigurationManager.AppSettings["STR_SMTP_SERVER"];
                string strFrom       = ConfigurationManager.AppSettings["STR_SMTP_FROM"];
                string strFromPass   = ConfigurationManager.AppSettings["STR_SMTP_PASSWORD"];
                SendEmail(strSmtpServer, strFrom, strFromPass, to, "激活邮箱", content);
                HttpContext.Current.Session["code"] = code;
                return("success");
            }

            return("user existed");
        }
Пример #16
0
        public static string Login(string userId, string Pwd, string entryType)
        {
            HttpContext.Current.Session["entryType"] = entryType;
            string cs = entryType;
            string sql;

            if (cs == "教师")
            {
                sql = "select * from TeacherInfo where TeachId=@userId and TeachPassword=@Pwd ";
            }
            else
            {
                sql = "select * from StudentInfo where StuId=@userId and StuPassword=@Pwd ";
            }

            SqlConnection con = DataOperate.CreateCon();

            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add(new SqlParameter("userId", SqlDbType.VarChar, 50));
            cmd.Parameters["userId"].Value = userId;
            cmd.Parameters.Add(new SqlParameter("Pwd", SqlDbType.VarChar, 50));
            cmd.Parameters["Pwd"].Value = Pwd;
            SqlDataReader sdr = cmd.ExecuteReader();

            if (sdr.Read())
            {
                HttpContext.Current.Session["userId"]   = userId;
                HttpContext.Current.Session["userName"] = cs == "教师" ? sdr["TeachName"].ToString() : sdr["StuName"].ToString();
                HttpContext.Current.Session["userType"] = cs;
                return("success");
            }

            return("fail");
        }