public static bool SuaKyThiThat(COMPETION cEdit)
        {
            bool rt = true;

            using (var httn = new DBTracNghiemDataContext())
            {
                var rs = httn.COMPETIONs.Where(s => (s.id == cEdit.id && s.subtractID == cEdit.subtractID)).SingleOrDefault();
                if (rs != null)
                {
                    rs.testTimeToLive = cEdit.testTimeToLive;
                    rs.testDateBegin  = cEdit.testDateBegin;
                    rs.gradeid        = cEdit.gradeid;
                    rs.idtest         = cEdit.idtest;
                    try
                    {
                        httn.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        rt = false;
                    }
                }
                else
                {
                    rt = false;
                }
            }
            return(rt);
        }
        private void DgvCompetition_SelectionChanged(object sender, EventArgs e)
        {
            int ri = dgvCompetition.CurrentRow.Index;

            lbMH.Text = dgvCompetition[1, ri].Value.ToString();
            cNew      = new COMPETION()
            {
                id             = Convert.ToInt32(dgvCompetition[0, ri].Value),
                subtractID     = dgvCompetition[1, ri].Value.ToString(),
                testDateBegin  = Convert.ToDateTime(dgvCompetition[2, ri].Value),
                testTimeToLive = Convert.ToInt32(dgvCompetition[3, ri].Value),
                gradeid        = Convert.ToInt32(dgvCompetition[4, ri].Value),
                idtest         = Convert.ToInt32(dgvCompetition[5, ri].Value)
            };
            var rs = TracNghiem.LayDanhSachKetQua();
            var rt = rs.Where(s => s.idCom == Convert.ToInt32(dgvCompetition[0, ri].Value) && s.idStudent == temp.id).Select(s => s).SingleOrDefault();

            if (rt != null)
            {
                lbScore.Text = string.Format("{0}", Math.Round((double)rt.score, 2));
            }
            else
            {
                lbScore.Text = "Chưa có";
            }
        }
Exemple #3
0
 public frmThiThat(COMPETION p, STUDENT t)
 {
     InitializeComponent();
     pemp                        = p;
     temp                        = t;
     timerTest.Tick             += TimerTest_Tick;
     txtCurrentQuiz.TextChanged += TxtCurrentQuiz_TextChanged;
 }
        public static bool ThemKyThiThat(COMPETION cNew)
        {
            bool rt = true;

            using (var httn = new DBTracNghiemDataContext())
            {
                httn.COMPETIONs.InsertOnSubmit(cNew);
                try
                {
                    httn.SubmitChanges();
                }
                catch (Exception)
                {
                    rt = false;
                }
            }
            return(rt);
        }
Exemple #5
0
        private void btnCreateCompetition_Click(object sender, EventArgs e)
        {
            //lấy thông tin từ các textbox đề tạo 1 kỳ thi mới
            //kiểm tra text box giờ thi
            //tạo 1 cái date time mới.
            DateTime  dt   = new DateTime(dtDateBegin.Value.Year, dtDateBegin.Value.Month, dtDateBegin.Value.Day, inputHour.Value, inputMin.Value, 0);
            COMPETION cNew = new COMPETION();

            cNew.id             = Convert.ToInt32(txtidtest.Text);
            cNew.subtractID     = cbSubtractCom.SelectedValue.ToString();
            cNew.testDateBegin  = dt;
            cNew.testTimeToLive = intTTL.Value;
            cNew.gradeid        = Convert.ToInt32(cbgradeid.SelectedValue);
            cNew.idtest         = Convert.ToInt32(cbDe.SelectedValue);
            //gọi hàm thêm kỳ thi
            TracNghiem.ThemKyThiThat(cNew);
            OnLoad(e);
        }
Exemple #6
0
        private void btnEditCompetion_Click(object sender, EventArgs e)
        {
            int rowindex = dgvCompetition.CurrentRow.Index;
            int code     = Convert.ToInt32(dgvCompetition[0, rowindex].Value);
            //tạo một cái time mới
            DateTime  dt    = new DateTime(dtDateBegin.Value.Year, dtDateBegin.Value.Month, dtDateBegin.Value.Day, inputHour.Value, inputMin.Value, 0);
            COMPETION cEdit = new COMPETION()
            {
                id             = code,
                subtractID     = cbSubtractCom.SelectedValue.ToString(),
                testDateBegin  = dt,
                testTimeToLive = intTTL.Value,
                gradeid        = Convert.ToInt32(cbgradeid.SelectedValue),
                idtest         = Convert.ToInt32(cbDe.SelectedValue)
            };

            TracNghiem.SuaKyThiThat(cEdit);
            OnLoad(e);
        }