Beispiel #1
0
        /// <summary>
        /// 加载发给别人的邮件列表
        /// </summary>
        private void loadMailFromList()
        {
            SessionData <User> sessionData = new SessionData <User>();

            sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
            sessionData.data      = LoginInfo.CurrentUser.data.user;

            //发送HTTP请求访问服务器
            try
            {
                string url      = Resources.Server + Resources.mailFromListUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                OkeResult <SessionData <List <Mail> > > result = JsonConvert.DeserializeObject <OkeResult <SessionData <List <Mail> > > >(response);
                if (result.success)
                {
                    mailFromList = result.data.data;
                    for (int i = 0; i < mailFromList.Count; i++)
                    {
                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.Text = mailFromList[i].mailToUser.username;
                        listViewItem.SubItems.Add(mailFromList[i].mailTitle);
                        mailFromListView.Items.Add(listViewItem);
                    }
                }
                else
                {
                    addAlter(result.error, CxFlatAlertBox.AlertType.Error);
                }
            }
            catch
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
            }
        }
Beispiel #2
0
        private void DataoutForm_Load(object sender, EventArgs e)
        {
            #region  拉框的加载
            //发送http请求,获取该教师教授的课程
            try
            {
                SessionData <Teacher> sessionData = new SessionData <Teacher>
                {
                    sessionId = LoginInfo.CurrentUser.sessionId,
                    data      = LoginInfo.CurrentUser.data
                };

                string url  = Resources.Server + Resources.CourseListUrl;
                string data = JsonConvert.SerializeObject(sessionData);
                //MessageBox.Show(data);

                string response = HttpUitls.POST(url, data);//返回的数据
                //MessageBox.Show(response);
                System.Diagnostics.Debug.WriteLine(response);

                #region  获取数据Json转List(反序列化)
                OkeResult <SessionData <List <Course> > > okeResult1 = JsonConvert.DeserializeObject <OkeResult <SessionData <List <Course> > > >(response);
                //MessageBox.Show(okeResult1.data.data.ToString());
                //System.Diagnostics.Debug.WriteLine(okeResult1.data.data.ToString());

                #endregion


                if (okeResult1.success)
                {
                    AddAlter("成功查询课程", CxFlatAlertBox.AlertType.Success);
                    Classlist = okeResult1.data.data;

                    foreach (Course p in Classlist)
                    {
                        this.Classchoose.Items.Add(p.courseName);
                    }
                    AdjustComboBoxDropDownListWidth(Classchoose);
                }
                else
                {
                    AddAlter("查询课程出错,请重新选择", CxFlatAlertBox.AlertType.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                System.Diagnostics.Debug.WriteLine(ex.Message);
                AddAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);//弹出提示
            }
            #endregion
        }
Beispiel #3
0
        /// <summary>
        /// 修改密码按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void updateUserButton_Click(object sender, EventArgs e)
        {
            lockButton();
            string oldPassword = oldPasswordBox.Text.Trim();
            string newPassword = newPasswordBox.Text.Trim();

            //输入密码格式错误
            if (!UserUitls.IsOkPassword(oldPassword) || !UserUitls.IsOkPassword(newPassword))
            {
                addAlter(EnumExtend.GetDisplayText(LoginEnum.ERRORPWD), CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }

            //发送HTTP请求访问服务器
            try
            {
                User user = new User();
                user.username = LoginInfo.CurrentUser.data.user.username;
                user.password = oldPassword;
                UpdateUserData updateUserData = new UpdateUserData();
                updateUserData.user        = user;
                updateUserData.newPassword = newPassword;

                SessionData <UpdateUserData> sessionData = new SessionData <UpdateUserData>();
                sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
                sessionData.data      = updateUserData;
                string             url       = Resources.Server + Resources.UpdateUserUrl;
                string             data      = JsonConvert.SerializeObject(sessionData);
                string             response  = HttpUitls.POST(url, data);
                OkeResult <string> okeResult = JsonConvert.DeserializeObject <OkeResult <string> >(response);
                if (okeResult.success)
                {
                    addAlter(EnumExtend.GetDisplayText(LoginEnum.SUCC_UPDATE), CxFlatAlertBox.AlertType.Success);
                    timer.Stop();
                    timer.Tick += formClose_Tick;
                    timer.Start();
                }
                else
                {
                    addAlter(okeResult.error, CxFlatAlertBox.AlertType.Error);
                    unlockButton();
                }
            }
            catch (Exception)
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }
            return;
        }
Beispiel #4
0
        private void RollcallForm_Load(object sender, EventArgs e)
        {
            #region 发送http请求
            try
            {
                SessionData <string> sessionData = new SessionData <string>
                {
                    data      = CourseInfo.CurrentUser.classCode,//获取当前课程码
                    sessionId = CourseInfo.CurrentUser.sessionId
                };

                string url      = Resources.Server + Resources.CourseOnlineStudentUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                //MessageBox.Show(response);

                OkeResult <SessionData <List <Student> > > okeResult2 = JsonConvert.DeserializeObject <OkeResult <SessionData <List <Student> > > >(response);
                if (okeResult2.success)
                {
                    AddAlter("成功查询学生名单", CxFlatAlertBox.AlertType.Success);

                    Studentlist = okeResult2.data.data;//获取抽奖名单

                    #region 加载抽奖名单到panel2
                    foreach (Student s in Studentlist)
                    {
                        Button btn = new Button
                        {
                            Name      = "Rollallstudent" + num.ToString(),
                            Text      = s.studentName,//把名字写在按钮上
                            Location  = new Point(8 + (num % 5) * 80, 25 * ((num + 5) / 5)),
                            Font      = new Font("微软雅黑", 10.5f, FontStyle.Bold),
                            BackColor = Color.FromArgb(92, 173, 255)
                        };
                        panel2.Controls.Add(btn);
                        num++;
                    }
                    #endregion
                }
                else
                {
                    AddAlter("查询出错(可能未登录)", CxFlatAlertBox.AlertType.Error);
                }
            }
            catch (Exception)
            {
                AddAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);//弹出提示
            }
            #endregion
        }
        /// <summary>
        /// time_Timer触发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void time_Timer_Tick(object sender, EventArgs e)
        {
            questionLimitTime--;

            int tmp = 0;

            if (sumTime != 0)
            {
                tmp = questionLimitTime * 100 / sumTime;
            }
            timeBar.ValueNumber = tmp;

            if (tmp == 0 || questionLimitTime % 100 == 0)
            {
                SessionData <Question> sessionData = new SessionData <Question>();
                sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
                sessionData.data      = question;
                //发送HTTP请求访问服务器
                try
                {
                    string url      = Resources.Server + Resources.AnswerListUrl;
                    string data     = JsonConvert.SerializeObject(sessionData);
                    string response = HttpUitls.POST(url, data);
                    OkeResult <SessionData <AnswerData> > okeResult = JsonConvert.DeserializeObject <OkeResult <SessionData <AnswerData> > >(response);
                    if (okeResult.success)
                    {
                        if (okeResult.data.data.total == 0)
                        {
                            accuracyBar.ValueNumber = 100;
                        }
                        else
                        {
                            accuracyBar.ValueNumber = okeResult.data.data.correct * 100 / okeResult.data.data.total;
                        }
                        totalBox.Text    = okeResult.data.data.total.ToString();
                        correctBox.Text  = okeResult.data.data.correct.ToString();
                        unCommitBox.Text = okeResult.data.data.unCommitted.ToString();
                        errorBox.Text    = okeResult.data.data.error.ToString();
                    }
                }
                catch (Exception)
                {
                }
            }
            if (tmp == 0)
            {
                confirmButton.Enabled = true;
                time_Timer.Stop();
            }
        }
