コード例 #1
0
        public JObject StartTest([FromBody] IntegerInput user)
        {
            MainDBContext mainDBContext  = new MainDBContext();
            var           countQuestions = mainDBContext.Questions.Count();
            var           prevTest       = mainDBContext.Statisics.Where(x => x.UserID == user.Value)
                                           .Select(x => x.TestResult).FirstOrDefault(x => x.UserAnswers.Count() != countQuestions);

            if (prevTest != null)
            {
                return(JObject.Parse(JsonConvert.SerializeObject(new StartActionNet {
                    IsStartPrev = true, PrevID = prevTest.ID, ResultCode = ResultCode.Success, WorkID = user.Value
                })));
            }
            var testResult = new TestResult {
                DateTime = DateTime.Now
            };
            var statistics = new Statisics {
                TestResult = testResult, UserID = user.Value
            };

            mainDBContext.Entry(testResult).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            mainDBContext.Entry(statistics).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            mainDBContext.SaveChanges();
            return(JObject.Parse(JsonConvert.SerializeObject(new StartActionNet {
                IsStartPrev = false, WorkID = user.Value, ResultCode = ResultCode.Success, PrevID = testResult.ID
            })));
        }
コード例 #2
0
        public void HienThi(IntegerInput itiSoNguoiToiDa,

                            IntegerInput itiTuoiNguoiDan_Min,
                            IntegerInput itiTuoiNguoiDan_Max,
                            IntegerInput itiTuoiNhanVien_Min,
                            IntegerInput itiTuoiNhanVien_Max
                            )
        {
            BindingSource bS = new BindingSource();

            bS.DataSource = m_QuyDinhData.LayDsQuyDinh();

            DataTable DT = m_QuyDinhData.LayDsQuyDinh();

            int SoNguoiToiDa = Convert.ToInt32(DT.Rows[0]["SoNguoiToiDa"]);


            itiTuoiNguoiDan_Min.DataBindings.Clear();
            itiTuoiNguoiDan_Min.DataBindings.Add("Value", bS, "TuoiNguoiDan_Min");


            itiTuoiNguoiDan_Max.DataBindings.Clear();
            itiTuoiNguoiDan_Max.DataBindings.Add("Value", bS, "TuoiNguoiDan_Max");

            itiTuoiNhanVien_Min.DataBindings.Clear();
            itiTuoiNhanVien_Min.DataBindings.Add("Value", bS, "TuoiNhanVien_Min");

            itiTuoiNhanVien_Max.DataBindings.Clear();
            itiTuoiNhanVien_Max.DataBindings.Add("Value", bS, "TuoiNhanVien_Max");
        }
コード例 #3
0
        /// <summary>
        /// 给右拉近赋值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Obstacle_ValueChange(object sender, EventArgs e)
        {
            IntegerInput txt = (IntegerInput)sender;

            switch (txt.Name)
            {
            case "dbi_LeftObstacle1":
                dbi_RightObstacle1.Value = txt.Value;
                break;

            case "dbi_LeftObstacle2":
                dbi_RightObstacle2.Value = txt.Value;
                break;

            case "dbi_LeftObstacle3":
                dbi_RightObstacle3.Value = txt.Value;
                break;

            case "dbi_LeftObstacle4":
                dbi_RightObstacle4.Value = txt.Value;
                break;

            case "dbi_LeftObstacle5":
                dbi_RightObstacle5.Value = txt.Value;
                break;

            case "dbi_LeftObstacle6":
                dbi_RightObstacle6.Value = txt.Value;
                break;

            default:
                break;
            }
        }
