protected void buttonSaveValues_Click(object sender, EventArgs e) { //Perform validations Page.Validate(); if (!Page.IsValid) { this.m_errorList.Add(BaseBusiness.ERR_MSG_VALIDATION_FAILED); return; } this.lblUserMessage.Visible = false; int BP = 0; int Credit = 0; int Quant = 0; int Cap = 0; int ST = 0; int Algo1 = 0; int Algo2 = 0; int Algo3 = 0; int Algo4 = 0; string[] names = new string[6]; List <int[]> arrList = new List <int[]>(); int numproducer = 0; int numrefiner = 0; int numbptrader = 0; int numalgo1trader = 0; int numcredit1 = 0; int numcredit2 = 0; int numalgo2trader = 0; int numoutcrytrader = 0; int numoutcryanalyst = 0; int numcap1 = 0; int numcap2 = 0; int numalgo3trader = 0; int numst1 = 0; int numst2 = 0; int numalgo4trader = 0; ContentPlaceHolder cph = (ContentPlaceHolder)this.Master.FindControl("cphPortalMaster"); PlaceHolder PlaceHolder1 = (PlaceHolder)cph.FindControl("PlaceHolder1"); PlaceHolder PlaceHolder2 = (PlaceHolder)cph.FindControl("PlaceHolder2"); PlaceHolder PlaceHolder3 = (PlaceHolder)cph.FindControl("PlaceHolder3"); PlaceHolder PlaceHolder4 = (PlaceHolder)cph.FindControl("PlaceHolder4"); for (int i = 1; i <= idx; i++) { Label student = (Label)PlaceHolder1.FindControl(string.Format("Student{0}", i)); names[i - 1] = student.Text; int bpprod = ValueCheck((CheckBox)PlaceHolder1.FindControl(string.Format("BPprod{0}", i))); int bpref = ValueCheck((CheckBox)PlaceHolder1.FindControl(string.Format("BPref{0}", i))); int bptrader = ValueCheck((CheckBox)PlaceHolder1.FindControl(string.Format("BPtrader{0}", i))); if (bpprod == 1 & bpref == 1) { this.lblErrorMsg.Text = "Cannot assign one competitor as both producer and refiner for BP Commodities Case"; return; } if (bpprod == 1 & bptrader == 1) { this.lblErrorMsg.Text = "Cannot assign one competitor as both producer and trader for BP Commodities Case"; return; } if (bpref == 1 & bptrader == 1) { this.lblErrorMsg.Text = "Cannot assign one competitor as both refiner and trader for BP Commodities Case"; return; } if (bpprod == 1) { BP = 1; numproducer++; } else if (bpref == 1) { BP = 2; numrefiner++; } else if (bptrader == 1) { BP = 3; numbptrader++; } else { BP = 0; } int credit1 = ValueCheck((CheckBox)PlaceHolder3.FindControl(string.Format("Credit1Student{0}", i))); int credit2 = ValueCheck((CheckBox)PlaceHolder3.FindControl(string.Format("Credit2Student{0}", i))); if (credit1 == 1 & credit2 == 1) { this.lblErrorMsg.Text = "Must assign two different team members for Heat #2 " + Day2MorningCase; return; } if (credit1 == 1) { Credit = 1; numcredit1++; } else if (credit2 == 1) { Credit = 2; numcredit2++; } else { Credit = 0; } int outcry1 = ValueCheck((CheckBox)PlaceHolder2.FindControl(string.Format("Outcrytrader{0}", i))); int outcry2 = ValueCheck((CheckBox)PlaceHolder2.FindControl(string.Format("Outcryanalyst{0}", i))); if (outcry1 == 1 & outcry2 == 1) { this.lblErrorMsg.Text = "Cannot assign one competitor as both trader and analyst for Quantitative Outcry Case"; return; } if (outcry1 == 1) { Quant = 1; numoutcrytrader++; } else if (outcry2 == 1) { Quant = 2; numoutcryanalyst++; } else { Quant = 0; } int cap1 = ValueCheck((CheckBox)PlaceHolder2.FindControl(string.Format("Cap1Student{0}", i))); int cap2 = ValueCheck((CheckBox)PlaceHolder2.FindControl(string.Format("Cap2Student{0}", i))); if (cap1 == 1 & cap2 == 1) { this.lblErrorMsg.Text = "Must assign two different team members for Heat #2 " + Day1AfternoonCase; return; } if (cap1 == 1) { Cap = 1; numcap1++; } else if (cap2 == 1) { Cap = 2; numcap2++; } else { Cap = 0; } int st1 = ValueCheck((CheckBox)PlaceHolder4.FindControl(string.Format("ST1Student{0}", i))); int st2 = ValueCheck((CheckBox)PlaceHolder4.FindControl(string.Format("ST2Student{0}", i))); if (st1 == 1 & st2 == 1) { this.lblErrorMsg.Text = "Must assign two different team members for Heat #2 " + Day2AfternoonCase; return; } if (st1 == 1) { ST = 1; numst1++; } else if (st2 == 1) { ST = 2; numst2++; } else { ST = 0; } Algo1 = ValueCheck((CheckBox)PlaceHolder1.FindControl(string.Format("Algo1Student{0}", i))); if (Algo1 == 1) { numalgo1trader++; } Algo2 = ValueCheck((CheckBox)PlaceHolder2.FindControl(string.Format("Algo2Student{0}", i))); if (Algo2 == 1) { numalgo2trader++; } if (Algo2Conflict(algo234[0]) == 1) { if (cap1 == 1 & Algo2 == 1) { this.lblErrorMsg.Text = "One member cannot be competing simultaneously in " + Day1AfternoonCase + " Heat #1 and Algo Case Heat #2"; return; } } else { if (cap2 == 1 & Algo2 == 1) { this.lblErrorMsg.Text = "One member cannot be competing simultaneously in " + Day1AfternoonCase + " Heat #2 and Algo Case Heat #2"; return; } } Algo3 = ValueCheck((CheckBox)PlaceHolder3.FindControl(string.Format("Algo3Student{0}", i))); if (Algo3 == 1) { numalgo3trader++; } if (Algo3Conflict(algo234[1]) == 1) { if (credit1 == 1 & Algo3 == 1) { this.lblErrorMsg.Text = "One member cannot be competing simultaneously in " + Day2MorningCase + " Heat #1 and Algo Case Heat #3"; return; } } else { if (credit2 == 1 & Algo3 == 1) { this.lblErrorMsg.Text = "One member cannot be competing simultaneously in " + Day2MorningCase + " Heat #2 and Algo Case Heat #3"; return; } } Algo4 = ValueCheck((CheckBox)PlaceHolder4.FindControl(string.Format("Algo4Student{0}", i))); if (Algo4 == 1) { numalgo4trader++; } if (Algo4Conflict(algo234[2]) == 1) { if (st1 == 1 & Algo4 == 1) { this.lblErrorMsg.Text = "One member cannot be competing simultaneously in " + Day2AfternoonCase + " Heat #1 and Algo Case Heat #4"; return; } } else { if (st2 == 1 & Algo4 == 1) { this.lblErrorMsg.Text = "One member cannot be competing simultaneously in " + Day2AfternoonCase + " Heat #2 and Algo Case Heat #4"; return; } } arrList.Add(new int[] { BP, Credit, Quant, Cap, ST, Algo1, Algo2, Algo3, Algo4 }); } /*Checking Region*/ //Friday Morning if (numbptrader != 2 | numproducer != 1 | numrefiner != 1) { this.lblErrorMsg.Text = "Must assign 1 producer, 1 refiner, and 2 traders for BP Commodities Case"; return; } if (numalgo1trader != 1) { this.lblErrorMsg.Text = "Must assign one trader for Algorithmic Case Heat #1"; return; } //Saturday Morning if (numcredit1 != 2) { this.lblErrorMsg.Text = "Must assign two competitors to " + Day2MorningCase + " Heat #1"; return; } if (numcredit2 != 2) { this.lblErrorMsg.Text = "Must assign two competitors to " + Day2MorningCase + " Heat #2"; return; } if (numoutcrytrader != 2) { this.lblErrorMsg.Text = "Must assign two competitors as traders for Quantitative Outcry Case"; return; } if (numoutcryanalyst != 2) { this.lblErrorMsg.Text = "Must assign two competitors as analysts for Quantitative Outcry Case"; return; } if (numalgo2trader != 1) { this.lblErrorMsg.Text = "Must assign one trader for Algorithmic Case Heat #2"; return; } //Friday Afternoon if (numcap1 != 2) { this.lblErrorMsg.Text = "Must assign two competitors to " + Day1AfternoonCase + " Heat #1"; return; } if (numcap2 != 2) { this.lblErrorMsg.Text = "Must assign two competitors to " + Day1AfternoonCase + " Heat #2"; return; } if (numalgo3trader != 1) { this.lblErrorMsg.Text = "Must assign one trader for Algorithmic Case Heat #3"; return; } //Saturday Afternoon if (numst1 != 2) { this.lblErrorMsg.Text = "Must assign two competitors to " + Day2AfternoonCase + " Heat #1"; return; } if (numst2 != 2) { this.lblErrorMsg.Text = "Must assign two competitors to " + Day2AfternoonCase + " Heat #2"; return; } if (numalgo4trader != 1) { this.lblErrorMsg.Text = "Must assign one trader for Algorithmic Case Heat #4"; return; } for (int i = 1; i <= idx; i++) { try { //Enable transaction support m_objDA.TransactionEnable(); m_objDA.TransactionBegin(); m_objDA.UpdateRoles(SessionManager.UserID, names[i - 1], arrList[i - 1][0], arrList[i - 1][1], arrList[i - 1][2], arrList[i - 1][3], arrList[i - 1][4], arrList[i - 1][5], arrList[i - 1][6], arrList[i - 1][7], arrList[i - 1][8]); //commit db changes m_objDA.TransactionCommit(); //display successful msg this.lblUserMessage.Visible = true; this.lblUserMessage.Text = "Competition schedule preferences saved successfully"; } //end try catch (Exception ex) { m_objDA.TransactionRollback(); string strError = string.Format("Exception occurred in Registration.buttonSaveValues_Click ... {0}", ex.Message); this.m_errorList.Add(strError); Utilities.CriticalErrorNotification(base.AnyErrorsNoHTML(this.m_errorList), base.m_bSendErrorEmails); } finally { } } } //buttonSaveValues_Click