Beispiel #6
0
        /// <summary>
        /// 更新数据按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void updateInfoButton_Click(object sender, EventArgs e)
        {
            lockButton();
            string name  = nameBox.Text.Trim();
            string title = titleBox.Text.Trim();

            //用户信息格式错误
            if (!UserUitls.IsOkInfo(name, title))
            {
                addAlter(EnumExtend.GetDisplayText(RegisterEnum.ERROR_INFO), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //发送HTTP请求访问服务器
            try
            {
                SessionData <Teacher> sessionData = new SessionData <Teacher>();
                sessionData.sessionId         = LoginInfo.CurrentUser.sessionId;
                sessionData.data              = LoginInfo.CurrentUser.data;
                sessionData.data.teacherName  = name;
                sessionData.data.teacherTitle = title;
                string url      = Resources.Server + Resources.UpdateInfoUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                OkeResult <SessionData <Teacher> > okeResult = JsonConvert.DeserializeObject <OkeResult <SessionData <Teacher> > >(response);
                if (okeResult.success)
                {
                    addAlter(EnumExtend.GetDisplayText(LoginEnum.SUCC_UPDATE), CxFlatAlertBox.AlertType.Success);
                    LoginInfo.CurrentUser.sessionId = okeResult.data.sessionId;
                    LoginInfo.CurrentUser.data      = okeResult.data.data;
                    timer.Stop();
                    timer.Tick += formClose_Tick;
                    timer.Start();
                }
                else
                {
                    addAlter(okeResult.error, CxFlatAlertBox.AlertType.Error);
                    unlockButton();
                }
            }
            catch (Exception)
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }
        }
Beispiel #7
0
        /// <summary>
        /// 发布按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void submitButton_Click(object sender, EventArgs e)
        {
            lockButton();

            //未登录或未开启课堂
            if (LoginInfo.CurrentUser.sessionId == null || CourseInfo.CurrentUser.classCode == null)
            {
                addAlter(EnumExtend.GetDisplayText(OperateEnum.NO_COURSE), CxFlatAlertBox.AlertType.Error);
                return;
            }
            SessionData <QuestionData> sessionData = new SessionData <QuestionData>();

            sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
            sessionData.data      = questionData;
            //发送HTTP请求访问服务器
            try
            {
                string url  = Resources.Server + Resources.AddQuestionUrl;
                string data = JsonConvert.SerializeObject(sessionData);
                System.Diagnostics.Debug.WriteLine(data);//测试
                string response = HttpUitls.POST(url, data);
                OkeResult <SessionData <string> > okeResult = JsonConvert.DeserializeObject <OkeResult <SessionData <string> > >(response);
                if (okeResult.success)
                {
                    addAlter(EnumExtend.GetDisplayText(OperateEnum.OP_SUCC), CxFlatAlertBox.AlertType.Success);
                    timer.Stop();
                    questionData.question.questionId = int.Parse(okeResult.error);
                    AnswerSituationForm answerSituationForm = new AnswerSituationForm();
                    answerSituationForm.load(questionData.question);
                    answerSituationForm.ShowDialog();
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    addAlter(EnumExtend.GetDisplayText(OperateEnum.OP_FAIL), CxFlatAlertBox.AlertType.Error);
                    unlockButton();
                }
            }
            catch (Exception)
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }

            unlockButton();
        }