コード例 #4
0
        public void HienThi(DataGridViewX dGV,
                            BindingNavigator bN,
                            TextBoxX txtMaLop,
                            TextBoxX txtTenLop,
                            ComboBoxEx cmbKhoiLop,
                            ComboBoxEx cmbNamHoc,
                            IntegerInput iniSiSo,
                            ComboBoxEx cmbGiaoVien)
        {
            BindingSource bS = new BindingSource();

            bS.DataSource = m_LopData.LayDsLop();

            bN.BindingSource = bS;
            dGV.DataSource   = bS;

            txtMaLop.DataBindings.Clear();
            txtMaLop.DataBindings.Add("Text", bS, "MaLop");

            txtTenLop.DataBindings.Clear();
            txtTenLop.DataBindings.Add("Text", bS, "TenLop");

            cmbKhoiLop.DataBindings.Clear();
            cmbKhoiLop.DataBindings.Add("SelectedValue", bS, "MaKhoiLop");

            cmbNamHoc.DataBindings.Clear();
            cmbNamHoc.DataBindings.Add("SelectedValue", bS, "MaNamHoc");

            iniSiSo.DataBindings.Clear();
            iniSiSo.DataBindings.Add("Text", bS, "SiSo");

            cmbGiaoVien.DataBindings.Clear();
            cmbGiaoVien.DataBindings.Add("SelectedValue", bS, "MaGiaoVien");
        }
