Esempio n. 1
0
        /// <summary>
        /// Duplicates DojoPromotion object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoPromotion object reflecting the replicated DojoPromotion object.</returns>
        public DojoPromotion Duplicate()
        {
            DojoPromotion clonedDojoPromotion = this.Clone();

            // Insert must be called after children are replicated!
            clonedDojoPromotion.iD       = DojoPromotionManager._insert(clonedDojoPromotion);
            clonedDojoPromotion.isSynced = true;
            return(clonedDojoPromotion);
        }
Esempio n. 2
0
        /// <summary>
        /// Ensures that the object's fields and children are
        /// pre-loaded before any updates or reads.
        /// </summary>
        public void EnsurePreLoad()
        {
            if (!isPlaceHolder)
            {
                return;
            }

            DojoPromotionManager._fill(this);
            isPlaceHolder = false;
        }
Esempio n. 3
0
        private void bindDropDownLists()
        {
            #region Bind General Child Data

            msTestList.Items.Add(new ListItem("Null", "Null"));
            DojoTestListManager    testListManager    = new DojoTestListManager();
            DojoTestListCollection testListCollection = testListManager.GetCollection(string.Empty, string.Empty, null);
            foreach (DojoTestList testList in testListCollection)
            {
                ListItem i = new ListItem(testList.ToString(), testList.ID.ToString());
                msTestList.Items.Add(i);
            }

            msMember.Items.Add(new ListItem("Null", "Null"));
            DojoMemberManager    memberManager    = new DojoMemberManager();
            DojoMemberCollection memberCollection = memberManager.GetCollection(string.Empty, string.Empty, null);
            foreach (DojoMember member in memberCollection)
            {
                ListItem i = new ListItem(member.ToString(), member.ID.ToString());
                msMember.Items.Add(i);
            }

            msEntryType.Items.Add(new ListItem("Null", "Null"));
            DojoTestListJournalEntryTypeManager    entryTypeManager    = new DojoTestListJournalEntryTypeManager();
            DojoTestListJournalEntryTypeCollection entryTypeCollection = entryTypeManager.GetCollection(string.Empty, string.Empty, null);
            foreach (DojoTestListJournalEntryType entryType in entryTypeCollection)
            {
                ListItem i = new ListItem(entryType.ToString(), entryType.ID.ToString());
                msEntryType.Items.Add(i);
            }

            #endregion

            #region Bind Details Child Data

            msEditor.Items.Add(new ListItem("Null", "Null"));
            DojoMemberManager    editorManager    = new DojoMemberManager();
            DojoMemberCollection editorCollection = editorManager.GetCollection(string.Empty, string.Empty, null);
            foreach (DojoMember editor in editorCollection)
            {
                ListItem i = new ListItem(editor.ToString(), editor.ID.ToString());
                msEditor.Items.Add(i);
            }

            msPromotion.Items.Add(new ListItem("Null", "Null"));
            DojoPromotionManager    promotionManager    = new DojoPromotionManager();
            DojoPromotionCollection promotionCollection = promotionManager.GetCollection(string.Empty, string.Empty, null);
            foreach (DojoPromotion promotion in promotionCollection)
            {
                ListItem i = new ListItem(promotion.ToString(), promotion.ID.ToString());
                msPromotion.Items.Add(i);
            }

            #endregion
        }
Esempio n. 4
0
        /// <summary>
        /// Saves the DojoPromotion object state to the database.
        /// </summary>
        public int Save()
        {
            if (member != null)
            {
                member.Save();
            }
            if (test != null)
            {
                test.Save();
            }
            if (promotionRank != null)
            {
                promotionRank.Save();
            }
            if (lastRank != null)
            {
                lastRank.Save();
            }

            if (isSynced)
            {
                return(iD);
            }

            if (iD == -1)
            {
                throw (new Exception("Invalid record; cannot be saved."));
            }
            if (iD == 0)
            {
                iD = DojoPromotionManager._insert(this);
            }
            else
            {
                DojoPromotionManager._update(this);
            }
            isSynced = iD != -1;
            return(iD);
        }