Beispiel #8
0
        /// <summary>
        /// 发布按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void submitButton_Click(object sender, EventArgs e)
        {
            lockButton();
            if (LoginInfo.CurrentUser.sessionId == null || CourseInfo.CurrentUser.classCode == null)
            {
                addAlter(EnumExtend.GetDisplayText(OperateEnum.NO_COURSE), CxFlatAlertBox.AlertType.Error);
                return;
            }
            SessionData <VoteData> sessionData = new SessionData <VoteData>();

            sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
            sessionData.data      = voteData;
            try
            {
                string url      = Properties.Resources.Server + Properties.Resources.AddVoteUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                System.Diagnostics.Debug.WriteLine(response + "触发了");
                //Vote vote = voteData.vote;
                OkeResult <SessionData <Vote> > okeResult = JsonConvert.DeserializeObject <OkeResult <SessionData <Vote> > >(response);

                if (okeResult.success)
                {
                    addAlter(EnumExtend.GetDisplayText(OperateEnum.OP_SUCC), CxFlatAlertBox.AlertType.Success);
                    timer.Stop();
                    //voteData.vote.voteId = int.Parse(okeResult.error);
                    VoteSituationForm voteSituationForm = new VoteSituationForm();
                    //voteSituationForm.voteData = voteData;
                    voteSituationForm.votecount = voteData.voteChoiceList.Count;
                    voteSituationForm.load(okeResult.data.data);
                    System.Diagnostics.Debug.WriteLine(voteData.voteChoiceList.Count + "hahaha");
                    voteSituationForm.ShowDialog();
                    timer.Tick += formClose_Tick;
                    timer.Start();
                }
            }
            catch (Exception)
            {
                addAlter(EnumExtend.GetDisplayText(OperateEnum.OP_FAIL), CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }
            unlockButton();
        }
Beispiel #9
0
        private void cxFlatButton1_Click(object sender, EventArgs e)
        {
            SessionData <string> sessionData = new SessionData <string>();

            sessionData.sessionId = CourseInfo.CurrentUser.sessionId;

            sessionData.data = CourseInfo.CurrentUser.classCode;
            //sessionData.data.courseNumber = CourseInfo.CurrentUser.data.courseNumber;

            //string url = Resources.Server + Resources.EndCourseUrl;
            //string data = JsonConvert.SerializeObject(sessionData);

            //string response = HttpUitls.POST(url, data);
            //textBox1.Text = data;
            try
            {
                string url      = Resources.Server + Resources.EndCourseUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                //textBox1.Text = data;
                OkeResult <string> result = JsonConvert.DeserializeObject <OkeResult <string> >(response);
                if (result.success)
                {
                    CourseInfo.CurrentUser.sessionId = null;
                    CourseInfo.CurrentUser.data      = null;
                    CourseInfo.CurrentUser.classCode = null;
                    addAlter("已结束", CxFlatAlertBox.AlertType.Success);
                    timer1.Stop();
                    timer1.Interval = 1000;
                    timer1.Enabled  = true;
                    timer1.Tick    += formClose_Tick;
                    timer1.Start();
                }
                else
                {
                    addAlter("发生错误", CxFlatAlertBox.AlertType.Error);
                }
            }
            catch
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 退出按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void logoutButton_Click(object sender, EventArgs e)
        {
            lockButton();
            SessionData <Teacher> sessionData = new SessionData <Teacher>();

            sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
            sessionData.data      = LoginInfo.CurrentUser.data;

            //发送HTTP请求访问服务器
            try
            {
                string             url      = Resources.Server + Resources.LogoutUrl;
                string             data     = JsonConvert.SerializeObject(sessionData);
                string             response = HttpUitls.POST(url, data);
                OkeResult <string> result   = JsonConvert.DeserializeObject <OkeResult <string> >(response);
                if (result.success)
                {
                    addAlter(EnumExtend.GetDisplayText(LoginEnum.SUCC_LOGOUT), CxFlatAlertBox.AlertType.Success);
                    LoginInfo.CurrentUser.sessionId = null;
                    LoginInfo.CurrentUser.data      = null;
                    timer.Stop();
                    timer.Tick += formClose_Tick;
                    timer.Start();
                }
                else
                {
                    addAlter(result.error, CxFlatAlertBox.AlertType.Error);
                    unlockButton();
                }
            }
            catch
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }
            return;
        }
Beispiel #11
0
        /// <summary>
        /// 发布稿件按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addMailButton_Click(object sender, EventArgs e)
        {
            lockButton();
            SessionData <Mail> sessionData = new SessionData <Mail>();

            sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
            Mail newMail = new Mail();

            newMail.mailTitle    = mailTitleBox.Text;
            newMail.mailDescribe = mailDescribeBox.Text;
            newMail.mailFromUser = LoginInfo.CurrentUser.data.user;
            newMail.mailToUser   = mail.mailFromUser;
            sessionData.data     = newMail;

            //发送HTTP请求访问服务器
            try
            {
                string url      = Resources.Server + Resources.addMailUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                OkeResult <SessionData <string> > result = JsonConvert.DeserializeObject <OkeResult <SessionData <string> > >(response);
                if (result.success)
                {
                    addAlter(result.error, CxFlatAlertBox.AlertType.Success);
                }
                else
                {
                    addAlter(result.error, CxFlatAlertBox.AlertType.Error);
                }
            }
            catch
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
            }
            unlockButton();
        }
