Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
        public ActionResult Create([Bind(Include = "ID,Name,DOB")] TEST tEST)
        {
            if (ModelState.IsValid)
            {
                db.TESTs.Add(tEST);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tEST));
        }
Esempio n. 2
0
        public void TestEnumDescription()
        {
            TEST   t1    = TEST.ENUM1;
            string desc1 = t1.GetEnumDescription();

            NUnit.Framework.Assert.AreEqual("ENUM1", desc1);

            TEST   t2    = TEST.ENUM2;
            string desc2 = t2.GetEnumDescription();

            NUnit.Framework.Assert.AreEqual("ENUM2", desc2);
        }
Esempio n. 3
0
        static void Main()
        {
            SAMPLE s = () => "Hello";

            Console.WriteLine("result={0}", s());

            int  a = 3;
            int  b = 7;
            TEST t = (c, d) => c + d;

            Console.WriteLine("add{0}+{1}={2}", a, b, t(a, b));
        }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "ID_TEST,NAZWA,CZAS_START,CZAS_STOP,KLUCZ,ID_BAZA,ID_UZYTKOWNIKA")] TEST tEST)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tEST).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_BAZA        = new SelectList(db.BAZA_DANYCH, "ID_BAZA", "TYP", tEST.ID_BAZA);
     ViewBag.ID_UZYTKOWNIKA = new SelectList(db.UZYTKOWNIK, "ID_UZYTKOWNIKA", "IMIE", tEST.ID_UZYTKOWNIKA);
     return(View(tEST));
 }
Esempio n. 5
0
    public void ReaderFuction(byte[] data)
    {
        PooledNetworkReader pooledNetworkReader = NetworkReaderPool.GetReader(data);
        int  value  = pooledNetworkReader.Read <int>();
        bool value2 = pooledNetworkReader.Read <bool>();

        Debug.LogWarning("ABCD " + value);

        TEST.OnDataReceive(value, value2);

        pooledNetworkReader.Dispose();
    }
Esempio n. 6
0
        private void btnDeleteTest_Click(object sender, EventArgs e)
        {
            TEST ts = new TEST()
            {
                id         = Convert.ToInt32(cbTest.SelectedValue),
                subtractID = cbMH.SelectedValue.ToString()
            };


            TracNghiem.XoaBoDeThi(ts);
            TracNghiem.XoaDeThi(ts);
            OnLoad(e);
        }
        public ActionResult AddT([Bind(Include = "ID_TEST,NAZWA,CZAS_START,CZAS_STOP,KLUCZ,ID_BAZA,ID_UZYTKOWNIKA")] TEST tEST)
        {
            tEST.ID_UZYTKOWNIKA = ID_USER;
            DateTime DaneNOW       = DateTime.Now;
            DateTime DaneDataStart = Convert.ToDateTime(tEST.CZAS_START);
            DateTime DaneDataStop  = Convert.ToDateTime(tEST.CZAS_STOP);
            int      DaneCheck;



            if (ModelState.IsValid)
            {
                if (tEST.CZAS_START != null)
                {
                    DaneCheck = DaneDataStart.CompareTo(DaneNOW);
                    if (DaneCheck == -1)
                    {
                        ViewBag.ID_BAZA = new SelectList(db.BAZA_DANYCH.Where(m => m.ID_UZYTKOWNIKA == ID_USER), "ID_BAZA", "NAZWA");
                        ModelState.AddModelError("CZAS_START", "Data mineła!!");
                        return(View(tEST));
                    }

                    if (tEST.CZAS_STOP != null)
                    {
                        DaneCheck = DaneDataStart.CompareTo(DaneDataStop);
                        if (DaneCheck == 1)
                        {
                            ModelState.AddModelError("CZAS_STOP", "Błędna data!!");
                            ViewBag.ID_BAZA = new SelectList(db.BAZA_DANYCH.Where(m => m.ID_UZYTKOWNIKA == ID_USER), "ID_BAZA", "NAZWA");
                            return(View(tEST));
                        }
                    }
                }
                else
                {
                    tEST.CZAS_START = DaneNOW.ToString();
                }



                tEST.KLUCZ = KeyGenerate();
                db.TEST.Add(tEST);
                db.SaveChanges();
                NRTest = tEST.ID_TEST;
                return(RedirectToAction("AddP"));
            }

            ViewBag.ID_BAZA = new SelectList(db.BAZA_DANYCH, "ID_BAZA", "NAZWA", tEST.ID_BAZA);
            return(View(tEST));
        }
