예제 #1
0
        /// <summary>
        /// 當成績資料被修改時...
        /// </summary>
        private void dataGridViewX1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            DataGridViewCell cell = dataGridViewX1.CurrentCell;

            if (!IsScore(cell))
            {
                return;
            }

            dataGridViewX1.CurrentCell.ErrorText       = "";
            dataGridViewX1.CurrentCell.Style.BackColor = Color.White;

            SCJoinRow scjRow = (SCJoinRow)dataGridViewX1.CurrentRow.DataBoundItem;

            scjRow.HasChange = true;

            if (_logDic.ContainsKey(scjRow.SCJoinID))
            {
                _logDic[scjRow.SCJoinID].IsChange = true;
            }

            //資料錯誤則離開
            if (!CheckCellValue(dataGridViewX1.CurrentCell))
            {
                return;
            }

            //進行成績及時計算
            if (GetPoint._wp != null)
            {
                SetRowResults(dataGridViewX1.CurrentRow);
            }
        }
예제 #2
0
        /// <summary>
        /// 把成績資料顯示在畫面上
        /// </summary>
        private void SetValueToRow(DataGridViewRow row)
        {
            SCJoinRow scjRow = (SCJoinRow)row.DataBoundItem;

            //如果不是空值
            if (!string.IsNullOrEmpty(scjRow.Score))
            {
                XmlElement xml = DSXmlHelper.LoadXml(scjRow.Score);

                foreach (XmlElement each in xml.SelectNodes("Item"))
                {
                    string name = each.GetAttribute("Name");
                    if (ColumnDic.ContainsKey(name))
                    {
                        row.Cells[ColumnDic[name]].Value = each.GetAttribute("Score");
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 排序資料
        /// 社團編號 ->社團名稱 ->班級名稱 ->座號 ->學生姓名
        /// </summary>
        private int SortSCJ(SCJoinRow a, SCJoinRow b)
        {
            string clubNameA = a.club.ClubNumber.PadLeft(3, '0');

            clubNameA += a.ClubName.PadLeft(10, '0');
            clubNameA += a.ClassIndex.PadLeft(3, '0');
            clubNameA += a.ClassName.PadLeft(5, '0');
            clubNameA += a.SeatNo.PadLeft(3, '0');
            clubNameA += a.StudentName.PadLeft(10, '0');

            string clubNameB = b.club.ClubNumber.PadLeft(3, '0');

            clubNameB += b.ClubName.PadLeft(10, '0');
            clubNameB += b.ClassIndex.PadLeft(3, '0');
            clubNameB += b.ClassName.PadLeft(5, '0');
            clubNameB += b.SeatNo.PadLeft(3, '0');
            clubNameB += b.StudentName.PadLeft(10, '0');

            return(clubNameA.CompareTo(clubNameB));
        }
예제 #4
0
        //儲存
        void Save_BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            List <SCJoin> list = new List <SCJoin>();

            if (GetPoint._wp != null)
            {
                foreach (DataGridViewRow row in dataGridViewX1.Rows)
                {
                    SCJoinRow scjRow = (SCJoinRow)row.DataBoundItem;

                    //Log
                    Log_Result Set_Log = _logDic[scjRow.SCJoinID];

                    if (scjRow.HasChange)
                    {
                        DSXmlHelper dsx    = new DSXmlHelper("Xml");
                        bool        IsTrue = false;

                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            if (!IsScore(cell))
                            {
                                continue;
                            }
                            //取得
                            if (_ColumnDic.ContainsKey(cell.ColumnIndex))
                            {
                                XmlElement xml = dsx.AddElement("Item");

                                string name  = _ColumnDic[cell.ColumnIndex];
                                string value = "" + cell.Value;

                                if (!string.IsNullOrEmpty(value))
                                {
                                    IsTrue = true;
                                }
                                xml.SetAttribute("Name", name);
                                xml.SetAttribute("Score", value);

                                //Log
                                if (Set_Log._NewItemDic.ContainsKey(name))
                                {
                                    Set_Log._NewItemDic[name] = value;
                                }
                            }
                        }
                        if (IsTrue)
                        {
                            scjRow.SCJ.Score = dsx.BaseElement.OuterXml;
                        }
                        else
                        {
                            scjRow.SCJ.Score = "";
                        }
                        list.Add(scjRow.SCJ);
                    }
                }
                //修改儲存


                _AccessHelper.UpdateValues(list);

                //Log
                FISCA.LogAgent.ApplicationLog.Log("社團", "成績輸入", GetLostConn());
            }
            else
            {
                //沒有指定成績比例原則
                e.Cancel = true;
            }
        }
예제 #5
0
        //畫面取得
        void BGW_FormLoad_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            btnReport.Enabled = true;
            btnSave.Enabled   = true;
            this.Text         = "成績輸入";

            if (e.Cancelled)
            {
                MsgBox.Show("資料取得已被中止");
            }
            else
            {
                if (e.Error == null)
                {
                    dataGridViewX1.AutoGenerateColumns = false;
                    RowList.Sort(SortSCJ);
                    dataGridViewX1.DataSource = RowList;

                    //Log
                    foreach (SCJoinRow each in RowList)
                    {
                        if (!_logDic.ContainsKey(each.SCJoinID))
                        {
                            _logDic.Add(each.SCJoinID, new Log_Result(ColumnDic.Keys.ToList(), each.SCJ));
                            _logDic[each.SCJoinID]._stud = each.student;
                            if (!string.IsNullOrEmpty(each.student.RefClassID))
                            {
                                if (ClassDic.ContainsKey(each.student.RefClassID))
                                {
                                    _logDic[each.SCJoinID]._class = ClassDic[each.student.RefClassID];
                                }
                            }
                        }
                    }

                    //學期成績資料
                    foreach (DataGridViewRow row in dataGridViewX1.Rows)
                    {
                        SCJoinRow scjRow = (SCJoinRow)row.DataBoundItem;
                        if (scjRow.RSR != null)
                        {
                            if (scjRow.RSR.ResultScore.HasValue)
                            {
                                row.Cells[colClearing].Value = scjRow.RSR.ResultScore.Value;
                            }
                        }
                    }

                    //分項成績資料與試算
                    if (GetPoint._wp != null)
                    {
                        foreach (DataGridViewRow row in dataGridViewX1.Rows)
                        {
                            //把資料顯示在畫面上
                            SetValueToRow(row);
                            //試算學期成績
                            SetRowResults(row);
                        }
                    }
                    else
                    {
                        MsgBox.Show("尚未設定評量比例\n將無法試算出總成績資料!!");
                    }
                    _ChangeListener.Reset();
                    _ChangeListener.ResumeListen();
                    IsChangeNow = false;
                }
                else
                {
                    MsgBox.Show("發生錯誤:\n" + e.Error.Message);
                }
            }
        }
예제 #6
0
        //void dataGridViewX1_DataError(object sender, DataGridViewDataErrorEventArgs e)
        //{
        //    MsgBox.Show("輸入資料錯誤!!");
        //    e.Cancel = false;
        //}

        void BGW_FormLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            StringBuilder sb_3 = new StringBuilder();

            GetPoint = new 成績取得器();
            GetPoint.SetWeightProportion();
            GetPoint.GetSCJoinByClubIDList(ClubAdmin.Instance.SelectedSource);

            #region 社團老師資訊

            List <string> teacherIDList = new List <string>();
            foreach (CLUBRecord club in GetPoint._ClubDic.Values)
            {
                if (!string.IsNullOrEmpty(club.RefTeacherID))
                {
                    if (!teacherIDList.Contains(club.RefTeacherID))
                    {
                        teacherIDList.Add(club.RefTeacherID);
                    }
                }
            }

            List <TeacherRecord> TeacherList = Teacher.SelectByIDs(teacherIDList);
            Dictionary <string, TeacherRecord> ClubTeacherDic = new Dictionary <string, TeacherRecord>();
            foreach (TeacherRecord each in TeacherList)
            {
                if (!ClubTeacherDic.ContainsKey(each.ID))
                {
                    ClubTeacherDic.Add(each.ID, each);
                }
            }

            #endregion

            #region 取得班級資料

            //從學生Record內取得班級ID,再取得班級Record
            ClassDic = GetClassDic();

            #endregion

            RowList.Clear();

            _logDic = new Dictionary <string, Log_Result>();

            //取得社團參與記錄
            foreach (List <SCJoin> each in GetPoint._SCJoinDic.Values)
            {
                if (each.Count == 1)
                {
                    #region 只有一筆資料
                    SCJoin sch = each[0];

                    SCJoinRow scjRow = new SCJoinRow();
                    scjRow.SCJ = sch;
                    //學生
                    if (GetPoint._StudentDic.ContainsKey(sch.RefStudentID))
                    {
                        scjRow.student = GetPoint._StudentDic[sch.RefStudentID];

                        //社團
                        if (GetPoint._ClubDic.ContainsKey(sch.RefClubID))
                        {
                            scjRow.club = GetPoint._ClubDic[sch.RefClubID];

                            if (ClubTeacherDic.ContainsKey(GetPoint._ClubDic[sch.RefClubID].RefTeacherID))
                            {
                                scjRow.teacher = ClubTeacherDic[GetPoint._ClubDic[sch.RefClubID].RefTeacherID];
                            }
                        }

                        if (GetPoint._RSRDic.ContainsKey(sch.UID))
                        {
                            scjRow.RSR = GetPoint._RSRDic[sch.UID];
                        }

                        RowList.Add(scjRow);
                    }
                    #endregion
                }
                else if (each.Count >= 1)
                {
                    #region  兩筆資料
                    //錯誤訊息
                    StudentRecord sr = Student.SelectByID(each[0].RefStudentID);
                    sb_3.AppendLine("學生[" + sr.Name + "]有2筆以上社團記錄");

                    SCJoin    sch    = each[0];
                    SCJoinRow scjRow = new SCJoinRow();
                    scjRow.SCJ = sch;
                    //學生
                    if (GetPoint._StudentDic.ContainsKey(sch.RefStudentID))
                    {
                        scjRow.student = GetPoint._StudentDic[sch.RefStudentID];

                        //社團
                        if (GetPoint._ClubDic.ContainsKey(sch.RefClubID))
                        {
                            scjRow.club = GetPoint._ClubDic[sch.RefClubID];

                            if (ClubTeacherDic.ContainsKey(GetPoint._ClubDic[sch.RefClubID].RefTeacherID))
                            {
                                scjRow.teacher = ClubTeacherDic[GetPoint._ClubDic[sch.RefClubID].RefTeacherID];
                            }
                        }

                        if (GetPoint._RSRDic.ContainsKey(sch.UID))
                        {
                            scjRow.RSR = GetPoint._RSRDic[sch.UID];
                        }

                        RowList.Add(scjRow);
                    }
                    #endregion
                }
                else
                {
                    //沒有記錄繼續
                }
            }

            if (!string.IsNullOrEmpty(sb_3.ToString()))
            {
                MsgBox.Show(sb_3.ToString());
            }
        }