Esempio n. 5
0
        public void PromotionAdjustment()
        {
            DojoPromotionManager    promotionManager;
            DojoPromotionCollection promotions;

            promotionManager = new DojoPromotionManager();
            promotions       = promotionManager.GetCollection(string.Empty,
                                                              string.Empty, DojoPromotionFlags.Member);

            // Loop through promotions and promote member to higher ranks incrementally.
            // Fix their attendance while doing so if required.
            foreach (DojoPromotion promotion in promotions)
            {
                if (promotion.PromotionDate > promotion.Member.RankDate)
                {
                    promotion.Member.Rank     = promotion.PromotionRank;
                    promotion.Member.RankDate = promotion.PromotionDate;
                    promotion.Member.Save();

                    // WHOAH! WAY SLOW!
                    AttendanceAdjustment(promotion.Member);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderContent(HtmlTextWriter output)
        {
            DojoPromotionManager    m = new DojoPromotionManager();
            DojoPromotionCollection dojoPromotionCollection = m.GetCollection(string.Empty, string.Empty, null);

            // Render Header Row
            this.headerLockEnabled = true;
            RenderRow(this.HeaderRowCssClass, );

            bool   rowflag = false;
            string rowCssClass;

            //
            // Render Records
            //
            foreach (DojoPromotion dojoPromotion in dojoPromotionCollection)
            {
                if (rowflag)
                {
                    rowCssClass = defaultRowCssClass;
                }
                else
                {
                    rowCssClass = alternateRowCssClass;
                }
                rowflag = !rowflag;
                output.WriteBeginTag("tr");
                output.WriteAttribute("i", dojoPromotion.ID.ToString());
                output.WriteLine(HtmlTextWriter.TagRightChar);
                output.Indent++;

                output.Indent--;
                output.WriteEndTag("tr");
                output.WriteLine();
            }
        }
Esempio n. 7
0
        ///// <summary>
        ///// Applies the promotion to the attendance database. This will update the ranks on
        ///// the promotion member's attendance using the dates of the member's attendance.
        ///// This is necissary to do, because the attendance tracker may have recorded incorrect
        ///// ranks before the promotion was entered into the database and after the actual test.
        ///// </summary>
        ///// <param name="promotion"></param>
        //public void AttendanceAdjustment(DojoPromotion promotion)
        //{
        //    DojoPromotionManager promotionManager;
        //    DojoPromotion nextPromotion;
        //    DojoAttendanceEntryManager attendanceManager;
        //    DojoAttendanceEntryCollection promotionAttendance;

        //    // Try to find member's next promotion if it exists.
        //    promotionManager = new DojoPromotionManager();
        //    attendanceManager = new DojoAttendanceEntryManager();

        //    nextPromotion =
        //        promotionManager.FindPromotionByMember(promotion.Member.iD,
        //        promotion.PromotionRank.PromotionRank.iD);

        //    if (nextPromotion == null)
        //        promotionAttendance = attendanceManager.GetCollection(
        //            "DojoClass.ClassStart>=#" + promotion.PromotionDate + "#" +
        //            " AND MemberID=" + promotion.member.iD,
        //            string.Empty, DojoAttendanceEntryFlags.Class);
        //    else
        //        promotionAttendance = attendanceManager.GetCollection(
        //            "DojoClass.ClassStart>=#" + promotion.PromotionDate + "#" +
        //            " AND DojoClass.ClassStart<=#" + nextPromotion.PromotionDate.Subtract(TimeSpan.FromDays(1)) + "#" +
        //            " AND MemberID=" + promotion.member.iD,
        //            string.Empty, DojoAttendanceEntryFlags.Class);

        //    for (int x = 0; x < promotionAttendance.Count; x++)
        //    {
        //        if (promotionAttendance[x].Rank.iD != promotion.PromotionRank.iD)
        //        {
        //            promotionAttendance[x].Rank = promotion.PromotionRank;
        //            promotionAttendance[x].Save();
        //        }
        //    }
        //}

        public void AttendanceAdjustment(DojoMember member)
        {
            DateTime                      nextPromotionDate;
            int                           promotionFirstClassIndex;
            DojoPromotion                 promotion;
            DojoPromotionManager          promotionManager;
            DojoPromotionCollection       promotions;
            DojoAttendanceEntryManager    attendanceManager;
            DojoAttendanceEntryCollection attendance;

            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            // Load member promotions oldest to newest
            promotionManager = new DojoPromotionManager();
            promotions       = promotionManager.GetCollection(
                "MemberID=" + member.ID.ToString(),
                "PromotionDate",
                DojoPromotionFlags.PromotionRank);

            // If the member has no promotions set all attendance
            // for the member to the member's rank.
            if (promotions.Count == 0)
            {
                dbCommand = database.GetSqlStringCommand(
                    "UPDATE kitTessen_Attendance " +
                    "SET RankID=@RankID " +
                    "WHERE MemberID=@MemberID;");
                database.AddInParameter(dbCommand, "@MemberID", DbType.Int32, member.ID);
                database.AddInParameter(dbCommand, "@RankID", DbType.Int32, member.Rank.ID);
                database.ExecuteNonQuery(dbCommand);
                return;
            }

            // Load Attendance oldest to newest
            attendanceManager = new DojoAttendanceEntryManager();
            attendance        = attendanceManager.GetCollection("MemberID=" +
                                                                member.ID.ToString(), "ClassStart",
                                                                DojoAttendanceEntryFlags.Class);

            //                  0                            1                 2
            //                  First Promotion >>>>>>>>>>>> Next Promotion
            //   DON'T CHANGE   11/04/2003                   5/2/2007          1/3/2008
            //   ...............p............................p.................p
            //   beginner       rokyu                        sankyu            nikyu
            //
            //   12/13/2001     11/04/2003                   5/2/2007        1/1/2008
            //   c c  c    c    c   c            c   c c c ccc              cc   c c cc c
            //   0 1  2    3    4   5            6   7 8 9 012              34   5 6 78 9
            //   0=========================================1=============================

            // Loop through the classes and find the first class
            // of the first promotion
            promotionFirstClassIndex = 0;
            for (int i = 0; i < attendance.Count; i++)
            {
                // i=4, 11/04/2003 >= 11/04/2003 true
                if (attendance[i].Class.ClassStart >=
                    promotions[0].PromotionDate)
                {
                    promotionFirstClassIndex = i;
                    break;
                }
            }

            // Loop through promotions - oldest to newest
            for (int p = 0; p < promotions.Count; p++)
            {
                promotion = promotions[p];

                // Find when the next promotion starts, otherwise
                // if there is no next promotion change all ranks
                // on the classes to the current rank.
                // 0 + 1 = 1 < 3 True
                // 2 + 1 = 3 < 3 False
                if (p + 1 < promotions.Count)
                {
                    // Preload the next promotion date.
                    // 5/2/2007
                    nextPromotionDate =
                        promotions[p + 1].PromotionDate;

                    // Find first class of next promotion. The last
                    // class of the current promotion is therefore
                    // one behind this one. (-1)
                    // i=4; i<15
                    for (int i = promotionFirstClassIndex;
                         i < attendance.Count; i++)
                    {
                        // [04] 11/04/2003 < 5/2/2007 True
                        // [10] 04/31/2003 < 5/2/2007 True
                        // [12] 05/02/2007 < 5/2/2007 False
                        if (attendance[i].Class.ClassStart >=
                            nextPromotionDate)
                        {
                            promotionFirstClassIndex = i;
                            break;
                        }

                        if (attendance[i].rank.iD !=
                            promotion.promotionRank.iD)
                        {
                            // use internals for speed
                            attendance[i].rank =
                                promotion.promotionRank;
                            attendance[i].isSynced = false;
                            attendance[i].Save();
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderContent(HtmlTextWriter output)
        {
            EnsureChildControls();

            DojoPromotionManager    m = new DojoPromotionManager();
            DojoPromotionCollection dojoPromotionCollection = m.GetCollection(string.Empty, "PromotionDate DESC",
                                                                              new DojoPromotionFlags[] {
                DojoPromotionFlags.Member,
                DojoPromotionFlags.MemberPrivateContact,
                DojoPromotionFlags.PromotionRank,
                DojoPromotionFlags.Test,
                DojoPromotionFlags.TestLocation
            });

            bool   rowflag = false;
            string rowCssClass;

            //
            // Render Records
            //
            foreach (DojoPromotion entry in dojoPromotionCollection)
            {
                if (rowflag)
                {
                    rowCssClass = this.defaultRowCssClass;
                }
                else
                {
                    rowCssClass = this.alternateRowCssClass;
                }
                rowflag = !rowflag;

                output.WriteBeginTag("tr");
                output.WriteAttribute("i", entry.iD.ToString());
                output.WriteLine(HtmlTextWriter.TagRightChar);
                output.Indent++;

                //
                // Render ID of Record
                //
//				output.WriteBeginTag("td");
//				output.WriteAttribute("class", rowCssClass);
//				output.Write(HtmlTextWriter.TagRightChar);
//				output.Write(entry.ID);
//				output.WriteEndTag("td");
//				output.WriteLine();

                //
                // Render Main Representation of Record
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("valign", "top");
                output.WriteAttribute("class", rowCssClass);
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write(entry.Member.PrivateContact.FullName);
                output.WriteEndTag("td");
                output.WriteLine();

                //
                // Render Test
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
                if (entry.Test != null)
                {
                    output.Write(entry.Test.Name);
                }
                else
                {
                    output.Write("None");
                }
                output.WriteEndTag("td");
                output.WriteLine();

                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
                if (entry.Test != null)
                {
                    output.Write(entry.Test.TestDate.ToShortDateString());
                }
                else
                {
                    output.Write("None");
                }
                output.WriteEndTag("td");
                output.WriteLine();

                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
                if (entry.Test != null)
                {
                    output.Write(entry.Test.Location.BusinessName);
                }
                else
                {
                    output.Write("None");
                }
                output.WriteEndTag("td");
                output.WriteLine();

                //
                // Render Promotion Date
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write(entry.PromotionDate.ToShortDateString());
                output.WriteEndTag("td");
                output.WriteLine();

                //
                // Render Promotion Rank
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write(entry.PromotionRank.Name);
                output.WriteEndTag("td");
                output.WriteLine();

                //
                // Render Active Promotion
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
                if (entry.Member.Rank == entry.PromotionRank)
                {
                    output.Write("Active");
                }
                else
                {
                    output.Write("&nbsp;");
                }
                output.WriteEndTag("td");
                output.WriteLine();


                output.Indent--;
                output.WriteEndTag("tr");
                output.WriteLine();
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Overwrites and existing DojoPromotion object in the database.
 /// </summary>
 public void Overwrite(int id)
 {
     iD = id;
     DojoPromotionManager._update(this);
     isSynced = true;
 }
Esempio n. 10
0
 public void Delete()
 {
     DojoPromotionManager._delete(this.iD);
     this.iD  = 0;
     isSynced = false;
 }
Esempio n. 11
0
 public DojoPromotion(int id)
 {
     this.iD  = id;
     isSynced = DojoPromotionManager._fill(this);
 }