Esempio n. 8
0
        //post method
        public ActionResult CreateTestDB(TEST test)
        {
            TestService testService = new TestService();
            PostService postService = new PostService();
            DateTime    postTime    = postService.findById(test.POST_ID.ToString()).END_DATE;

            //startime early than post created time
            if (DateTime.Compare(postTime, test.START_TIME) < 0)
            {
                //endtime late than start time
                if (DateTime.Compare(test.START_TIME, test.END_TIME) < 0)
                {
                    //starttime early than now
                    if (DateTime.Compare(test.START_TIME, DateTime.Now) < 0)
                    {
                        return(RedirectToAction("CreateTest", new { error = "Can't create a test with the start time has passed" }));
                    }
                    //check create test
                    else if (testService.create(test))
                    {
                        //create report
                        REPORT report = new REPORT()
                        {
                            CREATED = test.END_TIME, PERCENT_HIGH_SCORE = 0, PERCENT_MIDDLE_SCORE = 0, PERCENT_ATTEMPT = 0, PERCENT_FAST_FINISH = 0, PERCENT_HIGH_PART_1 = 0, PERCENT_HIGH_PART_2 = 0, PERCENT_HIGH_PART_3 = 0, PERCENT_MID_PART_1 = 0, PERCENT_MID_PART_2 = 0, PERCENT_MID_PART_3 = 0
                        };
                        ReportService reportService = new ReportService();
                        if (reportService.create(report))
                        {
                            return(RedirectToAction("ShowTests"));
                        }
                        else
                        {
                            return(RedirectToAction("CreateTest", new { error = "Can't Create Report. Please create again" }));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("CreateTest", new { error = "Missing Questions. Please create again" }));
                    }
                }
                else
                {
                    return(RedirectToAction("CreateTest", new { error = "The End Time must after the Start Time" }));
                }
            }
            else
            {
                return(RedirectToAction("CreateTest", new { error = "The Start time must after the Post end time" }));
            }
        }
Esempio n. 9
0
        //post method
        public ActionResult UpdateTestDB(TEST test)
        {
            TestService testService = new TestService();

            if ((DateTime.Compare(test.START_TIME, test.END_TIME) < 0) && (DateTime.Compare(DateTime.Now, test.START_TIME) < 0))
            {
                if (testService.update(test))
                {
                    return(RedirectToAction("ShowTests", "Manager"));
                }
            }

            return(RedirectToAction("ShowTests", "Manager"));
        }
Esempio n. 10
0
        private void Button_Click_1(object sender, RoutedEventArgs e)//доб. раздел
        {
            Model1 db = new Model1();

            var TEST = db.TEST;

            if (tbText.Text != "")
            {
                foreach (var t in TEST)
                {
                    if (t.TESTTITLE.Equals(tbText.Text))
                    {
                        this.ShowMessageAsync("Error", "This test already exists");
                        return;
                    }
                }
                int idTest;
                if (db.TEST.Count() != 0)
                {
                    idTest = db.TEST.Max(l => l.TESTID) + 1;
                }
                else
                {
                    idTest = 1;
                }
                var row = new TEST
                {
                    TESTTITLE  = tbText.Text,
                    TESTNOTE   = tbNote.Text,
                    TESTCATERY = tbCatery.Text,
                    TESTID     = idTest
                };
                try
                {
                    db.TEST.Add(row);
                    db.SaveChanges();
                    this.ShowMessageAsync("Success", "Successful saved");
                    this.Close();
                }
                catch (Exception er)
                {
                    this.ShowMessageAsync("Error", er.Message + "Inner:" + er.InnerException);
                    return;
                }
            }
            else
            {
                this.ShowMessageAsync("Error", "Enter test text");
            }
        }