コード例 #5
0
ファイル: FunctionEditForm.cs プロジェクト: weimingtom/pap2
        /// <summary>
        /// 选择确定
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void buttonX1_Click(object sender, EventArgs e)
        {
            Node node = advTree1.SelectedNode;

            if (node != null && node.Level == 1)
            {
                string arguments = "";
                for (int i = 0; i < 3; i++)
                {
                    IntegerInput input = inputControlList[i];
                    if (input.Enabled)
                    {
                        arguments += string.Format("{0},", input.Value);
                    }
                }
                arguments = arguments.TrimEnd(new char[] { ',' });
                string functionName = node.Text;
                value        = string.Format("{0}({1})", functionName, arguments);
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("请先选择要编辑的函数!", "函数参数编辑",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #6
0
ファイル: InfoEditor.cs プロジェクト: xnum/hasuite
 private void LoadOptionalInt(int?source, IntegerInput target, CheckBoxX checkBox)
 {
     checkBox.Checked = source != null;
     if (source != null)
     {
         target.Value = source.Value;
     }
 }
コード例 #7
0
ファイル: HomeController.cs プロジェクト: ElizAst/electrotest
        public JObject GetStatistics([FromBody] IntegerInput user)
        {
            MainDBContext mainDBContext = new MainDBContext();
            var           testResults   = mainDBContext.Statisics.Where(x => x.UserID == user.Value).Select(x => x.TestResultID);
            var           tmpTestRes    = new List <int>();

            foreach (var testResult in testResults)
            {
                var ticket = mainDBContext.UserAnswers.Where(x => x.TestResultID == testResult)
                             .Select(x => x.Question.TicketNum).FirstOrDefault();
                var userCounts = mainDBContext.UserAnswers.Where(x => x.TestResultID == testResult).Count();
                if (mainDBContext.Questions.Where(x => x.TicketNum == ticket).Count() == userCounts)
                {
                    tmpTestRes.Add(testResult);
                }
            }
            testResults = tmpTestRes.AsQueryable();

            var statisticsList = mainDBContext.TestResults.Where(x => testResults.Contains(x.ID))
                                 .Select(x => new StatisticResult
            {
                ResultCode = ResultCode.Success,
                WorkID     = x.ID,
                DateTime   = x.DateTime.ToLongDateString()
            }).ToList();

            for (int i = 0; i < statisticsList.Count; i++)
            {
                statisticsList[i].Ticket = mainDBContext.UserAnswers.Where(x => x.TestResultID == statisticsList[i].WorkID)
                                           .Select(x => x.Question.TicketNum).FirstOrDefault();
                int ticketCount = mainDBContext.Questions.Where(x => x.TicketNum == statisticsList[i].Ticket).Count();
                var userAnswers = mainDBContext.UserAnswers.Where(x => x.TestResultID == statisticsList[i].WorkID);
                int usersRight  = 0;
                foreach (var userAnswer in userAnswers)
                {
                    if (mainDBContext.RightQuestions.FirstOrDefault(x => x.AnswerID == userAnswer.AnswerID &&
                                                                    x.QuestionID == userAnswer.QuestionID) != null)
                    {
                        usersRight++;
                    }
                }
                if (usersRight == 0)
                {
                    statisticsList[i].Result = 0;
                }
                else
                {
                    statisticsList[i].Result = usersRight * 100 / ticketCount;
                }
            }
            return(JObject.Parse(JsonConvert.SerializeObject(new StatisticsList
            {
                ResultCode = statisticsList.Count() > 0 ? ResultCode.Success : ResultCode.Error,
                WorkID = user.Value,
                staticticResults = statisticsList.ToList()
            })));
        }
コード例 #8
0
 private void LoadOptionalInt(int?value, CheckBoxX cbx, IntegerInput box)
 {
     if (value == null)
     {
         cbx.Checked = false;
     }
     else
     {
         cbx.Checked = true; box.Value = (int)value;
     }
 }
コード例 #9
0
 private int?GetOptionalInt(CheckBoxX cbx, IntegerInput box)
 {
     if (cbx.Checked)
     {
         return(box.Value);
     }
     else
     {
         return(null);
     }
 }
コード例 #10
0
        private Control AddIntegerInputControl(IUserOption option)
        {
            IntegerInput tbOptionInput = new IntegerInput();

            tbOptionInput.Text = option.Value != null?option.Value.ToString() : "";

            tbOptionInput.ValueChanged += (sender, e) => OnVirtualPropertyValueChanged(sender as Control);
            tbOptionInput.ForeColor     = Color.Black;

            return(tbOptionInput);
        }
コード例 #11
0
        public JObject GetStatistics([FromBody] IntegerInput user)
        {
            MainDBContext          mainDBContext    = new MainDBContext();
            List <StatisticResult> statisticResults = new List <StatisticResult>();
            var testResults         = mainDBContext.Statisics.Where(x => x.UserID == user.Value).Select(x => x.TestResult).ToList();
            var questionsCount      = mainDBContext.Questions.Count();
            var groupResults        = mainDBContext.FinalQueries.GroupBy(x => x.Ticket);
            var testInterpretations = mainDBContext.TestInterpretations.GroupBy(x => x.Type);

            foreach (var testResult in testResults)
            {
                var usersAnswer = mainDBContext.TestResultUsers.Where(x => x.TestResult == testResult)
                                  .Select(x => x.TestFinal).ToList();
                if (usersAnswer.Count > 0)
                {
                    var userGroups = usersAnswer.GroupBy(x => x.Type).ToDictionary(x => x.Key, x => x.Sum(y => y.Mark));
                    foreach (var testInter in testInterpretations)
                    {
                        if (!userGroups.TryGetValue(testInter.Key, out var val))
                        {
                            userGroups.Add(testInter.Key, 0);
                        }
                    }
                    var testPresent = mainDBContext.TestInterpretations.Where(x => userGroups.Keys.Contains(x.Type) &&
                                                                              userGroups[x.Type] > x.MarkMin && userGroups[x.Type] <= x.MarkMax).ToList();
                    string res = string.Empty;
                    foreach (var group in groupResults)
                    {
                        if (group.Select(x => x.TestPresentation).ToList().Compare(testPresent.Select(x => x.ID).ToList()))
                        {
                            res += group.FirstOrDefault().Result;
                        }
                    }
                    if (!string.IsNullOrEmpty(res))
                    {
                        statisticResults.Add(new StatisticResult
                        {
                            DateTime   = testResult.DateTime.ToShortDateString(),
                            Result     = res,
                            ResultCode = ResultCode.Success,
                            WorkID     = testResult.ID
                        });
                    }
                }
            }


            return(JObject.Parse(JsonConvert.SerializeObject(new StatisticsList
            {
                ResultCode = statisticResults.Count() > 0 ? ResultCode.Success : ResultCode.Error,
                WorkID = user.Value,
                staticticResults = statisticResults
            })));
        }
コード例 #12
0
ファイル: PortalInstanceEditor.cs プロジェクト: xnum/hasuite
 private void SetOptionalInt(int?value, CheckBoxX enabler, IntegerInput input)
 {
     if (value == null)
     {
         enabler.Checked = false;
     }
     else
     {
         enabler.Checked = true; input.Value = (int)value;
     }
 }
コード例 #13
0
        private void CreateValue(List <Node> re)
        {
            var value = new Node();

            value.Text               = "Value";
            valueInput               = new IntegerInput();
            valueInput.Value         = Value;
            valueInput.ValueChanged += IntegerInput_ValueChanged;
            value.Nodes.Add(CreateControl("Value", "Value", valueInput));
            value.Expanded = true;
            re.Add(value);
        }
コード例 #14
0
ファイル: HomeController.cs プロジェクト: ElizAst/electrotest
        public JObject ProfileUserInfo([FromBody] IntegerInput id)
        {
            MainDBContext mainDBContext = new MainDBContext();
            var           user          = mainDBContext.Users.Find(id.Value);

            return(JObject.Parse(JsonConvert.SerializeObject(new UserProfileNet
            {
                Nickname = user.Nickname,
                ResultCode = ResultCode.Success,
                WorkID = user.ID
            })));
        }
コード例 #15
0
        public JObject GetQuestions([FromBody] IntegerInput id)
        {
            MainDBContext mainDBContext = new MainDBContext();
            var           questions     = mainDBContext.UserAnswers.Where(x => x.TestResultID == id.Value).ToList();
            var           quesionsList  = mainDBContext.Questions.ToList();

            return(JObject.Parse(JsonConvert.SerializeObject(new QuestionListActionNet
            {
                ResultCode = quesionsList.Count > 0 ? ResultCode.Error : ResultCode.Success,
                WorkID = id.Value,
                QuestionActionNets = quesionsList.Select(x => GetQuestionActionNet(x, mainDBContext, questions)).ToList()
            })));
        }
コード例 #16
0
ファイル: HomeController.cs プロジェクト: ElizAst/electrotest
        public JObject StartTest([FromBody] IntegerInput user)
        {
            MainDBContext mainDBContext           = new MainDBContext();
            var           countOfQuestionInTicket = mainDBContext.Questions.GroupBy(x => x.TicketNum).Select(x => new { Ticket = x.Key, Count = x.Count() });
            var           usersAnswerAll          = mainDBContext.Statisics.Where(x => x.UserID == user.Value).Select(x => x.TestResult);

            foreach (var userAnswer in usersAnswerAll)
            {
                var count = mainDBContext.UserAnswers.Where(x => x.TestResultID == userAnswer.ID).Select(x => x.Question);
                if (count.Count() > 0)
                {
                    var type = count.First().TicketNum;
                    if (count.Count() < countOfQuestionInTicket.FirstOrDefault(x => x.Ticket == type).Count)
                    {
                        return(JObject.Parse(JsonConvert.SerializeObject(new StartActionNet
                        {
                            IsStartPrev = true,
                            PrevID = userAnswer.ID,
                            ResultCode = ResultCode.Success,
                            WorkID = user.Value
                        })));
                    }
                }
                else
                {
                    return(JObject.Parse(JsonConvert.SerializeObject(new StartActionNet
                    {
                        IsStartPrev = true,
                        PrevID = userAnswer.ID,
                        ResultCode = ResultCode.Success,
                        WorkID = user.Value
                    })));
                }
            }
            var testResult = new TestResult {
                DateTime = DateTime.Now
            };
            var statistics = new Statisics {
                TestResult = testResult, UserID = user.Value
            };

            mainDBContext.Entry(testResult).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            mainDBContext.Entry(statistics).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            mainDBContext.SaveChanges();
            return(JObject.Parse(JsonConvert.SerializeObject(new StartActionNet {
                IsStartPrev = false, WorkID = user.Value, ResultCode = ResultCode.Success, PrevID = testResult.ID
            })));
        }
コード例 #17
0
        public void HienThi(IntegerInput txtSiSoCanDuoi,
                            IntegerInput txtSiSoCanTren,
                            IntegerInput txtDoTuoiCanDuoi,
                            IntegerInput txtDoTuoiCanTren,
                            CheckBoxX ckbThang10,
                            CheckBoxX ckbThang100,
                            TextBoxX txtTenTruong,
                            TextBoxX txtDiaChiTruong)
        {
            BindingSource bS = new BindingSource();

            bS.DataSource = m_QuyDinhData.LayDsQuyDinh();

            DataTable dT        = m_QuyDinhData.LayDsQuyDinh();
            int       thangDiem = Convert.ToInt32(dT.Rows[0]["ThangDiem"]);

            if (thangDiem == 10)
            {
                ckbThang10.Checked = true;
            }
            else
            {
                ckbThang100.Checked = true;
            }

            txtSiSoCanDuoi.DataBindings.Clear();
            txtSiSoCanDuoi.DataBindings.Add("Value", bS, "SiSoCanDuoi");

            txtSiSoCanTren.DataBindings.Clear();
            txtSiSoCanTren.DataBindings.Add("Value", bS, "SiSoCanTren");

            txtDoTuoiCanDuoi.DataBindings.Clear();
            txtDoTuoiCanDuoi.DataBindings.Add("Value", bS, "TuoiCanDuoi");

            txtDoTuoiCanTren.DataBindings.Clear();
            txtDoTuoiCanTren.DataBindings.Add("Value", bS, "TuoiCanTren");

            txtTenTruong.DataBindings.Clear();
            txtTenTruong.DataBindings.Add("Text", bS, "TenTruong");

            txtDiaChiTruong.DataBindings.Clear();
            txtDiaChiTruong.DataBindings.Add("Text", bS, "DiaChiTruong");
        }
コード例 #18
0
        void RecycleToolStripMenuItemClick(object sender, EventArgs e)
        {
            var item   = (ItemData)ItemsListView.SelectedItems[0].Tag;
            int amount = IntegerInput.ShowDialog(1, "How many?", item.Count);

            if (amount > 0)
            {
                var resp = RecycleItems(client, item, amount);
                if (resp)
                {
                    item.Count -= amount;
                    ItemsListView.SelectedItems[0].SubItems[1].Text = "" + item.Count;
                }
                else
                {
                    MessageBox.Show(th.TS(" recycle failed!"), th.TS("Recycle Status"), MessageBoxButtons.OK);
                }
            }
        }
コード例 #19
0
ファイル: Util.cs プロジェクト: ischoolinc/PSEvaluation
        public static void SetSemesterDefaultItems(IntegerInput intSchoolYear, IntegerInput intSemester)
        {
            try
            {
                int schoolyear = int.Parse(School.DefaultSchoolYear);
                int semester   = int.Parse(School.DefaultSemester);

                intSchoolYear.MaxValue = schoolyear + 20;
                intSchoolYear.MinValue = schoolyear - 20;
                intSchoolYear.Value    = schoolyear;

                intSemester.MaxValue = 2;
                intSemester.MinValue = 1;
                intSemester.Value    = semester;
            }
            catch (Exception)
            {
                MsgBox.Show("讀取學期資訊錯誤,請確定網路連線正常後再試一次。");
            }
        }
コード例 #20
0
        public void HienThi(IntegerInput txtSiSoToiDa,
                            IntegerInput txtTuoiToiThieu,
                            IntegerInput txtTuoiToiDa,
                            TextBoxX txtDiemToiThieu,
                            TextBoxX txtDiemToiDa,
                            TextBoxX txtDiemDat,
                            TextBoxX txtDiemDatMon)
        {
            BindingSource bS = new BindingSource();

            bS.DataSource = m_QuyDinhData.LayDsQuyDinh();

            DataTable dT = m_QuyDinhData.LayDsQuyDinh();

            foreach (DataRow row in dT.Rows)
            {
                txtSiSoToiDa.DataBindings.Clear();
                txtSiSoToiDa.DataBindings.Add("Value", bS, "GiaTri");

                txtTuoiToiThieu.DataBindings.Clear();
                txtTuoiToiThieu.DataBindings.Add("Value", bS, "GiaTri");

                if (row["TenThamSo"].ToString() == "TuoiToiDa")
                {
                    txtTuoiToiDa.DataBindings.Clear();
                    //  txtTuoiToiDa.DataBindings.Add("Value", bS, "GiaTri");
                }

                txtDiemToiThieu.DataBindings.Clear();
                txtDiemToiThieu.DataBindings.Add("Text", bS, "GiaTri");

                txtDiemToiDa.DataBindings.Clear();
                txtDiemToiDa.DataBindings.Add("Text", bS, "GiaTri");

                txtDiemDat.DataBindings.Clear();
                txtDiemDat.DataBindings.Add("Text", bS, "GiaTri");

                txtDiemDatMon.DataBindings.Clear();
                txtDiemDatMon.DataBindings.Add("Text", bS, "GiaTri");
            }
        }
コード例 #21
0
        public void loadQueryControl(List <BaseReportField> fieldList)
        {
            this.panelQueryControl.Controls.Clear();
            List <BaseReportField> _fieldList = fieldList.FindAll(x => x.UiType > 0).OrderBy(x => x.SortId).ToList();

            int maxheight = 0;;

            for (int i = 0; i < _fieldList.Count; i++)
            {
                Label lab = new Label();
                lab.Text      = _fieldList[i].Name;
                lab.TextAlign = ContentAlignment.MiddleRight;
                lab.Width     = 100;


                Control txt = null;
                if (_fieldList[i].UiType == 1)
                {
                    txt = new TextBox();
                }
                else if (_fieldList[i].UiType == 2)
                {
                    txt = new DateTimePicker();
                }
                else if (_fieldList[i].UiType == 3)
                {
                    txt = new IntegerInput();
                }
                else if (_fieldList[i].UiType == 4)
                {
                    txt = new DoubleInput();
                }
                else if (_fieldList[i].UiType == 5)
                {
                    txt = new ComboBox();
                    int unitId = 0;
                    if (_fieldList[i].DataUnitId == null || _fieldList[i].DataUnitId == "")
                    {
                        unitId = -1;
                    }
                    else
                    {
                        unitId = Convert.ToInt32(_fieldList[i].DataUnitId);
                    }
                    ((ComboBox)txt).DataSource    = InvokeController("GetComboData", unitId, _fieldList[i].DynamicSQL);
                    ((ComboBox)txt).DisplayMember = "name";
                    ((ComboBox)txt).ValueMember   = "code";
                }
                else if (_fieldList[i].UiType == 6)
                {
                    txt = new CheckBox();
                }
                txt.Width = 200;
                txt.Tag   = _fieldList[i];

                if (i % 2 == 0)
                {
                    lab.Location = new Point(0, 15 * i + 5);
                    txt.Location = new Point(100, 15 * i + 5);
                }
                else
                {
                    lab.Location = new Point(300, 15 * (i - 1) + 5);
                    txt.Location = new Point(400, 15 * (i - 1) + 5);
                }

                maxheight = 15 * i + 30;
                panelQueryControl.Controls.Add(lab);
                panelQueryControl.Controls.Add(txt);
            }
            splitContainer2.SplitterDistance = maxheight;
            panelQueryControl.Refresh();
        }
コード例 #22
0
ファイル: PortalInstanceEditor.cs プロジェクト: xnum/hasuite
 private int?GetOptionalInt(CheckBoxX enabler, IntegerInput input)
 {
     return(enabler.Checked ? (int?)input.Value : null);
 }
コード例 #23
0
ファイル: InfoEditor.cs プロジェクト: xnum/hasuite
 private int?GetOptionalInt(IntegerInput textbox, CheckBoxX checkBox)
 {
     return(checkBox.Checked ? (int?)textbox.Value : null);
 }
コード例 #24
0
 private void Int_PreviewText(object sender, TextCompositionEventArgs e)
 {
     IntegerInput.PreviewTextInputHandler(sender, e);
 }
コード例 #25
0
 private void Int_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     IntegerInput.PastingHandler(sender, e);
 }
コード例 #26
0
 private void ParticipantsTextBox_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     IntegerInput.PastingHandler(sender, e);
 }
コード例 #27
0
 private void ParticipantsTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     IntegerInput.PreviewTextInputHandler(sender, e);
 }