Beispiel #12
0
        /// <summary>
        /// 登录按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loginButton_Click(object sender, EventArgs e)
        {
            lockButton();
            bool   isSave   = rememberUser.Checked;
            string username = usernameBox.Text.Trim();
            string password = passwordBox.Text.Trim();

            //输入框不能为空
            if (username.Equals("") || password.Equals(""))
            {
                addAlter(EnumExtend.GetDisplayText(LoginEnum.NULLINPUT), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //用户名格式错误
            if (!UserUitls.IsOkUsername(username))
            {
                addAlter(EnumExtend.GetDisplayText(LoginEnum.ERRORURN), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //密码格式错误
            if (!UserUitls.IsOkPassword(password))
            {
                addAlter(EnumExtend.GetDisplayText(LoginEnum.ERRORPWD), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            User user = new User();

            user.username = username;
            user.password = password;

            //记住密码则写入数据
            if (isSave)
            {
                userData.isSaveUser = isSave;
                userData.user       = user;
                DataUitls.saveData(userData);
            }
            else
            {
                userData.isSaveUser = false;
                userData.user       = new User();
                DataUitls.saveData(userData);
            }

            //发送HTTP请求访问服务器
            try
            {
                string url      = Resources.Server + Resources.LoginUrl;
                string data     = JsonConvert.SerializeObject(user);
                string response = HttpUitls.POST(url, data);
                OkeResult <LoginInfo> okeResult = JsonConvert.DeserializeObject <OkeResult <LoginInfo> >(response);
                if (okeResult.success)
                {
                    addAlter(EnumExtend.GetDisplayText(LoginEnum.SUCC_LOGIN), CxFlatAlertBox.AlertType.Success);
                    LoginInfo.CurrentUser.sessionId = okeResult.data.sessionId;
                    LoginInfo.CurrentUser.data      = okeResult.data.data;
                    timer.Stop();
                    timer.Tick += formClose_Tick;
                    timer.Start();
                }
                else
                {
                    addAlter(EnumExtend.GetDisplayText(LoginEnum.FAIL_LOGIN), CxFlatAlertBox.AlertType.Error);
                    unlockButton();
                }
            }
            catch (Exception)
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }
        }
Beispiel #13
0
        private void getclassbtn_Click(object sender, EventArgs e)
        {
            if (CourseInfo.CurrentUser.classCode != null)
            {
                classTextBox1.Enabled = false;
                Clipboard.SetDataObject(CourseInfo.CurrentUser.classCode);
                addAlter("已复制", CxFlatAlertBox.AlertType.Success);
                timer1.Stop();
                timer1.Interval = 1000;
                timer1.Enabled  = true;
                timer1.Start();
                this.closebtn.Enabled = true;
            }
            else
            {
                if (classTextBox1.Text == "")
                {
                    addAlter("请输入课程名", CxFlatAlertBox.AlertType.Error);
                    timer1.Stop();
                    timer1.Interval = 1000;
                    timer1.Enabled  = true;
                    timer1.Start();
                }
                else
                {
                    try
                    {
                        SessionData <Course> sessionData = new SessionData <Course>();
                        sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
                        Course course = new Course();
                        sessionData.data            = course;
                        sessionData.data.courseName = classTextBox1.Text;
                        sessionData.data.teacher    = LoginInfo.CurrentUser.data;
                        string url      = Resources.Server + Resources.BeginCourseUrl;
                        string data     = JsonConvert.SerializeObject(sessionData);
                        string response = HttpUitls.POST(url, data);
                        //classTextBox2.Text = response;


                        OkeResult <SessionData <string> > okeResult = JsonConvert.DeserializeObject <OkeResult <SessionData <string> > >(response);
                        //classTextBox2.Text = okeResult.data.data;
                        //classTextBox2.Text = okeResult.data.data.courseNumber;
                        if (okeResult.success)
                        {
                            CourseInfo.CurrentUser.sessionId = okeResult.data.sessionId;
                            //course.courseNumber = okeResult.data.data;
                            //CourseInfo.CurrentUser.data = course;
                            CourseInfo.CurrentUser.classCode       = okeResult.data.data;
                            CourseInfo.CurrentUser.data            = course;
                            CourseInfo.CurrentUser.data.courseName = classTextBox1.Text;

                            //classTextBox2.Text = okeResult.data.data;
                            richTextBox1.Text = okeResult.data.data.Substring(0, 1);
                            richTextBox2.Text = okeResult.data.data.Substring(1, 1);
                            richTextBox3.Text = okeResult.data.data.Substring(2, 1);
                            richTextBox4.Text = okeResult.data.data.Substring(3, 1);
                            richTextBox5.Text = okeResult.data.data.Substring(4, 1);
                            richTextBox6.Text = okeResult.data.data.Substring(5, 1);
                            addAlter("下方为课程码", CxFlatAlertBox.AlertType.Success);
                            timer1.Stop();
                            timer1.Interval = 1000;
                            timer1.Enabled  = true;
                            timer1.Start();
                            MyQRUitls myqr = new MyQRUitls();
                            Bitmap    b    = MyQRUitls.BarcodeImage(CourseInfo.CurrentUser.classCode);
                            //MessageBox.Show("ok!");
                            pictureBox1.Image     = b;
                            getclassbtn.Text      = "复制上课码";
                            classTextBox1.Enabled = false;
                            this.closebtn.Enabled = true;
                        }
                        else
                        {
                            //classTextBox2.Text = okeResult.data.data;
                        }

                        //classTextBox2.Text = okeResult.data.data.courseNumber;
                        //Console.WriteLine(classTextBox2.Text);
                    }
                    catch (Exception)
                    {
                        //addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                        //unlockButton();
                    }
                }
            }
            //string coursename = classTextBox1.Text.Trim();

            //Course course = new Course();
            //course.courseName = coursename;



            //发送HTTP请求访问服务器
            //try
            //{
            //    SessionData<Course> sessionData = new SessionData<Course>();
            //    sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
            //    Course course = new Course();
            //    sessionData.data = course;
            //    sessionData.data.courseName = classTextBox1.Text;
            //    sessionData.data.teacher = LoginInfo.CurrentUser.data;
            //    string url = Resources.Server + Resources.BeginCourseUrl;
            //    string data = JsonConvert.SerializeObject(sessionData);
            //    string response = HttpUitls.POST(url, data);
            //    //classTextBox2.Text = response;


            //    OkeResult<SessionData<string>> okeResult = JsonConvert.DeserializeObject<OkeResult<SessionData<string>>>(response);
            //    //classTextBox2.Text = okeResult.data.data;
            //    //classTextBox2.Text = okeResult.data.data.courseNumber;
            //    if (okeResult.success)
            //    {

            //        CourseInfo.CurrentUser.sessionId = okeResult.data.sessionId;
            //        course.courseNumber = okeResult.data.data;
            //        CourseInfo.CurrentUser.data = course;
            //        //classTextBox2.Text = okeResult.data.data;
            //        richTextBox1.Text = okeResult.data.data.Substring(0, 1);
            //        richTextBox2.Text = okeResult.data.data.Substring(1, 1);
            //        richTextBox3.Text = okeResult.data.data.Substring(2, 1);
            //        richTextBox4.Text = okeResult.data.data.Substring(3, 1);
            //        richTextBox5.Text = okeResult.data.data.Substring(4, 1);
            //        richTextBox6.Text = okeResult.data.data.Substring(5, 1);

            //    }
            //    else
            //    {
            //        //classTextBox2.Text = okeResult.data.data;

            //    }

            //    //classTextBox2.Text = okeResult.data.data.courseNumber;
            //    //Console.WriteLine(classTextBox2.Text);
            //}
            //catch (Exception)
            //{

            //    //addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
            //    //unlockButton();
            //}
            //this.closebtn.Enabled = true;
        }
Beispiel #14
0
        private void time_Timer_Tick(object sender, EventArgs e)
        {
            voteLimitTime--;
            int tmp = 0;

            if (sumTime != 0)
            {
                tmp = voteLimitTime * 100 / sumTime;
            }
            timeBar.ValueNumber = tmp;

            if (voteLimitTime % 100 == 0)
            {
                SessionData <Vote> sessionData = new SessionData <Vote>();
                sessionData.sessionId = LoginInfo.CurrentUser.sessionId;
                sessionData.data      = vote;
                //发送HTTP请求访问服务器
                try
                {
                    string url      = Resources.Server + Resources.VoteSituAnonUrl;
                    string data     = JsonConvert.SerializeObject(sessionData);
                    string response = HttpUitls.POST(url, data);
                    System.Diagnostics.Debug.WriteLine(data + "hahxxxi");
                    System.Diagnostics.Debug.WriteLine(response + "hahaahahxxxi");
                    OkeResult <SessionData <List <int> > > okeResult = JsonConvert.DeserializeObject <OkeResult <SessionData <List <int> > > >(response);
                    if (okeResult.success)
                    {
                        int number = 0;
                        totalBox.Text = okeResult.data.data.Last().ToString();
                        //System.Diagnostics.Debug.WriteLine(okeResult.data.data.total.ToString() + "hahaahahxxxi");
                        //number = int.Parse(totalBox.Text);
                        //correctBox.Text = okeResult.data.data.correct.ToString();
                        //unCommitBox.Text = okeResult.data.data.unCommitted.ToString();

                        //errorBox.Text = okeResult.data.data.error.ToString();
                        number = okeResult.data.data.Last();
                        int[] xixi = okeResult.data.data.ToArray();
                        for (int i = 0; i < votecount; i++)
                        {
                            number -= xixi[i];
                        }
                        unCommitBox.Text = number.ToString();
                        //测试
                        int count = votecount;
                        System.Diagnostics.Debug.WriteLine(count + "xixixix");
                        string[] xData = { "A", "B", "C", "D", "E", "F", "G" };

                        string[] tt = new string[count];
                        Array.ConstrainedCopy(xData, 0, tt, 0, count);
                        int[] xx = new int[count];
                        Array.ConstrainedCopy(xixi, 0, xx, 0, count);


                        chart1.Series[0]["PieLabelStyle"]            = "Outside"; //将文字移到外侧
                        chart1.Series[0]["PieLineColor"]             = "Black";   //绘制黑色的连线。
                        chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;     //隐藏网格
                        chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;     //隐藏网格
                        chart1.ChartAreas[0].AxisY.LabelStyle.Format = "0%";      //格式化,为了显示百分号
                        //chart1.ChartAreas[0].AxisX.Minimum = 0.5;//设置最小值,为了让第一个柱紧挨坐标轴
                        chart1.Series[0].Label = "#VAL{P}";
                        chart1.Series[0].IsValueShownAsLabel = true;//显示标签
                        chart1.Series[0].Points.DataBindXY(tt, xx);
                    }
                    else
                    {
                        int count = votecount;
                        System.Diagnostics.Debug.WriteLine(count + "xixixix");
                        string[] xData = { "A", "B", "C", "D", "E", "F", "G" };
                        int[]    yData = { 0, 0, 0, 0, 0, 0, 0 };
                        string[] tt    = new string[count];
                        Array.ConstrainedCopy(xData, 0, tt, 0, count);
                        int[] xx = new int[count];
                        Array.ConstrainedCopy(yData, 0, xx, 0, count);

                        chart1.Series[0]["PieLabelStyle"]            = "Outside"; //将文字移到外侧
                        chart1.Series[0]["PieLineColor"]             = "Black";   //绘制黑色的连线。
                        chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;     //隐藏网格
                        chart1.ChartAreas[0].AxisY.LabelStyle.Format = "0%";      //格式化,为了显示百分号
                        chart1.ChartAreas[0].AxisX.Minimum           = 0.5;       //设置最小值,为了让第一个柱紧挨坐标轴
                        chart1.Series[0].Points.DataBindXY(tt, xx);
                    }
                }
                catch (Exception)
                {
                    int count = votecount;
                    System.Diagnostics.Debug.WriteLine(count + "xixixix");
                    string[] xData = { "A", "B", "C", "D", "E", "F", "G" };
                    int[]    yData = { 0, 0, 0, 0, 0, 0, 0 };
                    string[] tt    = new string[count];
                    Array.ConstrainedCopy(xData, 0, tt, 0, count);
                    int[] xx = new int[count];
                    Array.ConstrainedCopy(yData, 0, xx, 0, count);

                    chart1.Series[0]["PieLabelStyle"] = "Outside"; //将文字移到外侧
                    chart1.Series[0]["PieLineColor"]  = "Black";   //绘制黑色的连线。
                    chart1.Series[0].Points.DataBindXY(tt, xx);
                }
            }
            if (tmp == 0)
            {
                confirmButton.Enabled = true;
                time_Timer.Stop();
            }
        }
Beispiel #15
0
        /// <summary>
        /// 注册按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void registerButton_Click(object sender, EventArgs e)
        {
            lockButton();

            string username        = usernameBox.Text.Trim();
            string password        = passwordBox.Text.Trim();
            string passwordConfirm = passwordConfirmBox.Text.Trim();
            string name            = nameBox.Text.Trim();
            string title           = titleBox.Text.Trim();

            //输入框不能空
            if (username.Equals("") ||
                password.Equals("") ||
                passwordConfirm.Equals("") ||
                name.Equals("") ||
                title.Equals(""))
            {
                addAlter(EnumExtend.GetDisplayText(RegisterEnum.NULLINPUT), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //确认密码错误
            if (!password.Equals(passwordConfirm))
            {
                addAlter(EnumExtend.GetDisplayText(RegisterEnum.DIFFPWD), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //用户名格式错误
            if (!UserUitls.IsOkUsername(username))
            {
                addAlter(EnumExtend.GetDisplayText(RegisterEnum.ERRORURN), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //密码格式错误
            if (!UserUitls.IsOkPassword(password))
            {
                addAlter(EnumExtend.GetDisplayText(RegisterEnum.ERRORPWD), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            //姓名和职称格式错误
            if (!UserUitls.IsOkInfo(name, title))
            {
                addAlter(EnumExtend.GetDisplayText(RegisterEnum.ERROR_INFO), CxFlatAlertBox.AlertType.Error);
                unlockButton();
                return;
            }

            User user = new User();

            user.username = username;
            user.password = password;
            Teacher teacher = new Teacher();

            teacher.teacherName  = name;
            teacher.teacherTitle = title;
            teacher.user         = user;

            //发送HTTP请求访问服务器
            try
            {
                string             url       = Resources.Server + Resources.RegisterUrl;
                string             data      = JsonConvert.SerializeObject(teacher);
                string             response  = HttpUitls.POST(url, data);
                OkeResult <string> okeResult = JsonConvert.DeserializeObject <OkeResult <string> >(response);
                if (okeResult.success)
                {
                    addAlter(EnumExtend.GetDisplayText(RegisterEnum.SUCC_REGISTER), CxFlatAlertBox.AlertType.Success);
                    timer.Stop();
                    timer.Tick += formClose_Tick;
                    timer.Start();
                }
                else
                {
                    addAlter(EnumExtend.GetDisplayText(RegisterEnum.FAIL_REGISTER), CxFlatAlertBox.AlertType.Error);
                    unlockButton();
                }
            }
            catch (Exception)
            {
                addAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);
                unlockButton();
            }
            return;
        }
Beispiel #16
0
        private void Classcheckbutton_Click(object sender, EventArgs e)
        {
            #region 发送http请求
            try
            {
                SessionData <Course> sessionData = new SessionData <Course>
                {
                    sessionId = LoginInfo.CurrentUser.sessionId
                };
                Course course = new Course();
                sessionData.data = course;
                sessionData.data.courseNumber = Classlist[Classchoose.SelectedIndex].courseNumber;//获取下拉框里面选中的索引值,在classlist里面查找其课程码
                //MessageBox.Show(Classchoose.Text.Trim());
                sessionData.data.teacher = LoginInfo.CurrentUser.data;
                string url      = Resources.Server + Resources.OnlineStudentListUrl;
                string data     = JsonConvert.SerializeObject(sessionData);
                string response = HttpUitls.POST(url, data);
                //MessageBox.Show(response);

                OkeResult <SessionData <List <CourseRecordData> > > okeResult2 = JsonConvert.DeserializeObject <OkeResult <SessionData <List <CourseRecordData> > > >(response);
                if (okeResult2.success)
                {
                    AddAlter("成功查询学生名单", CxFlatAlertBox.AlertType.Success);

                    #region 把接受到的数据展示在datagridview
                    List <CourseRecordData> Alllist = okeResult2.data.data;
                    //MessageBox.Show(Alllist.ToString());
                    int[] scorelist = Alllist.Select(x => x.score).ToArray();                           //读出score列

                    List <CourseRecord> CAlllist        = Alllist.Select(x => x.courseRecord).ToList(); //读出CourseRecord的内容
                    List <DateTime>     OnlineTimelist  = CAlllist.Select(x => x.onlineTime).ToList();  //读出在线时间
                    List <DateTime>     OfflineTimelist = CAlllist.Select(x => x.offlineTime).ToList(); //读出下线时间

                    List <Student> SAlllist = CAlllist.Select(x => x.student).ToList();                 //读出student的内容

                    #region 把上面读出来的数据加入datatable
                    System.Data.DataTable studentinfo = new System.Data.DataTable();
                    studentinfo = (System.Data.DataTable)ToDataTable(SAlllist);
                    studentinfo.Columns.Add("分数", typeof(string));     //把分数列添加进datatable
                    studentinfo.Columns.Add("上线时间", typeof(DateTime)); //把上线时间添加进datatable
                    studentinfo.Columns.Add("下线时间", typeof(DateTime)); //把下线时间添加进datatable

                    int j = 0;
                    foreach (DataRow dr in studentinfo.Rows)
                    {
                        dr["分数"]   = scorelist[j];
                        dr["上线时间"] = OnlineTimelist[j];
                        dr["下线时间"] = OfflineTimelist[j];
                        j++;
                    }
                    #endregion

                    #region 移除无关信息
                    studentinfo.Columns.Remove("studentId"); //把学生Id移除
                    studentinfo.Columns.Remove("user");      //把用户名、密码等信息移除
                    #endregion


                    #region 替换列名
                    studentinfo.Columns["studentNumber"].ColumnName = "学号";
                    studentinfo.Columns["studentName"].ColumnName   = "学生姓名";
                    studentinfo.Columns["studentClass"].ColumnName  = "行政班";
                    #endregion

                    studentdataview.DataSource = studentinfo;
                    #endregion
                }
                else
                {
                    AddAlter("查询学生名单出错,请重新选择课程", CxFlatAlertBox.AlertType.Error);
                }
            }
            catch (Exception)
            {
                AddAlter(Resources.ExceptionTip, CxFlatAlertBox.AlertType.Error);//弹出提示
            }
            #endregion
        }