Esempio n. 11
0
        // GET: TEST/Details/ssss
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TEST tEST = db.TEST.Find(id);

            if (tEST == null)
            {
                return(HttpNotFound());
            }
            return(View(tEST));
        }
        public ActionResult EditT(int ID_Test)
        {
            NRTEST = ID_Test;


            TEST tEST = db.TEST.Find(ID_Test);

            ID_USER         = int.Parse("" + tEST.ID_UZYTKOWNIKA);
            ViewBag.ID_BAZA = new SelectList(db.BAZA_DANYCH.Where(m => m.ID_UZYTKOWNIKA == ID_USER), "ID_BAZA", "NAZWA");

            List <PYTANIE> pytanie = db.PYTANIE.Where(m => m.ID_TEST == ID_Test).ToList();

            ViewBag.Pytania = pytanie;
            return(View(tEST));
        }
Esempio n. 13
0
        /// <summary>
        /// 判断指定主键Id的记录是否存在——在IIS缓存或数据库中查找
        /// </summary>
        /// <param name="id">主键Id</param>
        /// <returns></returns>
        public bool Exist(int id)
        {
            if (id <= 0)
            {
                return(false);
            }

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                return(Exist(x => x.Id == id));
            }

            //从数据库中查找
            return(TEST.Exists(x => x.Id == id));
        }
Esempio n. 14
0
        /// <summary>
        /// 将TEST记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.TEST)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.TEST</returns>
        public DataAccess.Model.TEST Transform(TEST model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new DataAccess.Model.TEST
            {
                Id = model.Id,
                COL1 = model.COL1,
                COL2 = model.COL2,
                COL3 = model.COL3,
                COL4 = model.COL4,
            });
        }
Esempio n. 15
0
        public static void HandleData(byte[] data)
        {
            TEST strN = structFromBytes(data);

            Console.WriteLine("HANDLE DATA at SERVER");
            Console.WriteLine("struct size: " + Marshal.SizeOf(strN));
            Console.WriteLine("data size: " + data.Length);
            Console.WriteLine("message: " + strN.aString);
            Console.WriteLine("message size: " + strN.aString.Length);
            Console.WriteLine("----");
            Console.WriteLine("");

            var response = Encoding.ASCII.GetBytes(strN.aString);

            serverSocket.Send((new byte[] { HEADER_SERVER_RESPONSE }).Concat(response).ToArray(), response.Length + 1);
        }
Esempio n. 16
0
        // GET: TEST/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TEST tEST = db.TEST.Find(id);

            if (tEST == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ID_BAZA        = new SelectList(db.BAZA_DANYCH, "ID_BAZA", "TYP", tEST.ID_BAZA);
            ViewBag.ID_UZYTKOWNIKA = new SelectList(db.UZYTKOWNIK, "ID_UZYTKOWNIKA", "IMIE", tEST.ID_UZYTKOWNIKA);
            return(View(tEST));
        }
        public static bool ThemDeThi(TEST t)
        {
            bool rt = true;

            using (var httn = new DBTracNghiemDataContext())
            {
                httn.TESTs.InsertOnSubmit(t);
                try
                {
                    httn.SubmitChanges();
                }
                catch (Exception) {
                    rt = false;
                }
            }
            return(rt);
        }
Esempio n. 18
0
        public ActionResult CreateForGrid([DataSourceRequest] DataSourceRequest request, TestViewModel test)
        {
            if (ModelState.IsValid)
            {
                TEST entity = test.ToEntity(new TEST());
                try
                {
                    db.TESTS.Create(entity);
                    test.id = entity.ID;
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("TEST", ex.Message);
                }
            }

            return(Json(new[] { test }.ToDataSourceResult(request, ModelState)));
        }
Esempio n. 19
0
        public ActionResult Index()
        {
            TEST t = new TEST();

            t.test = new SelectList(
                new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Homeowner", Value = "value1"
                },
                new SelectListItem {
                    Text = "Contractor", Value = "value2"
                }
            }, "Value", "Text"
                );

            return(View(t));
        }
        public static bool XoaDeThi(TEST t)
        {
            bool rt = true;

            using (var httn = new DBTracNghiemDataContext())
            {
                var rs = httn.TESTs.Where(s => s.id == t.id && s.subtractID == t.subtractID);
                httn.TESTs.DeleteAllOnSubmit(rs);
                try
                {
                    httn.SubmitChanges();
                }
                catch (Exception)
                {
                    rt = false;
                }
            }
            return(rt);
        }
