protected void ok_Click(object sender, EventArgs e) { if(dojoPromotionID == 0) obj = new DojoPromotion(); else obj = new DojoPromotion(dojoPromotionID); obj.PromotionDate = DateTime.Parse(tbPromotionDate.Text); if(msMember.SelectedItem != null && msMember.SelectedItem.Value != "Null") obj.Member = DojoMember.NewPlaceHolder( int.Parse(msMember.SelectedItem.Value)); else obj.Member = null; if(msTest.SelectedItem != null && msTest.SelectedItem.Value != "Null") obj.Test = DojoTest.NewPlaceHolder( int.Parse(msTest.SelectedItem.Value)); else obj.Test = null; if(msPromotionRank.SelectedItem != null && msPromotionRank.SelectedItem.Value != "Null") obj.PromotionRank = DojoRank.NewPlaceHolder( int.Parse(msPromotionRank.SelectedItem.Value)); else obj.PromotionRank = null; if(msLastRank.SelectedItem != null && msLastRank.SelectedItem.Value != "Null") obj.LastRank = DojoRank.NewPlaceHolder( int.Parse(msLastRank.SelectedItem.Value)); else obj.LastRank = null; if(msStatus.SelectedItem != null && msStatus.SelectedItem.Value != "Null") obj.Status = DojoPromotionStatus.NewPlaceHolder( int.Parse(msStatus.SelectedItem.Value)); else obj.Status = null; if(editOnAdd) dojoPromotionID = obj.Save(); else obj.Save(); if(resetOnAdd) { tbPromotionDate.Text = DateTime.Now.ToString(); msMember.SelectedIndex = 0; msTest.SelectedIndex = 0; msPromotionRank.SelectedIndex = 0; msLastRank.SelectedIndex = 0; msStatus.SelectedIndex = 0; } OnUpdated(EventArgs.Empty); }
private void btPromote_Click(object sender, EventArgs e) { if (ddTests.SelectedValue != "-1") { DojoMember member = new DojoMember(this.SelectedID); DojoTest test = new DojoTest(int.Parse(ddTests.SelectedValue)); DojoPromotion promotion = new DojoPromotion(); promotion.LastRank = member.Rank; promotion.Member = member; promotion.PromotionDate = test.TestDate; promotion.PromotionRank = member.Rank.PromotionRank; promotion.Test = test; promotion.Save(); member.Rank = member.Rank.PromotionRank; member.RankDate = test.TestDate; member.Save(); // MembershipScan mScan = new MembershipScan(); // mScan.FixAttendance(); Page.ClientScript.RegisterStartupScript(this.GetType(), "WarningMessage", "<script language=\"javascript\">alert('" + member.PrivateContact.FullName + " promoted to " + member.Rank.Name + "." + "');</script>");; } }
private void add() { DojoTest test; DojoMember member; member = new DojoMember(int.Parse(ddMember.SelectedValue)); if (dojoPromotionID == 0) { editDojoPromotion = new DojoPromotion(); } else { editDojoPromotion = new DojoPromotion(dojoPromotionID); } if (ddMember.SelectedItem != null) { editDojoPromotion.Member = member; } else { editDojoPromotion.Member = null; } // If a test is not selected, set the test to null // and the promotion date to the date entered unless // the date entered is blank. In the event it is blank // use the current date. // If the test is selected, use the test and test date // to set the promotion test and promotion date. if (ddTest.SelectedValue == "-1") { editDojoPromotion.Test = null; try { editDojoPromotion.PromotionDate = DateTime.Parse(tbPromotionDate.Text); } catch { editDojoPromotion.PromotionDate = DateTime.Now; tbPromotionDate.Text = DateTime.Now.ToString(); } } else { test = new DojoTest(int.Parse(ddTest.SelectedValue)); editDojoPromotion.Test = test; editDojoPromotion.PromotionDate = test.TestDate; tbPromotionDate.Text = ""; } if (ddPromotionRank.SelectedItem != null) { editDojoPromotion.PromotionRank = DojoRank.NewPlaceHolder( int.Parse(ddPromotionRank.SelectedItem.Value)); } else { editDojoPromotion.PromotionRank = null; } // If the Last Rank is "Current" then get the member's // last rank and set it. if (ddLastRank.SelectedValue == "-1") { editDojoPromotion.LastRank = member.Rank; } else { if (ddLastRank.SelectedItem != null) { editDojoPromotion.LastRank = DojoRank.NewPlaceHolder( int.Parse(ddLastRank.SelectedItem.Value)); } else { editDojoPromotion.LastRank = null; } } // Run an attendace adjustment on this rank. MembershipScan scan = new MembershipScan(); scan.AttendanceAdjustment(editDojoPromotion.Member); dojoPromotionID = editDojoPromotion.Save(); }