private void butOK_Click(object sender, EventArgs e) { if (textDate.errorProvider1.GetError(textDate) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (textDate.Text == "") { MsgBox.Show(this, "Please enter a date."); return; } if (comboSopCode.SelectedIndex == -1) { MsgBox.Show(this, "Please select an Sop Code."); return; } //Make sure there is not already a payor type entered with the selected date. //If there is, they should edit the existing one for that date. There should not be two payor types that start on the same date. List <PayorType> listPayorTypes = PayorTypes.Refresh(PayorTypeCur.PatNum); for (int i = 0; i < listPayorTypes.Count; i++) { //if updating an existing payor type, move past the current one if (listPayorTypes[i].PayorTypeNum == PayorTypeCur.PayorTypeNum) { continue; } if (listPayorTypes[i].DateStart == PIn.Date(textDate.Text)) { MsgBox.Show(this, "There is already a payor type with the selected start date. Either change the date of this payor type or edit the existing payor type with this date."); return; } } PayorTypeCur.SopCode = Sops.Listt[comboSopCode.SelectedIndex].SopCode; PayorTypeCur.Note = textNote.Text; PayorTypeCur.DateStart = PIn.Date(textDate.Text); if (IsNew) { PayorTypes.Insert(PayorTypeCur); } else { PayorTypes.Update(PayorTypeCur); } DialogResult = DialogResult.OK; }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col = new GridColumn("Date Start", 70); col.TextAlign = HorizontalAlignment.Center; gridMain.ListGridColumns.Add(col); col = new GridColumn("Date End", 70); col.TextAlign = HorizontalAlignment.Center; gridMain.ListGridColumns.Add(col); col = new GridColumn("SOP Code", 70); gridMain.ListGridColumns.Add(col); col = new GridColumn("Description", 250); gridMain.ListGridColumns.Add(col); col = new GridColumn("Note", 100); gridMain.ListGridColumns.Add(col); ListPayorTypes = PayorTypes.Refresh(PatCur.PatNum); gridMain.ListGridRows.Clear(); GridRow row; for (int i = 0; i < ListPayorTypes.Count; i++) { row = new GridRow(); row.Cells.Add(ListPayorTypes[i].DateStart.ToShortDateString()); if (i == ListPayorTypes.Count - 1) { row.Cells.Add("Current"); } else { row.Cells.Add(ListPayorTypes[i + 1].DateStart.ToShortDateString()); } row.Cells.Add(ListPayorTypes[i].SopCode); row.Cells.Add(Sops.GetDescriptionFromCode(ListPayorTypes[i].SopCode)); row.Cells.Add(ListPayorTypes[i].Note); gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); }