Esempio n. 21
0
        public AddTest(TEST t, List <string> type)
        {
            Id   = t.ID;
            Name = t.NAME_TEST;
            Type = type;

            List <QUESTION> quests = t.QUESTION.ToList();

            foreach (var i in quests)
            {
                Quest.Add(i.QUESTION1);
            }

            //  List<RESULT> results = t.RESULT.ToList();
            //foreach(var e in results)
            //{
            //    Restxt.Add(e.TEXT_RESULT);
            //}
        }
Esempio n. 22
0
 //Mail the APPROVED candidates
 public ActionResult Mail(int APPLY_ID, int TEST_ID)
 {
     try
     {
         ResultService resultService = new ResultService();
         RESULT        result        = new RESULT();
         result.APPLY_ID = APPLY_ID;
         result.TEST_ID  = TEST_ID;
         //create result before mail
         resultService.create(result);
     }
     catch (Exception)
     {
     }
     try
     {
         //Mail
         AptechSem3.Service.MailService mailService  = new Service.MailService();
         ApplicationService             applyService = new ApplicationService();
         JOB_APPLICATION apply = applyService.findById(APPLY_ID.ToString());
         AptechSem3.Service.UsrService userService = new AptechSem3.Service.UsrService();
         USR         usr         = userService.findUsrByApplyID(APPLY_ID);
         TestService testService = new TestService();
         TEST        test        = testService.findById(TEST_ID.ToString());
         //message
         String message = "<p>Dear " + apply.NAME + ",</p>" +
                          "<p>Thank you for applying for the position with The Webster Company.</p>" +
                          "<p>We would like to invite you to our online test for the position. Your test has been scheduled for " + test.START_TIME + " to " + test.END_TIME + ".</p>" +
                          "<p>Your account for this test:</p>" +
                          "<p>Username: "******"</p>" + "<p>Password: "******"</p>" +
                          "<p>Please reply if you have any question.</p>" +
                          "<p>Sincerly,</p>" +
                          "<p>The Webster Company</p>";
         mailService.sendMail(apply.MAIL, test.TEST_NAME, message);
         ViewBag.error = "Mail success";
     }
     catch (Exception ex)
     {
         ViewBag.error = ex.Message;
     }
     return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = APPLY_ID }));
 }
Esempio n. 23
0
        static void Main(string[] args)
        {
            DateTime?TEST;

            TEST = null;
            if (TEST == null)
            {
                Console.WriteLine("NULL");
            }
            else
            {
                Console.WriteLine(TEST.ToString());
            }

            string LLGUSD = "LLG_USD";

            Console.WriteLine(LLGUSD.Remove(3, 1));
            //Console.WriteLine(Math.Round(1m,5));
            //int i = 0;
            //int b = i++;
            //Console.WriteLine(b);

            //Random rd = new Random();
            //int num = rd.Next(0, 10);
            //for(int a=0;a<20;a++)
            //{
            //    Console.WriteLine(rd.Next(1, 5));
            //}
            //string value = " 123 456  789 ";
            //string[] StringArray = value.Trim().Split();
            //Console.WriteLine(StringArray[0]);
            //Console.WriteLine(StringArray[1]);
            //Console.WriteLine(StringArray[2]);

            //InfoStudent student = new InfoStudent();
            //student.StudyBase();
            //student.Work();
            //student.StudySpecial();
            Console.ReadKey();
            //Thread.Sleep(60000);
            //System.Diagnostics.Process.Start(@"C:\JProject\Usage_DLL_PriceForm_SpotTest\Usage_DLL_PriceForm.exe");
        }
