private void ActionMoveRule_Click(object sender, EventArgs e) { Button tb = (Button)sender; String[] ids = tb.ID.Split(','); if (ids[1] == ADD) { int hour = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + HOUR + ",moveRule")).Text); String lowPoolName = ((DropDownList)this.Master.FindControl("MainContent").FindControl("," + LOW_POOL_NAME + ",moveRule")).Text; int lowPoolFrom = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + LOW_POOL_FROM + ",moveRule")).Text); int lowPoolTo = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + LOW_POOL_TO + ",moveRule")).Text); int lowPoolWaiting = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + LOW_POOL_WAITING + ",moveRule")).Text); int coopFrom = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + COOP_FROM + ",moveRule")).Text); int coopTo = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + COOP_TO + ",moveRule")).Text); String highPoolName = ((DropDownList)this.Master.FindControl("MainContent").FindControl("," + HIGH_POOL_NAME + ",moveRule")).Text; int highPoolFrom = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + HIGH_POOL_FROM + ",moveRule")).Text); int highPoolTo = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + HIGH_POOL_TO + ",moveRule")).Text); int highPoolWaiting = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + HIGH_POOL_WAITING + ",moveRule")).Text); int value = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + FACTOR_VALUE + ",moveRule")).Text); MoveRule moveRule = new MoveRule(hour, lowPoolName, lowPoolFrom, lowPoolTo, lowPoolWaiting, coopFrom, coopTo, highPoolName, highPoolFrom, highPoolTo, highPoolWaiting, value); Manager.MoveRules.Add(moveRule); } else if (ids[1] == DELETE) { MoveRule moveRule = Manager.MoveRules.Find(fa => fa.Id == ids[0]); Manager.MoveRules.Remove(moveRule); } DataAccess.Save(Manager); Response.Redirect(Request.RawUrl); }
private void MoveRuleNumber_Changed(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; String[] ids = ddl.ID.Split(','); MoveRule moveRule = Manager.MoveRules.Find(fa => fa.Id == ids[0]); if (ids[1] == HOUR) { moveRule.Hour = int.Parse(ddl.Text); } else if (ids[1] == LOW_POOL_FROM) { moveRule.LowPoolNumberFrom = int.Parse(ddl.Text); } else if (ids[1] == LOW_POOL_TO) { moveRule.LowPoolNumberTo = int.Parse(ddl.Text); } else if (ids[1] == LOW_POOL_WAITING) { moveRule.LowPoolWaiting = int.Parse(ddl.Text); } else if (ids[1] == COOP_FROM) { moveRule.CoopNumberFrom = int.Parse(ddl.Text); } else if (ids[1] == COOP_TO) { moveRule.CoopNumberTo = int.Parse(ddl.Text); } else if (ids[1] == HIGH_POOL_FROM) { moveRule.HighPoolNumberFrom = int.Parse(ddl.Text); } else if (ids[1] == HIGH_POOL_TO) { moveRule.HighPoolNumberTo = int.Parse(ddl.Text); } else if (ids[1] == HIGH_POOL_WAITING) { moveRule.HighPoolWaiting = int.Parse(ddl.Text); } else if (ids[1] == FACTOR_VALUE) { moveRule.ToMove = int.Parse(ddl.Text); } DataAccess.Save(Manager); }
private void MoveRulePoolNameDDL_Changed(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; String[] ids = ddl.ID.Split(','); MoveRule moveRule = Manager.MoveRules.Find(fa => fa.Id == ids[0]); if (ids[1] == LOW_POOL_NAME) { moveRule.LowPoolName = ddl.Text; } else if (ids[1] == HIGH_POOL_NAME) { moveRule.HighPoolName = ddl.Text; } DataAccess.Save(Manager); }
private TableCell CreateNumberCell(MoveRule moveRule, String numberType, String number, List <String> numbers) { TableCell numberCell = new TableCell(); DropDownList numberDDL = new DropDownList(); numberDDL.ID = moveRule.Id + "," + numberType + ",moveRule"; numberDDL.DataSource = numbers; numberDDL.DataBind(); numberDDL.SelectedValue = number; if (moveRule.Id != null) { numberDDL.AutoPostBack = true; numberDDL.SelectedIndexChanged += new EventHandler(MoveRuleNumber_Changed); } numberCell.Controls.Add(numberDDL); return(numberCell); }
public int CalculateMoveIntern(Pool highPool, Pool lowPool, Game highPoolGame, Game lowPoolGame) { int highPoolNumber = highPoolGame.NumberOfReservedPlayers; int highPoolWaiting = highPoolGame.WaitingList.Count; int intern = highPoolGame.Dropins.Items.FindAll(d => d.IsCoop && d.Status == InOutNoshow.In).Count; int lowPoolNumber = lowPoolGame.NumberOfReservedPlayers; int lowPoolWaiting = lowPoolGame.WaitingList.Count; int hour = Manager.EastDateTimeNow.Hour; MoveRule moveRule = Manager.MoveRules.Find(mr => hour >= mr.Hour && mr.LowPoolName == lowPool.Name && mr.LowPoolNumberFrom <= lowPoolNumber && lowPoolNumber <= mr.LowPoolNumberTo && // lowPoolWaiting >= mr.LowPoolWaiting && mr.CoopNumberFrom <= intern && intern <= mr.CoopNumberTo && mr.HighPoolName == highPool.Name && // mr.HighPoolNumberFrom <= highPoolNumber && highPoolNumber <= mr.HighPoolNumberTo && highPoolWaiting >= mr.HighPoolWaiting); if (moveRule != null) { return(moveRule.ToMove); } return(0); }
private void CreateMoveRuleTableRow(MoveRule moveRule) { TableRow tableRow = new TableRow(); //Hour tableRow.Cells.Add(CreateNumberCell(moveRule, HOUR, moveRule.Hour.ToString(), Numbers)); //Low pool name tableRow.Cells.Add(CreatePoolNameCell(moveRule, LOW_POOL_NAME, moveRule.LowPoolName)); //Low pool number from tableRow.Cells.Add(CreateNumberCell(moveRule, LOW_POOL_FROM, moveRule.LowPoolNumberFrom.ToString(), Numbers)); //Low pool number to tableRow.Cells.Add(CreateNumberCell(moveRule, LOW_POOL_TO, moveRule.LowPoolNumberTo.ToString(), Numbers)); //Low pool waiting tableRow.Cells.Add(CreateNumberCell(moveRule, LOW_POOL_WAITING, moveRule.LowPoolWaiting.ToString(), Numbers)); //Coop from tableRow.Cells.Add(CreateNumberCell(moveRule, COOP_FROM, moveRule.CoopNumberFrom.ToString(), Numbers)); //Coop to tableRow.Cells.Add(CreateNumberCell(moveRule, COOP_TO, moveRule.CoopNumberTo.ToString(), Numbers)); //high pool name tableRow.Cells.Add(CreatePoolNameCell(moveRule, HIGH_POOL_NAME, moveRule.HighPoolName)); //high pool number from tableRow.Cells.Add(CreateNumberCell(moveRule, HIGH_POOL_FROM, moveRule.HighPoolNumberFrom.ToString(), Numbers)); //high pool number to tableRow.Cells.Add(CreateNumberCell(moveRule, HIGH_POOL_TO, moveRule.HighPoolNumberTo.ToString(), Numbers)); //High pool waiting tableRow.Cells.Add(CreateNumberCell(moveRule, HIGH_POOL_WAITING, moveRule.HighPoolWaiting.ToString(), Numbers)); //Value tableRow.Cells.Add(CreateNumberCell(moveRule, FACTOR_VALUE, moveRule.ToMove.ToString(), toMoveNumbers)); TableCell actionCell = new TableCell(); Button actionBtn = new Button(); actionBtn.ID = moveRule.Id + "," + (moveRule.Id == null ? ADD : DELETE) + ",moveRule"; actionBtn.Text = (moveRule.Id == null) ? ADD : DELETE; actionBtn.Click += new EventHandler(ActionMoveRule_Click); actionBtn.OnClientClick = "if ( !confirm('Are you sure?')) return false;"; actionCell.Controls.Add(actionBtn); tableRow.Cells.Add(actionCell); if (moveRule.Id == null) { tableRow.BackColor = System.Drawing.Color.CadetBlue; } this.MoveRuleTable.Rows.Add(tableRow); }
private TableCell CreatePoolNameCell(MoveRule moveRule, String poolNameType, String poolName) { TableCell poolNameCell = new TableCell(); DropDownList poolNameDDL = new DropDownList(); poolNameDDL.ID = moveRule.Id + "," + poolNameType + ",moveRule"; poolNameDDL.DataSource = Manager.Pools; poolNameDDL.DataTextField = "Name"; poolNameDDL.DataValueField = "Name"; poolNameDDL.DataBind(); poolNameDDL.SelectedValue = poolName; if (moveRule.Id != null) { poolNameDDL.AutoPostBack = true; poolNameDDL.SelectedIndexChanged += new EventHandler(MoveRulePoolNameDDL_Changed); } poolNameCell.Controls.Add(poolNameDDL); return(poolNameCell); }