private void butOK_Click(object sender, System.EventArgs e) { if (textDescription.Text == "") { MsgBox.Show(this, "Please enter a description"); return; } if (this.textDataFileName.Text == "" || this.textTemplateName.Text == "") { MsgBox.Show(this, "Filenames cannot be left blank."); return; } if (comboCategory.SelectedIndex == -1) { MsgBox.Show(this, "Please select a category"); return; } if (listPatSelect.SelectedIndices.Count == 0 && listReferral.SelectedIndices.Count == 0) { MsgBox.Show(this, "Please select at least one field."); return; } Cursor.Current = Cursors.WaitCursor; LetterMergeCur.Description = textDescription.Text; LetterMergeCur.TemplateName = textTemplateName.Text; LetterMergeCur.DataFileName = textDataFileName.Text; LetterMergeCur.Category = DefB.Short[(int)DefCat.LetterMergeCats][comboCategory.SelectedIndex].DefNum; if (IsNew) { LetterMerges.Insert(LetterMergeCur); } else { LetterMerges.Update(LetterMergeCur); } LetterMergeFields.DeleteForLetter(LetterMergeCur.LetterMergeNum); LetterMergeField field; for (int i = 0; i < listPatSelect.SelectedItems.Count; i++) { field = new LetterMergeField(); field.LetterMergeNum = LetterMergeCur.LetterMergeNum; field.FieldName = (string)listPatSelect.SelectedItems[i]; //(string)listPatSelect.Items[listPatSelect.SelectedIndices[i]]; LetterMergeFields.Insert(field); } for (int i = 0; i < listReferral.SelectedItems.Count; i++) { field = new LetterMergeField(); field.LetterMergeNum = LetterMergeCur.LetterMergeNum; field.FieldName = "referral." + (string)listReferral.SelectedItems[i]; LetterMergeFields.Insert(field); } Cursor.Current = Cursors.Default; DialogResult = DialogResult.OK; }
private void FillLetters() { listLetters.Items.Clear(); if (listCategories.SelectedIndex == -1) { ListForCat = new List <LetterMerge>(); return; } LetterMergeFields.RefreshCache(); LetterMerges.RefreshCache(); ListForCat = LetterMerges.GetListForCat(listCategories.SelectedIndex); for (int i = 0; i < ListForCat.Count; i++) { listLetters.Items.Add(ListForCat[i].Description); } }
///<summary>Must have run LetterMergeFields first.</summary> public static void Refresh() { string command = "SELECT * FROM lettermerge ORDER BY Description"; DataTable table = General.GetTable(command); List = new LetterMerge[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { List[i] = new LetterMerge(); List[i].LetterMergeNum = PIn.PInt(table.Rows[i][0].ToString()); List[i].Description = PIn.PString(table.Rows[i][1].ToString()); List[i].TemplateName = PIn.PString(table.Rows[i][2].ToString()); List[i].DataFileName = PIn.PString(table.Rows[i][3].ToString()); List[i].Category = PIn.PInt(table.Rows[i][4].ToString()); List[i].Fields = LetterMergeFields.GetForLetter(List[i].LetterMergeNum); } }