Esempio n. 24
0
        /// <summary>
        /// 获取数据表中的某个值——从数据库中查询,如果使用了缓存,删除成功后会清空本表的所有缓存记录,然后重新加载进缓存
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="expression">条件语句</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Delete(Page page, Expression <Func <TEST, bool> > expression, bool isAddUseLog = true)
        {
            //执行删除
            TEST.Delete(expression);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //清空当前表所有缓存记录
                DelAllCache();
                //重新载入缓存
                GetList();
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了TEST表记录!");
            }
        }
Esempio n. 25
0
        public async Task <IActionResult> CreateTest([FromBody] TestView model)
        {
            if (ModelState.IsValid)
            {
                var UserId = _userManager.GetUserId(User);

                var test = new TEST
                {
                    ID_USER   = UserId,
                    NAME_TEST = model.T.NAME_TEST,
                    RESULT    = model.T.RESULT,
                    QUESTION  = model.T.QUESTION,
                    ID_TYPE   = model.T.ID_TYPE
                };

                await testService.Add(test);

                return(Ok(test));
            }
            return(BadRequest(ModelState));
        }
Esempio n. 26
0
 // GET: Test
 public ActionResult Index()
 {
     if (Session["username"] != null)
     {
         UsrService      usrService  = new UsrService();
         int             apply_id    = usrService.getApplyIdByUsername(Session["username"].ToString());
         JOB_APPLICATION application = JobApplicationService.findByUsername(Session["username"].ToString());
         ViewBag.Application = application;
         TEST test = TestService.getTestByApplyId(apply_id);
         ViewBag.Test = test;
         //if start time is later than now and end time is ealier than now let the candidate have link to do test
         if (DateTime.Compare(DateTime.Now, test.START_TIME) > 0 && DateTime.Compare(DateTime.Now, test.END_TIME) < 0)
         {
             ViewBag.link = TestService.getIndexByApplyId(apply_id);
         }
         //timer
         TimeSpan timeLeft = test.END_TIME - test.START_TIME;
         ViewBag.TimeLeft = timeLeft;
         return(View());
     }
     return(RedirectToAction("Login", "Home"));
 }
