public void RefreshCustomers() { dgvCustomerData.DataSource = null; customerList = CustomerRoster.getCustomerList(); dgvCustomerData.DataSource = customerList; FormatGridView(); }
private void DgvCustomerData_CellLeave(object sender, DataGridViewCellEventArgs e) { DataGridView gridView = sender as DataGridView; if (gridView.IsCurrentCellDirty) { gridView.CommitEdit(DataGridViewDataErrorContexts.Commit); //DataRowView currentRowView = (DataRowView)gridView.Rows[e.RowIndex].DataBoundItem; //DataRow currentRow = currentRowView.Row; CustomerRoster modifiedCustomer = (CustomerRoster)gridView.Rows[e.RowIndex].DataBoundItem; //CustomerRowToObject(currentRow, modifiedCustomer); CustomerRoster match = modifiedCustomers.Where(cust => cust.Customer_ID == modifiedCustomer.Customer_ID).FirstOrDefault(); if (modifiedCustomers.Contains(match)) // if we captured this customer before, delete the previous snapshot. { modifiedCustomers.Remove(match); } modifiedCustomers.Add(modifiedCustomer); // add the new changes to the queue regardless. gridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Aqua; if (!btUpdate.Enabled) { btUpdate.Enabled = true; } } }
public NewReferral(int CustomerID) { InitializeComponent(); CustomerRoster customer = CustomerRoster.getCustomerList() .FirstOrDefault(x => x.Customer_ID == CustomerID); lblCustomerName.Text = customer.FirstName + " " + customer.LastName; }
private void BtUpdate_Click(object sender, EventArgs e) { foreach (CustomerRoster customer in modifiedCustomers) { CustomerRoster.updateCustomer(customer); } //ClearDirtyRows(); // clears the selection collection and resets rows to default colors. RefreshCustomers(); }
private void BtSubmit_Click(object sender, EventArgs e) { int testInt; try { cust.AgeGroup = chbYouth.Checked ? "Y" : "A"; cust.SelfCertified = chbSelfCert.Checked ? "Yes" : "No"; cust.FirstName = tbFirstName.Text; cust.MiddleInitial = tbMiddleInitial.Text; cust.LastName = tbLastName.Text; cust.DOB = dtpDOB.Value; cust.PhoneNumber = tbPhoneNumber.Text; cust.Staff = tbStaff.Text; if (cbEnrollmentType.SelectedItem != null) { cust.EnrollmentType = cbEnrollmentType.SelectedItem.ToString(); } else { cust.EnrollmentType = "New"; } cust.ReasonForVisit = tbReasonForVisit.Text; cust.IntakeDate = dtpIntake.Value; if (int.TryParse(tbISIS_ID.Text, out testInt)) { cust.ISIS_ID = testInt; } else { cust.ISIS_ID = null; } cust.PSAExpDate = dtpPSAExp.Value; cust.YouthSchool = tbYouthSchool.Text; cust.StreetAddress = tbAddress.Text; cust.CityName = tbCity.Text; cust.StateName = tbState.Text; cust.Zip = tbZip.Text; cust.Email = tbEmail.Text; cust.Notes = rtbNotes.Text; } catch (Exception ex) { MessageBox.Show( "Error capturing customer", "There was a problem reading the data! \n\n" + $"Exception: {ex}", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { CustomerRoster.addCustomerRoster(cust); this.Close(); } catch (Exception ex) { MessageBox.Show( "Error adding customer", "There was a problem adding to the database! \n\n " + $"Exception: {ex}", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void FillRosterTable() { const int PYStartNumber = 1; const int PY_ID_CONST = 45; if (values != null && values.Count > 0) { Console.WriteLine("PY RosterID, LastName, FirstName"); foreach (var row in values) { // Print columns A and E, which correspond to indices 0 and 4. if (row.Count > 3) { Console.WriteLine("{0}, {1}, {2}", row[1], row[2], row[3]); //CustomerRoster tempCust = new CustomerRoster(); if (Int32.TryParse(row[1].ToString(), out int tempRecordID)) { if (tempRecordID < PYStartNumber) { continue; } } else { Console.Error.WriteLine($"Could not parse rosterID!\n\nRecord Number: {row[1]}"); } if (Int32.TryParse((row.Count > 11 ? row[11] : "").ToString(), out int tempISIS_ID)) { // do something? } else { Console.Error.WriteLine($"Could not parse rosterID!\n\nRecord Number: {row[1]}"); } // end ISIS_ID parse. if (DateTime.TryParse((row.Count > 4 ? row[4] : "").ToString(), out DateTime tempDOB)) { // do something? } else { Console.Error.WriteLine($"Could not parse DOB!\n\nRecord Number: {row[1]}"); } // end DOBParse if (DateTime.TryParse((row.Count > 5 ? row[5] : "").ToString(), out DateTime tempDOS)) { // do something? } else { Console.Error.WriteLine($"Could not parse DOS!\n\nRecord Number: {row[1]}"); } // end DateOfService Parse. if (DateTime.TryParse((row.Count > 10 ? row[10] : "").ToString(), out DateTime tempSubmissionDate)) { //tempCust.RosterID = tempInt; } else { Console.Error.WriteLine($"Could not parse SubmissionDate!\n\nRecord Number: {row[1]}"); } // end SubmissionDate parse. if (DateTime.TryParse((row.Count > 13 ? row[13] : "").ToString(), out DateTime tempIntakeDate)) { //tempCust.RosterID = tempInt; } else { Console.Error.WriteLine($"Could not parse IntakeDate!\n\nRecord Number: {row[1]}"); } // end IntakeDate parse. if (DateTime.TryParse((row.Count > 15 ? row[15] : "").ToString(), out DateTime tempPSAExpDate)) { //tempCust.RosterID = tempInt; } else { Console.Error.WriteLine($"Could not parse PSAExpDate!\n\nRecord Number: {row[1]}"); tempPSAExpDate = DateTime.Parse("1/1/1777"); } // end PSAExpDate parse. customerRecordsList.Add(new CustomerRoster { RosterID = tempRecordID, LastName = (string)row[2], FirstName = (string)row[3], DOB = tempDOB, DateOfService = tempDOS, Staff = row.Count > 6 ? (string)row[6] : null, EnrollmentType = row.Count > 7 ? (string)row[7] : null, ReferredBy = row.Count > 8 ? (string)row[8] : null, ReasonForVisit = row.Count > 9 ? (string)row[9] : null, SubmissionDate = tempSubmissionDate, ISIS_ID = tempISIS_ID, SelfCertified = row.Count > 12 ? (string)row[12] : null, IntakeDate = tempIntakeDate, AgeGroup = row.Count > 14 ? (string)row[14] : null, PSAExpDate = tempPSAExpDate, YouthSchool = row.Count > 16 ? (string)row[16] : null, Notes = row.Count > 19 ? (string)row[17] + row[18] + row[19] : null, PhoneNumber = row.Count > 20 ? (string)row[20] : null, Email = row.Count > 21 ? (string)row[21] : null, PY_ID = PY_ID_CONST }); } } } else { Console.WriteLine("No data found."); } SqlConnection conn = new SqlConnection(ConnectionAccess.ListingsString); conn.Open(); foreach (CustomerRoster cust in customerRecordsList) { try { CustomerRoster.addCustomerRosterBatch(conn, cust); } catch (Exception ex) { Console.Error.WriteLine("Error adding customer to the database!"); Console.Error.WriteLine($"Customer Record#: {cust.RosterID}\nCustomerName: {cust.FirstName + " " + cust.LastName}\n"); Console.Error.WriteLine($"Exception: {ex}\n\n"); } } conn.Close(); Console.WriteLine("Roster Records imported. Press ENTER Key To Continue..."); Console.Read(); }