public Op0SlotView(ExamSlot sl) { Init(); // mSl = sl; Header = mSl.Dt.ToString(DT.hh); Name = "_" + (Header as string).Replace(':', '_'); }
private void lbxSl_Selected(object sender, RoutedEventArgs e) { ListBoxItem i = sender as ListBoxItem; if (i == null) { return; } if (mBrd.vSl.ContainsKey(i.Content as string)) { return; } ExamSlot sl = new ExamSlot(); DateTime dt; DT.To_(mBrd.mDt.ToString(DT._) + ' ' + i.Content as string, DT.H, out dt); sl.Dt = dt; string emsg; if ((emsg = sl.DBSelRoomId()) != null) { WPopup.s.ShowDialog(emsg); return; } sl.DBSelStt(); sl.DBSelQPkR(); sl.DBSelNee(); if (sl.DBSelArchieve(out emsg)) { WPopup.s.ShowDialog(emsg); return; } Op0SlotView tbi = new Op0SlotView(sl); tbi.DeepCopy(tbcRefSl); tbi.ShowExaminee(); tbi.ShowQSHeader(); tbcSl.Items.Add(tbi); QuestSheet.DBUpdateCurQSId(mBrd.mDt); mBrd.vSl.Add(i.Content as string, sl); if ((tbi = tbcSl.SelectedItem as Op0SlotView) != null && tbi.mSl.eStt == ExamStt.Prep) { EnableQSGen(); } else { DisableQSGen(); } }
private void Lv_Checked(object sender, RoutedEventArgs e) { ExamSlot sl = (tbcSl.SelectedItem as Op0SlotView).mSl; if (rdoA.IsChecked.HasValue ? rdoA.IsChecked.Value : false) { grdB.Visibility = Visibility.Collapsed; grdA.Visibility = Visibility.Visible; txtNqs.Text = sl.CountQSByRoom(ExamLv.A).ToString(); } else { grdA.Visibility = Visibility.Collapsed; grdB.Visibility = Visibility.Visible; txtNqs.Text = sl.CountQSByRoom(ExamLv.B).ToString(); } }
public PrepNeeView(ExamSlot sl) { mSlDB = sl; Header = mSlDB.Dt.ToString(DT.hh); Name = "_" + (Header as string).Replace(':', '_'); mSlTmp = new ExamSlot(); mSlTmp.Dt = mSlDB.Dt; foreach (ExamRoom rom in mSlDB.vRoom.Values) { if (!mSlTmp.vRoom.ContainsKey(rom.uId)) { ExamRoom r = new ExamRoom(); r.uId = rom.uId; mSlTmp.vRoom.Add(r.uId, r); } } }
private void lbxSl_Selected(object sender, RoutedEventArgs e) { ListBoxItem i = sender as ListBoxItem; if (i == null) { return; } ExamSlot sl = new ExamSlot(); DateTime dt; DT.To_(mBrd.mDt.ToString(DT._) + ' ' + i.Content as string, DT.H, out dt); sl.Dt = dt; sl.DBSelRoomId(); sl.DBSelStt(); sl.DBSelNee(); PrepNeeView pnv = new PrepNeeView(sl); pnv.DeepCopy(refSl); pnv.Show(true); tbcNee.Items.Add(pnv); pnv.Focus(); }
private void lbxNee_Selected(object sender, RoutedEventArgs e) { ListBoxItem i = sender as ListBoxItem; if (i == null) { return; } ExamineeS0 nee = new ExamineeS0(); List <TabItem> l = new List <TabItem>(); foreach (TabItem ti in tbcSl.Items) { if (!nee.ParseLvId(ti.Header as string)) { l.Add(ti); } } foreach (TabItem ti in l) { tbcSl.Items.Remove(ti); } if (nee.ParseLvId(i.Content as string)) { return; } TabItem tbi = new TabItem(); tbi.Header = i.Content; // nee.mDt = mBrd.mDt; int qsid = nee.DBGetQSId(); if (qsid < 0) { return; } QuestSheet qs = null; foreach (ExamSlot sl in mBrd.vSl.Values) { if (sl.vQPack[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPack[nee.eLv].vSheet[qsid]; break; } else if (sl.vQPackAlt[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPackAlt[nee.eLv].vSheet[qsid]; break; } } if (qs == null) { string t = nee.DBGetT(); if (!mBrd.vSl.ContainsKey(t)) { ExamSlot sl = new ExamSlot(); DateTime dati; DT.To_(mBrd.mDt.ToString(DT._) + ' ' + t, DT.HS, out dati); sl.Dt = dati; string emsg; if ((emsg = sl.DBSelRoomId()) != null) { WPopup.s.ShowDialog(emsg); return; } sl.DBSelStt(); sl.DBSelQPkR(); sl.DBSelNee(); if (sl.DBSelArchieve(out emsg)) { WPopup.s.ShowDialog(emsg); return; } mBrd.vSl.Add(t.Substring(0, 5), sl); // if (sl.vQPack[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPack[nee.eLv].vSheet[qsid]; } else if (sl.vQPackAlt[nee.eLv].vSheet.ContainsKey(qsid)) { qs = sl.vQPackAlt[nee.eLv].vSheet[qsid]; } } } if (qs == null) { return; } nee.DBSelGrade(); StackPanel spl = new StackPanel(); TextBlock tx = new TextBlock(); tx.Text = Txt.s._[(int)TxI.QS_ID] + ' ' + qs.tId + ", "; spl.Children.Add(tx); tx = new TextBlock(); tx.Text = Txt.s._[(int)TxI.MARK] + ' ' + nee.Grade; spl.Children.Add(tx); ScrollViewer svwr = new ScrollViewer(); svwr.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; StackPanel sp = new StackPanel(); int x = 0; SolidColorBrush evenbg = Theme.s._[(int)BrushId.BG]; SolidColorBrush oddbg = Theme.s._[(int)BrushId.Q_BG]; SolidColorBrush difbg = Theme.s._[(int)BrushId.Ans_TopLine]; SolidColorBrush bg; bool even = false; char[] ans = nee.DBGetAns(); int k = -1; foreach (Question q in qs.ShallowCopy()) { /*if (q.bDiff) * bg = difbg; * else*/if (even) { bg = evenbg; } else { bg = oddbg; } even = !even; TextBlock j = new TextBlock(); j.Width = tbcSl.Width - SystemParameters.ScrollWidth; j.TextWrapping = TextWrapping.Wrap; j.Text = ++x + ". " + q.Stmt; j.Background = bg; sp.Children.Add(j); for (int idx = 0; idx < Question.N_ANS; ++idx) { j = new TextBlock(); j.Width = tbcSl.Width - SystemParameters.ScrollWidth; j.TextWrapping = TextWrapping.Wrap; j.Text = ((char)('A' + idx)).ToString() + ") " + q.vAns[idx]; j.Background = bg; if (q.vKeys[idx]) { j.FontWeight = FontWeights.Bold; } if (ans[++k] == Question.C1) { j.Background = Theme.s._[(int)BrushId.Ans_Highlight]; } sp.Children.Add(j); } } svwr.Content = sp; svwr.Height = 560; spl.Children.Add(svwr); tbi.Content = spl; // tbcSl.Items.Add(tbi); }
public bool SrvrBufHndl(byte[] buf, out byte[] outMsg) { outMsg = null; int offs = 0; NetCode c = (NetCode)BitConverter.ToInt32(buf, offs); offs += 4; QuestSheet qs; int lvid; ExamineeA e; DateTime dt; switch (c) { case NetCode.Dating: outMsg = new byte[DT.BYTE_COUNT]; offs = 0; DT.ToByte(outMsg, ref offs, mBrd.mDt); return(true); case NetCode.Authenticating: e = new ExamineeS1(); e.bFromC = true; e.ReadByte(buf, ref offs); bool lck = true; bool found = false; foreach (SortedList <int, bool> l in vfbLock) { if (l.TryGetValue(e.LvId, out lck)) { found = true; break; } } if (!found) { lck = false; } if (!lck) { ExamineeA o = null; dt = DateTime.Now; foreach (ExamSlot sl in mBrd.Slots.Values) { if ((o = sl.Signin(e)) != null) { dt = sl.Dt; break; } } if (o != null) { if (o.dtTim1.Hour == DT.INV) { o.dtTim1 = DateTime.Now; } Dispatcher.InvokeAsync(() => { foreach (Op1SlotView vw in tbcSl.Items.OfType <Op1SlotView>()) { TextBlock t; lvid = o.LvId; if (vw.vComp.TryGetValue(lvid, out t)) { t.Text = o.tComp; } if (vw.vDt1.TryGetValue(lvid, out t)) { t.Text = o.dtTim1.ToString("HH:mm"); } CheckBox cbx; if (vw.vLock.TryGetValue(lvid, out cbx)) { cbx.IsChecked = true; cbx.IsEnabled = true; } if (vw.vbLock.Keys.Contains(lvid)) { vw.vbLock[lvid] = true; } } }); byte[] a; o.bFromC = true; o.ToByte(out a); outMsg = new byte[4 + a.Length]; Buffer.BlockCopy(BitConverter.GetBytes(0), 0, outMsg, 0, 4); Buffer.BlockCopy(a, 0, outMsg, 4, a.Length); } else { outMsg = new byte[4]; Buffer.BlockCopy(BitConverter.GetBytes((int)TxI.SIGNIN_NOK), 0, outMsg, 0, 4); return(false); //close } } else { ExamineeA o = null; foreach (ExamSlot sl in mBrd.Slots.Values) { if ((o = sl.Find(e.LvId)) != null) { break; } } if (o == null) { o = new ExamineeC(e.tId); } if (o.tComp == null) { outMsg = new byte[16]; } else { outMsg = new byte[16 + o.tComp.Length]; } Buffer.BlockCopy(BitConverter.GetBytes((int)TxI.SIGNIN_AL), 0, outMsg, 0, 4); if (o.tComp == null) { Buffer.BlockCopy(BitConverter.GetBytes(0), 0, outMsg, 4, 4); offs = 8; } else { byte[] comp = Encoding.UTF8.GetBytes(o.tComp); Buffer.BlockCopy(BitConverter.GetBytes(comp.Length), 0, outMsg, 4, 4); offs = 8; Buffer.BlockCopy(comp, 0, outMsg, offs, o.tComp.Length); offs += comp.Length; } Buffer.BlockCopy(BitConverter.GetBytes(o.dtTim1.Hour), 0, outMsg, offs, 4); offs += 4; Buffer.BlockCopy(BitConverter.GetBytes(o.dtTim1.Minute), 0, outMsg, offs, 4); break; } return(true); case NetCode.ExamRetrieving: outMsg = null; lvid = BitConverter.ToInt32(buf, offs); ExamSlot slo = null; foreach (ExamSlot s in mBrd.Slots.Values) { foreach (ExamRoom r in s.Rooms.Values) { if (r.vExaminee.ContainsKey(lvid)) { slo = s; break; } } } if (slo == null) { outMsg = new byte[4]; Array.Copy(BitConverter.GetBytes((int)TxI.NEEID_NF), 0, outMsg, 0, 4); break; } Level lv = (lvid < (int)Level.MAX_COUNT_EACH_LEVEL) ? Level.A : Level.B; offs += 4; int qsid = BitConverter.ToInt32(buf, offs); if (qsid == (int)Level.MAX_COUNT_EACH_LEVEL) { byte[] a = slo.ToByteNextQS(lv); if (a != null) { outMsg = new byte[a.Length + 4]; Array.Copy(BitConverter.GetBytes(0), outMsg, 4); Array.Copy(a, 0, outMsg, 4, a.Length); } } else if (slo.MainPacks[lv].Sheets.TryGetValue(qsid, out qs)) { outMsg = new byte[qs.ItemsInBytes.Length + 4]; Array.Copy(BitConverter.GetBytes(0), outMsg, 4); Array.Copy(qs.ItemsInBytes, 0, outMsg, 4, qs.ItemsInBytes.Length); } if (outMsg == null) { mCbMsg += Txt.s._[(int)TxI.QS_NFOUND] + (qsid); outMsg = new byte[8]; Array.Copy(BitConverter.GetBytes((int)TxI.QS_NFOUND), 0, outMsg, 0, 4); Array.Copy(BitConverter.GetBytes(qsid), 0, outMsg, 4, 4); } break; case NetCode.Submiting: e = new ExamineeS1(); e.bFromC = true; if (!e.ReadByte(buf, ref offs)) { AnsSheet keySh = null; found = false; foreach (ExamSlot sl in mBrd.Slots.Values) { if (sl.mKeyPack.Sheets.TryGetValue(e.mAnsSh.uQSLvId, out keySh)) { found = true; break; } } if (!found) { outMsg = BitConverter.GetBytes(101); //todo break; } ExamineeA o = null; lvid = e.LvId; found = false; foreach (ExamSlot sl in mBrd.Slots.Values) { if ((o = sl.Find(lvid)) != null) { break; } } if (o != null) { o.eStt = NeeStt.Finished; o.mAnsSh = e.mAnsSh; o.uGrade = keySh.Grade(e.mAnsSh.aAns); o.dtTim2 = DateTime.Now; foreach (SortedList <int, bool> sl in vfbLock) { if (sl.ContainsKey(lvid)) { sl[lvid] = true; } } Dispatcher.InvokeAsync(() => { bool toSubm = true; foreach (Op1SlotView vw in tbcSl.Items.OfType <Op1SlotView>()) { TextBlock t = null; if (vw.vDt2.TryGetValue(lvid, out t)) { t.Text = o.dtTim2.ToString("HH:mm"); } if (vw.vMark.TryGetValue(lvid, out t)) { t.Text = o.Grade.ToString(); } CheckBox cbx; if (vw.vLock.TryGetValue(lvid, out cbx)) { cbx.IsChecked = true; cbx.IsEnabled = false; } if (vw.vAbsen.TryGetValue(lvid, out cbx)) { cbx.IsChecked = cbx.IsEnabled = false; } if (!vw.ToSubmit()) { toSubm = false; } } if (toSubm) { ToSubmit(true); } }); o.ToByte(out outMsg, 0); } else { mCbMsg += Txt.s._[(int)TxI.NEEID_NF] + ' ' + lvid; outMsg = BitConverter.GetBytes((int)TxI.NEEID_NF); } } else { mCbMsg += Txt.s._[(int)TxI.RECV_DAT_ER]; outMsg = BitConverter.GetBytes((int)TxI.RECV_DAT_ER); } break; default: outMsg = null; break; } return(false); }