Esempio n. 27
0
        public void TestMethod1()
        {
            CGD.buffer tempBufer = new CGD.buffer();

            tempBufer.alloc(100);

            TEST temp = new TEST();

            temp.X = 10;
            temp.Y = 1.0f;
            temp.Z = 100;

            string tempString = "Txxx";


            tempBufer.append <int>(10);
            tempBufer.append <TEST>(temp);
            tempBufer.append <string>(tempString);

            int    a1 = tempBufer.extract <int>();
            TEST   a2 = tempBufer.extract <TEST>();
            string a3 = tempBufer.extract <string>();
        }
        private void BindGridDetail(string group_id, int level)
        {
            string group = group_id.Substring(0, 1);

            CountPPL.Text = "";
            if (group == "1")
            {
                PTTB.BindGroupDetail(group_id, level);
                PTTBPPL.BindPPLDetail(group_id, level);
                CountPPL.Text   = PTTBPPL.CountPPL();
                PTTB.Visible    = true;
                PTT.Visible     = false;
                GC.Visible      = false;
                CS.Visible      = false;
                TCS.Visible     = false;
                TEST.Visible    = false;
                PTTPPL.Visible  = false;
                PTTBPPL.Visible = true;
                GCPPL.Visible   = false;
                CSPPL.Visible   = false;
                TCSPPL.Visible  = false;
                TESTPPL.Visible = false;
            }
            else if (group == "2")
            {
                PTT.BindGroupDetail(group_id, level);
                PTTPPL.BindPPLDetail(group_id, level);
                CountPPL.Text   = PTTPPL.CountPPL();
                PTTB.Visible    = false;
                PTT.Visible     = true;
                GC.Visible      = false;
                CS.Visible      = false;
                TCS.Visible     = false;
                TEST.Visible    = false;
                PTTPPL.Visible  = true;
                PTTBPPL.Visible = false;
                GCPPL.Visible   = false;
                CSPPL.Visible   = false;
                TCSPPL.Visible  = false;
                TESTPPL.Visible = false;
            }
            else if (group == "3")
            {
                GC.BindGroupDetail(group_id, level);
                GCPPL.BindPPLDetail(group_id, level);
                CountPPL.Text   = GCPPL.CountPPL();
                PTTB.Visible    = false;
                PTT.Visible     = false;
                GC.Visible      = true;
                CS.Visible      = false;
                TCS.Visible     = false;
                TEST.Visible    = false;
                PTTPPL.Visible  = false;
                PTTBPPL.Visible = false;
                GCPPL.Visible   = true;
                CSPPL.Visible   = false;
                TCSPPL.Visible  = false;
                TESTPPL.Visible = false;
            }
            else if (group == "4")
            {
                CS.BindGroupDetail(group_id, level);
                CSPPL.BindPPLDetail(group_id, level);
                CountPPL.Text   = CSPPL.CountPPL();
                PTTB.Visible    = false;
                PTT.Visible     = false;
                GC.Visible      = false;
                TCS.Visible     = false;
                CS.Visible      = true;
                TEST.Visible    = false;
                PTTPPL.Visible  = false;
                PTTBPPL.Visible = false;
                GCPPL.Visible   = false;
                CSPPL.Visible   = true;
                TCSPPL.Visible  = false;
                TESTPPL.Visible = false;
            }
            else if (group == "5")
            {
                TCS.BindGroupDetail(group_id, level);
                TCSPPL.BindPPLDetail(group_id, level);
                CountPPL.Text   = TCSPPL.CountPPL();
                PTTB.Visible    = false;
                PTT.Visible     = false;
                GC.Visible      = false;
                CS.Visible      = false;
                TCS.Visible     = true;
                TEST.Visible    = false;
                PTTPPL.Visible  = false;
                PTTBPPL.Visible = false;
                GCPPL.Visible   = false;
                CSPPL.Visible   = false;
                TCSPPL.Visible  = true;
                TESTPPL.Visible = false;
            }
            else if (group == "6")
            {
                TEST.BindGroupDetail(group_id, level);
                TESTPPL.BindPPLDetail(group_id, level);
                PTTB.Visible    = false;
                PTT.Visible     = false;
                GC.Visible      = false;
                TCS.Visible     = false;
                CS.Visible      = false;
                TEST.Visible    = true;
                PTTPPL.Visible  = false;
                PTTBPPL.Visible = false;
                GCPPL.Visible   = false;
                CSPPL.Visible   = false;
                TCSPPL.Visible  = false;
                TESTPPL.Visible = true;
            }
            else
            {
                GROUPLabel.Text = "-";
                PPLLabel.Text   = "-";
                PTTB.Visible    = false;
                PTT.Visible     = false;
                GC.Visible      = false;
                CS.Visible      = false;
                TCS.Visible     = false;
                TEST.Visible    = false;
                PTTPPL.Visible  = false;
                PTTBPPL.Visible = false;
                GCPPL.Visible   = false;
                CSPPL.Visible   = false;
                TCSPPL.Visible  = false;
                TESTPPL.Visible = false;
            }
            //setEnableBtn();
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            //lấy ra đề thi có id lớn nhất của môn học được chọn
            var rs = TracNghiem.LayDanhSachDeThi();

            if (rs.Count == 0)
            {
                TEST ts = new TEST()
                {
                    id = 1, subtractID = cbMonThi.SelectedValue.ToString()
                };
                TracNghiem.ThemDeThi(ts);
                Random rd  = new Random();
                var    rs1 = TracNghiem.LayDanhSachCauHoi().Where(s => s.idSubtract == cbMonThi.SelectedValue.ToString()).ToList();
                while (rancauhoi.Count < 60)
                {
                    int i = rd.Next(0, rs1.Count);
                    if (!rancauhoi.Contains(rs1[i]))
                    {
                        rancauhoi.Add(rs1[i]);
                    }
                }
                for (int i = 0; i < 60; i++)
                {
                    TEST_DETAIL tNew = new TEST_DETAIL()
                    {
                        testID     = ts.id,
                        subtractID = rancauhoi[i].idSubtract,
                        stt        = i + 1,
                        quizID     = rancauhoi[i].id
                    };
                    TracNghiem.ThemChiTietDeThi(tNew);
                }
            }
            else
            {
                var t = rs.OrderByDescending(s => s.id).Where(s => s.subtractID == cbMonThi.SelectedValue.ToString()).Take(1).Select(s => s).SingleOrDefault();
                if (t != null)
                {
                    TEST ts = new TEST()
                    {
                        id = t.id + 1, subtractID = cbMonThi.SelectedValue.ToString()
                    };
                    TracNghiem.ThemDeThi(ts);
                    Random rd  = new Random();
                    var    rs1 = TracNghiem.LayDanhSachCauHoi().Where(s => s.idSubtract == cbMonThi.SelectedValue.ToString()).ToList();
                    while (rancauhoi.Count < 60)
                    {
                        int i = rd.Next(0, rs1.Count);
                        if (!rancauhoi.Contains(rs1[i]))
                        {
                            rancauhoi.Add(rs1[i]);
                        }
                    }
                    for (int i = 0; i < 60; i++)
                    {
                        TEST_DETAIL tNew = new TEST_DETAIL()
                        {
                            testID     = ts.id,
                            subtractID = rancauhoi[i].idSubtract,
                            stt        = i + 1,
                            quizID     = rancauhoi[i].id
                        };
                        TracNghiem.ThemChiTietDeThi(tNew);
                    }
                }
            }
            MessageBox.Show("Tạo đề thành công");
            Close();
        }
