public void SetBehaviourRecord(BehaviorRecord behaviourRecord, UnityAction action, bool bBack) { this.behaviourRecord = behaviourRecord; this.bPlayingRecord = true; playOverAction = action; this.bBack = bBack; if (bBack) { frameIdx = behaviourRecord.FrameCount - 1; } else { frameIdx = 0; } if (bBack) { if (animator == null) { animator = GetComponent <Animator>(); } animator.runtimeAnimatorController = backAnimatorController; } else { if (animator == null) { animator = GetComponent <Animator>(); } animator.runtimeAnimatorController = normalAnimatorController; } }
//修改 public BehaviorForm(BehaviorRecord behavior, bool editable) { InitializeComponent(); this._Editable = editable; //權限設定 SetPerm(); this._Action = "修改"; this._BehaviorRecord = behavior; this._BefaoreUpdate = behavior.ShallowCopy(); //淺程複製(log用) }
//新增 public BehaviorForm(string studentID, bool editable) { InitializeComponent(); this._Editable = editable; //權限設定 SetPerm(); this._Action = "新增"; this._BehaviorRecord = new BehaviorRecord(); this._BehaviorRecord.StudentID = studentID; }
/// <summary> /// load畫面 /// </summary> private void LoadingView() { _DicOriBehaviorRecord.Clear(); dataGridViewX1.Rows.Clear(); _ListUpdateTarget.Clear(); string query = string.Format(@" SELECT $esl.behavior_data.uid , course.course_name , teacher.teacher_name , class.class_name , student.seat_no , student.student_number , student.name AS student_name , student.english_name , $esl.behavior_data.comment , $esl.behavior_data.create_date , $esl.behavior_data.is_good_behavior , $esl.behavior_data.detention FROM $esl.behavior_data LEFT JOIN course ON $esl.behavior_data.ref_course_id = course.id LEFT JOIN teacher ON $esl.behavior_data.ref_teacher_id = teacher.id LEFT JOIN student ON $esl.behavior_data.ref_student_id = student.id LEFT JOIN class ON student.ref_class_id = class.id WHERE create_date::DATE >= '{0}'::DATE AND create_date::DATE <= '{1}'::DATE ORDER BY class.grade_year , class.display_order , class.class_name , student.seat_no , student.id , course_name , class_name , create_date " , dateTimeInput1.Value.Date.ToShortDateString() , dateTimeInput2.Value.Date.ToShortDateString() ); QueryHelper qh = new QueryHelper(); DataTable dt = qh.Select(query); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridViewX1); //將資料庫撈回來資料 塞到_DicOriBehaviorRecord<behaviorRecord> 以便核對是否修改 row.Tag = dr["uid"]; BehaviorRecord behaviorRecord = new BehaviorRecord(); behaviorRecord.UID = "" + dr["uid"]; behaviorRecord.Comment = "" + dr["comment"]; behaviorRecord.IsGood = "" + dr["is_good_behavior"].ToString() == "true"; behaviorRecord.IsDentetion = dr["detention"].ToString() == "true"; int i = 0; row.Cells[i++].Value = "" + dr["class_name"]; row.Cells[i++].Value = "" + dr["seat_no"]; row.Cells[i++].Value = "" + dr["student_number"]; row.Cells[i++].Value = "" + dr["student_name"]; row.Cells[i++].Value = "" + dr["english_name"]; row.Cells[i++].Value = "" + dr["course_name"]; row.Cells[i++].Value = "" + dr["teacher_name"]; row.Cells[i++].Value = DateTime.Parse("" + dr["create_date"]).ToShortDateString();; row.Cells[i++].Value = "" + dr["comment"]; row.Cells[i++].Value = dr["is_good_behavior"].ToString() == "true"; row.Cells[i++].Value = dr["detention"].ToString() == "true"; row.Cells[i - 1].ToolTipText = "" + dr["comment"]; dataGridViewX1.Rows.Add(row); // 建立原本資訊的字典,作為對照用 // oriCommentDict.Add("" + dr["uid"], "" + dr["comment"]); _DicOriBehaviorRecord.Add("" + dr["uid"], behaviorRecord); } } }