protected void ClearForm() { lblConfMessage.Text = lblMessageTop.Text = uncClm.LblMessageText = ""; ClimberControl1.ClearForm(); ClimberControl2.ClearForm(); ClimberControl3.ClearForm(); ClimberControl4.ClearForm(); }
protected void btnSubmitClimbers_Click(object sender, EventArgs e) { List <ONLClimberCompLink> clmList = new List <ONLClimberCompLink>(); bool res = true, newClm; ONLClimberCompLink u; if (!ClimberControl1.IsEmpty()) { u = ClimberControl1.createClimber(cbTeam.SelectedValue, out newClm); if (u != null) { clmList.Add(u); } res = res && (u != null); } if (!ClimberControl2.IsEmpty()) { u = ClimberControl2.createClimber(cbTeam.SelectedValue, out newClm); if (u != null) { clmList.Add(u); } res = res && (u != null); } if (!ClimberControl3.IsEmpty()) { u = ClimberControl3.createClimber(cbTeam.SelectedValue, out newClm); if (u != null) { clmList.Add(u); } res = res && (u != null); } if (!ClimberControl4.IsEmpty()) { u = ClimberControl4.createClimber(cbTeam.SelectedValue, out newClm); if (u != null) { clmList.Add(u); } res = res && (u != null); } if (res) { if (clmList.Count > 0) { panelClimbers.Enabled = false; panelConfirm.Visible = true; lblMessageTop.Text = "Пожалуйста, проверьте данные и подтвердите отправку заявки"; } else { lblMessageTop.Text = "Вы не ввели ни одного участника"; } } }
protected void btnConfirm_Click(object sender, EventArgs e) { List <ClimberLink> uList = new List <ClimberLink>(); ONLClimberCompLink c; ONLclimber outClimber; bool newClm; try { if (!ClimberControl1.IsEmpty()) { c = ClimberControl1.createClimber(cbTeam.SelectedValue, out newClm, out outClimber); if (c != null) { uList.Add(new ClimberLink(c, outClimber, newClm)); } } if (!ClimberControl2.IsEmpty()) { c = ClimberControl2.createClimber(cbTeam.SelectedValue, out newClm, out outClimber); if (c != null) { uList.Add(new ClimberLink(c, outClimber, newClm)); } } if (!ClimberControl3.IsEmpty()) { c = ClimberControl3.createClimber(cbTeam.SelectedValue, out newClm, out outClimber); if (c != null) { uList.Add(new ClimberLink(c, outClimber, newClm)); } } if (!ClimberControl4.IsEmpty()) { c = ClimberControl4.createClimber(cbTeam.SelectedValue, out newClm, out outClimber); if (c != null) { uList.Add(new ClimberLink(c, outClimber, newClm)); } } if (User.IsInRole(Constants.ROLE_ADMIN, compID)) { foreach (var v in uList) { v.Link.state = Constants.CLIMBER_CONFIRMED; } } else { ONLoperation currentOp; try { currentOp = dc.ONLoperations.First(op => op.user_id == User.Identity.Name && op.comp_id == compID && op.state == Constants.OP_STATE_NEW); } catch { currentOp = ONLoperation.CreateONLoperation( SortingClass.GetNextIID("ONLOperations", "iid", cn, null), compID, User.Identity.Name, DateTime.UtcNow, Constants.OP_STATE_NEW); dc.ONLoperations.AddObject(currentOp); dc.SaveChanges(); } foreach (var v in uList) { v.Link.updOpIid = currentOp.iid; v.Link.ONLoperation = currentOp; } } foreach (var v in uList) { try { if (v.Link.EntityState != System.Data.EntityState.Detached) { dc.ONLClimberCompLinks.Detach(v.Link); } } catch { } try { if (v.NewClimber && v.Climber.EntityState != System.Data.EntityState.Detached) { dc.ONLclimbers.Detach(v.Climber); } } catch { } } int nErr; string erMsg; InsertClimberLink(uList, dc, out nErr, out erMsg); lblMessageTop.Text = "Заявка на " + (uList.Count - nErr) + " человек принята."; if (nErr > 0) { lblMessageTop.Text += "<br />Произошли ошибки при добавлении следующих участников:<br />" + erMsg; } if (User.IsInRole(Constants.ROLE_ADMIN, compID)) { panelConfirm.Visible = false; ReloadData(); ClearForm(); panelClimbers.Enabled = true; panelConfirm.Visible = false; } else { lblMessageTop.Text += "<br />Для окончательного подтверждения заявки, после ввода всех участников, нажмите на кнопку \"" + "Подтвердить все завки через e-mail\". Старший тренер Вашего региона подтвердит все введённые заявки."; panelConfirm.Visible = false; ReloadData(); uncClm.btnAddAppEnabled = true; uncClm.LblMessageText = ""; } } catch (Exception ex) { lblConfMessage.Text = "Ошибка добавления участников"; if (User.IsInRole(Constants.ROLE_ADMIN, compID)) { lblConfMessage.Text += ": " + ex.Message; } } }