Ejemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Global  gb = new Global();
            paramst p  = gb.pp;

            Session.Add("gb", gb);
            var questionQuery = from o in p.context.StudInfo
                                where (o.studentid == TextBox1.Text) && (o.pd == TextBox2.Text)
                                select o;

            // Response.Write("<script>window.alert('your message')</script>");

            try
            {
                StudInfo st = questionQuery.First <StudInfo>();
                Session.Add("user", st);
                Response.Redirect("TaskList");

                // Response.Write(@"<script>window.alert('ok')</script>");
            }
            catch (Exception e1)
            {
                String stre = e1.Message + "(无此账号或密码错误)";


                Response.Write(@"<script>window.alert('" + stre + @"')</script>");
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            expid = Session["expid"] as String;
            Global gb = Session["gb"] as Global;;;

            vce = Session["vce"] as View_class_exp;
            st  = Session["user"] as StudInfo;
            pp  = gb.pp;
            if (expid != null)
            {
                var questionQuery2 = from o in pp.context.exp_q
                                     where (o.idexp == int.Parse(expid))

                                     select o;

                if (questionQuery2.Count <exp_q>() > 0)
                {
                    qew = questionQuery2.First <exp_q>();
                }
                labcontrol();
            }
        }
Ejemplo n.º 3
0
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            gb          = Session["gb"] as Global;;
            st          = Session["user"] as StudInfo;
            stid        = st.studentid;
            Label1.Text = "欢迎:" + stid;
            pp          = gb.pp;

            lcsl    = getcsl(stid);
            lclinfo = getclassinfo(lcsl);

            /*
             * DropDownList1.DataSource= lclinfo;
             * //DropDownList1.DataSourceID   = "classinfo1";
             * DropDownList1.DataTextField = "classinfo1";
             * DropDownList1.DataBind();
             * if (Session["cindex"]as string  != null) DropDownList1.SelectedIndex =int.Parse( Session["cindex"]as string) ;
             * // DropDownList1.SelectedIndex = 1;
             * GridView1.DataSource = ltemp;
             * GridView1.DataBind();
             */
            //////////////////////////////////////////
        }
Ejemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Global  gb = Session["gb"] as Global;;
            paramst pp = gb.pp;

            StudInfo st = Session["user"] as StudInfo;


            if (TextBox1.Text == TextBox2.Text && TextBox2.Text != "")
            {
                // var questionQuery1 = from o in pp.context.StudInfo
                //                     where o.studentid == st.studentid
                //                  select o;

                st.pd = TextBox1.Text;
                pp.context.UpdateObject(st);
                pp.context.SaveChanges();
                Response.Write("<script>window.alert('修改成功')</script>");
            }
            else
            {
                Response.Write("<script>window.alert('密码不一致')</script>");
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ////
            Global gb = Session["gb"] as Global;;;

            pp          = gb.pp;
            Label1.Text = Session["Lexserise"] as String;
            exeriseid   = Session["Lexserise"] as String;
            st          = Session["user"] as StudInfo;

            var questionQuery1 = from o in pp.context.exerDetail
                                 where o.lid == int.Parse(exeriseid) && o.typeq == 3
                                 orderby o.id
                                 select o;

            ell = questionQuery1.ToList <exerDetail>();

            int numm = 0;
            ///////////////////////////////////////////////////////////
            List <extime> ltemp = Session["ltemp"] as List <extime>;
            DateTime      dtnow = DateTime.Now;
            // DateTime stime = new DateTime();
            // DateTime etime = new DateTime();
            //"{ eid = 3164, ename = 20-21绪论, stime = 2020/10/12 0:00:00, etime = 2020/11/6 0:00:00 }
            bool benable = true;

            foreach (extime o in ltemp)
            {
                int lexid = o.eid;
                if (lexid == int.Parse(exeriseid))
                {
                    DateTime stime = (DateTime)o.stime;
                    DateTime etime = (DateTime)o.etime;
                    if (dtnow < stime || dtnow > etime)
                    {
                        benable = false;
                    }
                }
            }
            // if (!benable) Button1.Enabled = false;
            ////////////////////////////////////

            foreach (exerDetail eld in ell)
            {
                var questionQuery2 = from o in pp.context.SQues
                                     where o.id == eld.qid
                                     select o;
                SQues mcq = questionQuery2.First <SQues>();
                System.IO.MemoryStream mstream = new System.IO.MemoryStream(mcq.question, false);
                StreamReader           rt      = new StreamReader(mstream);
                RtfSource rs    = new RtfSource(rt);
                int       no    = numm + 1;
                var       html2 = Rtf.ToHtml(rs);
                //  viewDiv.InnerHtml  = no+"."+html2;
                HtmlGenericControl Div2 = new HtmlGenericControl();
                Div2.ID = "div" + numm;
                HtmlGenericControl Div3 = new HtmlGenericControl();
                Div3.ID = "div" + (numm + 1000);
                HtmlGenericControl Div4 = new HtmlGenericControl();
                Div4.ID = "pdiv" + numm;
                Button rbl = new Button();
                if (!benable)
                {
                    rbl.Enabled = false;
                }
                rbl.Click          += new System.EventHandler(this.but_Click);
                rbl.CommandArgument = numm.ToString();
                HtmlInputFile fbutton = new HtmlInputFile();
                fbutton.Accept = "image/*";
                fbutton.ID     = numm.ToString();
                lfb.Add(fbutton);
                // CommandArgument = "Descending"
                // OnCommand = "CommandBtn_Click"
                rbl.Text = "上传图片";
                rbl.ID   = "rbl" + numm;
                Image Image1            = new Image();
                HtmlGenericControl Div5 = new HtmlGenericControl();
                Div5.InnerHtml = "</br>" + "</br>";
                if (numm % 2 == 0)
                {
                    Div2.Style.Add("lcs", "OVERFLOW: auto; WIDTH: 400px; HEIGHT: 400px;color:blue;font-size:16px");
                }
                else
                {
                    Div2.Style.Add("lcs", "OVERFLOW: auto; WIDTH: 400px; HEIGHT: 400px;color: balck;font-size:16px");
                }

                ///读取答案
                var questionQuery3 = from o in pp.context.studAnsw
                                     where o.did == eld.id && o.lid == eld.lid && o.stid == st.studentid
                                     select o;
                if (questionQuery3.Count <studAnsw>() > 0)
                {
                    if (questionQuery3.First <studAnsw>().answ3 != null)
                    {
                        // bool ics = (bool)questionQuery3.First<studAnsw>().answ2;


                        //
                        //  Image himg = new Image();
                        // byte[] bytes = questionQuery3.First<studAnsw>().answ3;
                        // Response.BinaryWrite(bytes);
                        //  MemoryStream ms = new MemoryStream(bytes);
                        // himg = Image.FromStream(ms, true);
                        //
                        byte[]       bytes   = questionQuery3.First <studAnsw>().answ3;
                        MemoryStream MStream = new MemoryStream(bytes);
                        string       base64  = Convert.ToBase64String(MStream.ToArray());
                        Image1.ImageUrl   = "data:image/png;base64," + base64;
                        Image1.ImageAlign = ImageAlign.Middle;
                        // Image1.Width = 600;
                        Image1.Width = Unit.Percentage(70);
                        Div4.Controls.Add(Image1);
                    }
                }



                ////

                Div3.Controls.Add(fbutton);
                Div3.Controls.Add(rbl);
                Div2.InnerHtml = "</br>" + no + "." + html2 + "</br>";
                numm           = numm + 1;
                //   rrtf.Add(richTextBox1.Rtf);
                viewDiv.Controls.Add(Div2);

                viewDiv.Controls.Add(Div4);
                viewDiv.Controls.Add(Div5);
                viewDiv.Controls.Add(Div3);
                //查询答案

                /*var q2 = from q in pp.context.studAnsw
                 *       where q.lid == eld.lid && q.stid == pp.st.studentid && q.did == eld.id
                 *       select q;
                 * studAnsw answ1 = null;
                 #00FFFF
                 * if (q2.Count<studAnsw>() > 0) { answ1 = q2.First<studAnsw>(); Lmqansw.Add(answ1); }
                 * ell = questionQuery1.ToList<exerDetail>();
                 */
            }
            ////
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ////
            Global  gb = Session["gb"] as Global;;
            paramst pp = gb.pp;

            Label1.Text = Session["Lexserise"] as String;
            exeriseid   = Session["Lexserise"] as String;
            st          = Session["user"] as StudInfo;
            ///////////////////////////////////////////////////////////
            List <extime> ltemp = Session["ltemp"] as List <extime>;
            DateTime      dtnow = DateTime.Now;
            // DateTime stime = new DateTime();
            // DateTime etime = new DateTime();
            //"{ eid = 3164, ename = 20-21绪论, stime = 2020/10/12 0:00:00, etime = 2020/11/6 0:00:00 }
            bool benable = true;

            foreach (extime o in ltemp)
            {
                int lexid = o.eid;
                if (lexid == int.Parse(exeriseid))
                {
                    DateTime stime = (DateTime)o.stime;
                    DateTime etime = (DateTime)o.etime;
                    if (dtnow < stime || dtnow > etime)
                    {
                        benable = false;
                    }
                }
            }
            if (!benable)
            {
                Button1.Enabled = false;
            }
            ////////////////////////////////////

            var questionQuery1 = from o in pp.context.exerDetail
                                 where o.lid == int.Parse(exeriseid) && o.typeq == 1
                                 orderby o.id
                                 select o;
            List <exerDetail> ell = questionQuery1.ToList <exerDetail>();


            int numm = 0;

            foreach (exerDetail eld in ell)
            {
                var questionQuery2 = from o in pp.context.TFQues
                                     where o.id == eld.qid
                                     select o;
                TFQues mcq = questionQuery2.First <TFQues>();
                System.IO.MemoryStream mstream = new System.IO.MemoryStream(mcq.question, false);
                StreamReader           rt      = new StreamReader(mstream);
                RtfSource rs    = new RtfSource(rt);
                int       no    = numm + 1;
                var       html2 = Rtf.ToHtml(rs);
                //  viewDiv.InnerHtml  = no+"."+html2;
                HtmlGenericControl Div2 = new HtmlGenericControl();
                Div2.ID = "div" + numm;
                HtmlGenericControl Div3 = new HtmlGenericControl();
                Div3.ID = "div" + (numm + 1000);
                RadioButtonList rbl = new RadioButtonList();
                rbl.ID = "rbl" + numm;
                rbl.Items.Add("True");
                rbl.Items.Add("False");

                lrb.Add(rbl);
                if (numm % 2 == 0)
                {
                    Div2.Style.Add("lcs", "OVERFLOW: auto; WIDTH: 400px; HEIGHT: 400px;color:blue;font-size:16px");
                }
                else
                {
                    Div2.Style.Add("lcs", "OVERFLOW: auto; WIDTH: 400px; HEIGHT: 400px;color: balck;font-size:16px");
                }
                rbl.RepeatDirection = RepeatDirection.Horizontal;
                ///读取答案
                var questionQuery3 = from o in pp.context.studAnsw
                                     where o.did == eld.id && o.lid == eld.lid && o.stid == st.studentid
                                     select o;
                if (questionQuery3.Count <studAnsw>() > 0)
                {
                    if (questionQuery3.First <studAnsw>().answ2 != null)
                    {
                        string cs  = "";
                        bool   ics = (bool)questionQuery3.First <studAnsw>().answ2;
                        if (!ics)
                        {
                            cs = "False";
                        }
                        if (ics)
                        {
                            cs = "True";
                        }
                        rbl.SelectedValue = cs;
                    }
                }



                ////


                Div3.Controls.Add(rbl);
                Div2.InnerHtml = no + "." + html2;
                numm           = numm + 1;
                //   rrtf.Add(richTextBox1.Rtf);
                viewDiv.Controls.Add(Div2);
                viewDiv.Controls.Add(Div3);
                //查询答案

                /*var q2 = from q in pp.context.studAnsw
                 *       where q.lid == eld.lid && q.stid == pp.st.studentid && q.did == eld.id
                 *       select q;
                 * studAnsw answ1 = null;
                 #00FFFF
                 * if (q2.Count<studAnsw>() > 0) { answ1 = q2.First<studAnsw>(); Lmqansw.Add(answ1); }
                 * ell = questionQuery1.ToList<exerDetail>();
                 */
            }
            ////
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // String str= Request.QueryString["r0"];
            // Label1.Text = str;
            List <String> keystrl = new List <string>();
            //Global gb = new Global();
            Global  gb = Session["gb"] as Global;;
            paramst pp = gb.pp;

            exeriseid = Session["Lexserise"] as String;
            st        = Session["user"] as StudInfo;

            var questionQuery1 = from o in pp.context.exerDetail
                                 where o.lid == int.Parse(exeriseid) && o.typeq == 0
                                 orderby o.id
                                 select o;

            ell = questionQuery1.ToList <exerDetail>();
            for (int i = 0; i < ell.Count(); i++)
            {
                String index = "r" + i;
                String str   = Request.QueryString[index];
                keystrl.Add(str);
            }


            int num = 0;

            foreach (exerDetail eld in ell)
            {
                ///更新答案
                var questionQuery3 = from o in pp.context.studAnsw
                                     where o.did == eld.id && o.lid == eld.lid && o.stid == st.studentid
                                     select o;
                if (questionQuery3.Count <studAnsw>() > 0)
                {
                    // if (questionQuery3.First<studAnsw>().answ1 != null)
                    // {
                    int      cs      = -1;
                    studAnsw stanser = questionQuery3.First <studAnsw>();
                    if (keystrl[num] == "A")
                    {
                        cs = 0;
                    }
                    if (keystrl[num] == "B")
                    {
                        cs = 1;
                    }
                    if (keystrl[num] == "C")
                    {
                        cs = 2;
                    }
                    if (keystrl[num] == "D")
                    {
                        cs = 3;
                    }
                    if (cs != -1)
                    {
                        stanser.answ1 = cs;
                    }
                    pp.context.UpdateObject(stanser);

                    //  }
                }
                else
                {
                    if (keystrl[num] != null)
                    {
                        int cs = -1;
                        if (keystrl[num] == "A")
                        {
                            cs = 0;
                        }
                        if (keystrl[num] == "B")
                        {
                            cs = 1;
                        }
                        if (keystrl[num] == "C")
                        {
                            cs = 2;
                        }
                        if (keystrl[num] == "D")
                        {
                            cs = 3;
                        }
                        studAnsw tst = new studAnsw();
                        if (cs != -1)
                        {
                            tst.answ1 = cs;
                        }
                        tst.did  = eld.id;
                        tst.lid  = eld.lid;
                        tst.stid = st.studentid;
                        pp.context.AddTostudAnsw(tst);
                        pp.context.SaveChanges();
                    }
                }
                num++;
            }//endeach
            pp.context.SaveChanges();
        }