static ClimberData() { Empty = new ClimberData(int.MinValue); Empty.Age = 0; Empty.Name = Empty.Group = Empty.Team = Empty.Qf = ""; Empty.Photo = null; Empty.Loaded = true; }
private void SetClimberToRight(ClimberData clm) { ClimberData c; if (clm == null) { c = ClimberData.Empty; } else { c = clm; } tbRightAge.Text = c.AgeStr; tbRightGroup.Text = c.Group; tbRightNum.Text = c.IidStr; tbRightQf.Text = c.Qf; tbRightSurname.Text = c.Name; tbRightTeam.Text = c.Team; pbRightPhoto.Image = c.Photo; c.SetToListBox(listBoxRight); }
protected virtual void SetClimberData(ClimberData clm) { ClimberData c; if (clm == null) { c = ClimberData.Empty; } else { c = clm; } tbPartAge.Text = c.AgeStr; tbPartGroup.Text = c.Group; tbPartNumber.Text = c.IidStr; tbPArtQf.Text = c.Qf; tbPartSurname.Text = c.Name; tbPartTeam.Text = c.Team; pbPhoto.Image = c.Photo; c.SetToListBox(listBox1); }
protected virtual bool SetCurrentList() { if (currentList < 0 || currentList >= ShowingLists.Count) { return(false); } SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandText = "SELECT nowClimbing FROM lists(NOLOCK) WHERE iid=" + ShowingLists[currentList].iid.ToString(); object oTmp = cmd.ExecuteScalar(); if (oTmp == null || oTmp == DBNull.Value) { return(false); } int curClm = Convert.ToInt32(oTmp); if (currentClimber != null && curClm == currentClimber.Iid) { return(true); } ClimberData c = new ClimberData(curClm); if (!c.LoadData(cn)) { return(false); } if (this.InvokeRequired) { this.Invoke(new EventHandler(delegate { SetClimberData(c); })); } else { SetClimberData(c); } currentClimber = c; return(true); }
protected override bool SetCurrentList() { if (currentList < 0 || currentList >= ShowingLists.Count) { return(false); } SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandText = "SELECT nowClimbing l, nowClimbingTmp r FROM lists(NOLOCK) WHERE iid=" + ShowingLists[currentList].iid.ToString(); int iRight, iLeft; SqlDataReader rdr = cmd.ExecuteReader(); try { if (rdr.Read()) { if (rdr["l"] != DBNull.Value) { iLeft = Convert.ToInt32(rdr["l"]); } else { iLeft = int.MinValue; } if (rdr["r"] != DBNull.Value) { iRight = Convert.ToInt32(rdr["r"]); } else { iRight = int.MinValue; } } else { return(false); } } finally { rdr.Close(); } if (iLeft <= 0 && iRight <= 0) { return(false); } ClimberData newLeft, newRight; bool leftSet = true, rightSet = true; if (iLeft <= 0) { newLeft = ClimberData.Empty; } else if (iLeft == currentClimber.Iid) { leftSet = false; newLeft = currentClimber; } else if (iLeft == clRight.Iid) { newLeft = clRight; } else { newLeft = new ClimberData(iLeft); if (!newLeft.LoadData(cn)) { return(false); } } if (iRight <= 0) { newRight = ClimberData.Empty; } else if (iRight == clRight.Iid) { rightSet = false; newRight = clRight; } else if (iRight == currentClimber.Iid) { newRight = currentClimber; } else { newRight = new ClimberData(iRight); if (!newRight.LoadData(cn)) { return(false); } } if (this.InvokeRequired) { this.Invoke(new EventHandler(delegate { if (leftSet) { SetClimberData(newLeft); } if (rightSet) { SetClimberToRight(newRight); } })); } else { if (leftSet) { SetClimberData(newLeft); } if (rightSet) { SetClimberToRight(newRight); } } currentClimber = newLeft; clRight = newRight; return(true); }