Esempio n. 30
0
        static void Sample_simple_append_extract_struct()
        {
            // Decalre) 임시로 사용할 List를 선언한다.
            TEST	temp	 = new TEST();
            temp.x	 = 10;
            temp.y	 = 1.0f;
            temp.z	 = "temp string";
            temp.w	 = new List<int> { 10, 20, 30};

            // 1) byte[256]를 생성해서 설정한다.
            CGD.buffer bufTemp = new CGD.buffer(new byte[256]);

            // APPEND) List<int>를 추가한다.
            bufTemp.append(temp);

            // EXTRACT) 추가했던 문자열을 읽어낸다.
            var tempRead = bufTemp.extract<TEST>();

            // 2) 출력한다.
            Console.WriteLine(tempRead.x);
            Console.WriteLine(tempRead.y);
            Console.WriteLine(tempRead.z);
            foreach (var iter in tempRead.w) { Console.WriteLine(iter.ToString()); }
        }
Esempio n. 31
0
 partial void InsertTEST(TEST instance);
Esempio n. 32
0
 public static void Main()
 => TEST.Solve();
Esempio n. 33
0
        public void TestMethod_General_append_extract_struct()
        {
            // 1) Buffer 할당
            CGD.buffer	bufferCreate = new CGD.buffer(2048);
            TEST		tempData	 = new TEST();

            tempData.v0	 = 	(sbyte)3;
            tempData.v1	 = 	(byte)4;
            tempData.v2	 = 	(short)4100;
            tempData.v3	 = 	(ushort)32210;
            tempData.v4	 = 	123310;
            tempData.v5	 = 	121234;
            tempData.v6	 = 	-1000443L;
            tempData.v7	 = 	12233094310UL;
            tempData.v8	 = 	1.0f;
            tempData.v9	 = 	2.0;

            for (int i = 0; i < _TEST_COUNT; ++i)
            {
                // 1) Buffer 준비
                CGD.buffer bufferTemp = bufferCreate;

                // 2) 값 써넣기
                bufferTemp.append<TEST>(tempData);

                // 3) 값 읽기
                var value2 = bufferTemp.extract<TEST>();
            }
        }
Esempio n. 34
0
 partial void UpdateTEST(TEST instance);
Esempio n. 35
0
        public void TestMethod1()
        {
            CGD.buffer tempBufer = new CGD.buffer();

            tempBufer.alloc(100);

            TEST temp = new TEST();

            temp.X   = 10;
            temp.Y   = 1.0f;
            temp.Z   = 100;

            string tempString = "Txxx";

            tempBufer.append<int>(10);
            tempBufer.append<TEST>(temp);
            tempBufer.append<string>(tempString);

            int     a1   = tempBufer.extract<int>();
            TEST    a2   = tempBufer.extract<TEST>();
            string  a3   = tempBufer.extract<string>();
        }
Esempio n. 36
0
 partial void DeleteTEST(TEST instance);