private void btnResetRingNumbers_Click(object sender, EventArgs e) { bool success = false; RingNumbers ringNumbers = new RingNumbers(_connString); List <RingNumbers> ringNumberList = ringNumbers.GetRing_Numbers(); if (ringNumberList != null && ringNumberList.Count > 0) { foreach (RingNumbers row in ringNumberList) { success = UpdateRingNumber(_show_ID, row.Dog_ID, 0); if (!success) { string msg = string.Format("Failed to reset Ring Number {0}.!", row.Ring_No.ToString()); lblMessage.Text = msg; Utils.LogToFile(msg); break; } } } if (success) { dgvRingNumbers.DataSource = null; dgvRingNumbers.Refresh(); lblMessage.Text = "Ring numbers reset successfully."; } else { lblMessage.Text = "A problem occurred resetting the Ring Numbers!"; } }
protected void PopulateRingNumbersGridView() { RingNumbers ringNumbers = new RingNumbers(_connString); RingNumberList = ringNumbers.GetRing_Numbers(); if (RingNumberList != null && RingNumberList.Count > 0) { Common.RingNumberList = RingNumberList; RingNumberGridView.DataSource = RingNumberList; RingNumberGridView.DataBind(); divRingNumberList.Visible = true; } else { MessageLabel.Text = "No Data for this Show."; divRingNumberList.Visible = false; } }
private void btnAllocateRingNumbers_Click(object sender, EventArgs e) { if (PopulateRingNumbersTable()) { bool success = false; RingNumbers ringNumbers = new RingNumbers(_connString); List <RingNumbers> ringNumberList = ringNumbers.GetRing_Numbers(); if (ringNumberList != null && ringNumberList.Count > 0) { foreach (RingNumbers row in ringNumberList) { success = UpdateRingNumber(_show_ID, row.Dog_ID, row.Ring_No); if (!success) { string msg = string.Format("Failed to update Ring Number {0}.!", row.Ring_No.ToString()); lblMessage.Text = msg; Utils.LogToFile(msg); break; } } } if (success) { PopulateGrid(); lblMessage.Text = "Ring numbers updated successfully."; } else { lblMessage.Text = "A problem occurred updating the Ring Numbers!"; } } else { string msg = "Failed to populate Ring Number table"; lblMessage.Text = msg; Utils.LogToFile(msg); } }
private void PopulateGrid() { DataTable gridData = new DataTable(); gridData.Columns.Clear(); DataColumn dcDogID = new DataColumn("DogID"); DataColumn dcRingNumber = new DataColumn("RingNumber"); DataColumn dcDogKCName = new DataColumn("DogKCName"); DataColumn dcFirstName = new DataColumn("FirstName"); DataColumn dcLastName = new DataColumn("LastName"); gridData.Columns.Add(dcDogID); gridData.Columns.Add(dcRingNumber); gridData.Columns.Add(dcDogKCName); gridData.Columns.Add(dcFirstName); gridData.Columns.Add(dcLastName); object[] dataRow = new object[5]; RingNumbers ringNumbers = new RingNumbers(_connString); List <RingNumbers> ringNumberList = ringNumbers.GetRing_Numbers(); foreach (RingNumbers ringNumber in ringNumberList) { dataRow[0] = ringNumber.Dog_ID; dataRow[1] = ringNumber.Ring_No; dataRow[2] = ringNumber.Dog_KC_Name; dataRow[3] = ringNumber.Person_Forename; dataRow[4] = ringNumber.Person_Surname; gridData.Rows.Add(dataRow); } dgvRingNumbers.DataSource = gridData; dgvRingNumbers.Columns["DogID"].Visible = false; dgvRingNumbers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; //dgvRingNumbers.AutoSize = true; }