public void SaveLsnActs(IList <EnLsnAct> Values) { foreach (EnLsnAct act in Values) { IList <EnLsnAct> Acts = ClsLsns[act.ClsLesson.Id].Acts; if (Acts.Contains(act)) { ThisModule.OleDB.ExecuteNonQuery("update TLsnAct set" + " FLocked = " + (act.Locked ? "True" : "false") + ", FTime = " + VcTimeLogic.TimeToInt32(act.Time) + " where Id = " + act.Id); } else { Debug.Assert(act.Id == 0, "act.Id != 0"); EnLsnAct nAct = new EnLsnAct(); nAct.Locked = act.Locked; nAct.ClsLesson = act.ClsLesson; act.Time.CopyFieldTo(nAct.Time); nAct.Id = Convert.ToInt64(ThisModule.OleDB.InsertAndReturnId_MS("Insert into TLsnAct" + "(FClsLesson, FLocked, FTime) values (" + nAct.ClsLesson.Id + ", " + (act.Locked ? "True" : "false") + ", " + VcTimeLogic.TimeToInt32(nAct.Time) + ")")); Acts.Add(nAct); } } }
public IList <VcRuleCell> GetRules(BaseEntity Ety) { IList <VcRuleCell> Result = new List <VcRuleCell>(); List <KindIdent> KindIdents; Int32 RulesIdx; if (Find(Ety, out KindIdents, out RulesIdx)) { ExIList.Append <VcRuleCell>(KindIdents[RulesIdx].Rules, Result); return(Result); } else { KindIdent ki = new KindIdent(Ety.GetType().Name); foreach (OleDbDataReader Reader in ThisModule.OleDB.EachRows("select FRule, FTime from TRule " + " where FKind = '" + ki.Kind + "'" + " and FId = " + Ety.Id)) { VcRuleCell rt = new VcRuleCell(); //rt.Rule = (eRule)ExMath.Bound(Convert.ToInt32(Reader[0]), (Int32)eRule.crisscross, (Int32)eRule.excellent, (Int32)eRule.common); var rd = ExConvert.TryToInt32(Reader[0], 0); rt.Rule = rd <(Int32)eRule.crisscross || rd> (Int32) eRule.excellent ? eRule.common : (eRule)rd; rt.Time = VcTimeLogic.GetTimeFromInt32(Convert.ToInt32(Reader[1])); ki.Rules.Add(rt); } if (KindIdents == null) { KindIdents = new List <KindIdent>(); KindIdents.Add(ki); RuleBuf.Add(Ety.Id, KindIdents); } else { KindIdents.Add(ki); } ExIList.Append <VcRuleCell>(ki.Rules, Result); return(Result); } }
public void SetRules(BaseEntity Ety, IList <VcRuleCell> Value) { List <KindIdent> KindIdents; Int32 RulesIdx; if (Find(Ety, out KindIdents, out RulesIdx)) { KindIdents[RulesIdx].Rules.Clear(); ExIList.Append <VcRuleCell>(Value, KindIdents[RulesIdx].Rules); } else { KindIdent ki = new KindIdent(Ety.GetType().Name); ExIList.Append <VcRuleCell>(Value, ki.Rules); if (KindIdents == null) { KindIdents = new List <KindIdent>(); KindIdents.Add(ki); RulesIdx = KindIdents.Count - 1; RuleBuf.Add(Ety.Id, KindIdents); } } ThisModule.OleDB.ExecuteNonQuery("Delete from TRule " + " where FKind = '" + Ety.GetType().Name + "'" + " and FId = " + Ety.Id); foreach (VcRuleCell rt in KindIdents[RulesIdx].Rules) { ThisModule.OleDB.ExecuteNonQuery("insert into TRule" + " (FKind, FId, FRule, FTime) values (" + "'" + Ety.GetType().Name + "'" + ", " + Ety.Id + ", " + (Int32)rt.Rule + ", " + VcTimeLogic.TimeToInt32(rt.Time) + ")"); } }
/// <summary> /// 生成ClsLesson的规则表(ClsLsnRuleList) /// </summary> private void SetClsLsnRuleList() { ClsLsnRuleList.Clear(); foreach (EnClsLesson clsLsn in DataRule.Lsn.eachClsLesson()) { DtMatrix <eRule> clsLsnRules = new DtMatrix <eRule>(DataRule.Solution); ClsLsnRuleList.Add(clsLsn, clsLsnRules); foreach (VcRuleCell rt in DataRule.Rule.GetRules(clsLsn)) { if (clsLsnRules.TestTime(rt.Time)) { clsLsnRules[rt.Time] = VcTimeLogic.RuleAdd(clsLsnRules[rt.Time], rt.Rule); } } foreach (VcRuleCell rt in DataRule.Rule.GetRules(clsLsn.Lesson)) { if (clsLsnRules.TestTime(rt.Time)) { clsLsnRules[rt.Time] = VcTimeLogic.RuleAdd(clsLsnRules[rt.Time], rt.Rule); } } foreach (BaseEntity ety in eachClsLsnComponent(clsLsn)) { foreach (VcRuleCell rt in DataRule.Rule.GetRules(ety)) { if (clsLsnRules.TestTime(rt.Time)) { clsLsnRules[rt.Time] = VcTimeLogic.RuleAdd(clsLsnRules[rt.Time], rt.Rule); } } } } }
private void LoadAct() { foreach (OleDbDataReader reader in ThisModule.OleDB.EachRows( "select Id, FClsLesson, FTime, FLocked" + " from TLsnAct")) { EnLsnAct Act = new EnLsnAct(); Act.Id = Convert.ToInt64(reader[0]); VcTimeLogic.GetTimeFromInt32(Convert.ToInt32(reader[2])).CopyFieldTo(Act.Time); Act.Locked = Convert.ToBoolean(reader[3]); Int64 ClsLsnId = Convert.ToInt64(reader[1]); ClsLsnContainer ClsLsnCnt; if (!ClsLsns.TryGetValue(ClsLsnId, out ClsLsnCnt)) { ThisModule.ErrorLog.Error("VcLsnAct恢复错误:ID对应的实体不存在 " + " ClsLesson: " + ClsLsnId); continue; } Act.ClsLesson = ClsLsnCnt.ClsLsn; ClsLsnCnt.Acts.Add(Act); } }
private void CreateCells() { IList <Control> ColumnHeades = new List <Control>(); Control CRh = new Button(); CRh.Visible = false; ColumnHeades.Add(CRh); for (Int32 i = 0; i < Solution.ActiveWeekArr.Length; i++) { if (Solution.ActiveWeekArr[i]) { Control Ch = new HeadButton(); Ch.Visible = false; Ch.Text = ExDateTime.DayOfWeekToChiese((DayOfWeek)i, "周"); ColumnHeades.Add(Ch); } } foreach (Control ctl in ColumnHeades) { ctl.Parent = this.Parent; } Cells.Add(ColumnHeades); IList <Control> Row; Boolean HasSeparator = true; for (Int32 i = 0; i < Solution.LessonNumberArr.Length; i++) { if (Solution.LessonNumberArr[i] > 0) { if (!HasSeparator) { Row = new List <Control>(); Button Separator = new HeadButton(); Separator.Visible = false; Separator.Enabled = false; Separator.Parent = this.Parent; Row.Add(Separator); Cells.Add(Row); } HasSeparator = false; for (Int32 j = 0; j < Solution.LessonNumberArr[i]; j++) { Row = new List <Control>(); Button Rh = new HeadButton(); Rh.Text = VcTimeLogic.BetideNodeToString((eBetideNode)i) + " " + (j + 1); Rh.Parent = this.Parent; Row.Add(Rh); for (Int32 k = 0; k < Solution.ActiveWeekArr.Length; k++) { if (Solution.ActiveWeekArr[k]) { T Cell = new T(); Cell.Visible = false; Cell.Time.Week = (DayOfWeek)k; Cell.Time.BetideNode = (eBetideNode)i; Cell.Time.Order = j + 1; Cell.Parent = this.Parent; Row.Add(Cell); } } Cells.Add(Row); } } } }
protected void CreateMattes() { mattes = new DtMatrix <MatterCell>(solution); foreach (VcTime time in mattes.eachTime()) { MatterCell cl = this.GetNewMatterCell(); time.CopyFieldTo(cl.Time); mattes[time] = cl; } ClmCount = 1; RowCount = cRate; BorderDirect bd0 = new BorderDirect(); bd0.Border = this.GetNewBorderCell(); bd0.Clm = ClmCount - 1; bd0.Row = 0; bd0.Wdh = 1; bd0.Hgh = cRate; TopBordes[0] = bd0; for (Int32 i = 0; i < 7; i++) { if (solution.ActiveWeekArr[i]) { ClmCount++; BorderDirect bd = new BorderDirect(); bd.Border = this.GetNewBorderCell(); bd.Border.Text = ExDateTime.DayOfWeekToChiese((DayOfWeek)i, "周"); bd.Clm = ClmCount - 1; bd.Row = 0; bd.Wdh = 1; bd.Hgh = cRate; TopBordes[i + 1] = bd; } } Boolean IsOpening = false; for (Int32 i = 0; i < 4; i++) { if (solution.LessonNumberArr[i] > 0) { if (IsOpening) { BorderDirect bd = new BorderDirect(); bd.Border = this.GetNewBorderCell(); bd.Clm = 0; bd.Row = RowCount; bd.Wdh = ClmCount; bd.Hgh = 1; LeftBordes[i, 0] = bd; RowCount = RowCount + 1; } for (Int32 j = 1; j <= solution.LessonNumberArr[i]; j++) { BorderDirect bd = new BorderDirect(); bd.Border = this.GetNewBorderCell(); bd.Border.Text = j == 1 ? VcTimeLogic.BetideNodeToString((eBetideNode)i) + " " + (j) : j.ToString(); bd.Clm = 0; bd.Row = RowCount; bd.Wdh = 1; bd.Hgh = cRate; LeftBordes[i, j] = bd; RowCount = RowCount + cRate; } IsOpening = true; } } }