private void butCopy_Click(object sender, System.EventArgs e) { if (listClaimForms.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select an item first.")); return; } ClaimForm ClaimFormCur = ClaimForms.ListLong[listClaimForms.SelectedIndex].Copy(); long oldClaimFormNum = ClaimFormCur.ClaimFormNum; ClaimFormCur.UniqueID = ""; //designates it as a user added claimform ClaimForms.Insert(ClaimFormCur); //this duplicates the original claimform, but no items. long newClaimFormNum = ClaimFormCur.ClaimFormNum; //ClaimFormItems.GetListForForm(ClaimForms.ListLong[listClaimForms.SelectedIndex].ClaimFormNum); for (int i = 0; i < ClaimFormCur.Items.Length; i++) { //ClaimFormItems.Cur=ClaimFormItems.ListForForm[i]; ClaimFormCur.Items[i].ClaimFormNum = newClaimFormNum; ClaimFormItems.Insert(ClaimFormCur.Items[i]); } ClaimFormItems.RefreshCache(); changed = true; FillList(); }
///<Summary>Can be called externally as part of the update sequence. Surround with try catch. Returns the ClaimFormNum of the new ClaimForm if it inserted a new claimform.</Summary> public static int ImportForm(string path, bool isUpdateSequence) { if (!File.Exists(path)) { throw new ApplicationException(Lan.g("FormClaimForm", "File does not exist.")); } ClaimForm tempClaimForm = new ClaimForm(); XmlSerializer serializer = new XmlSerializer(typeof(ClaimForm)); try{ using (TextReader reader = new StreamReader(path)){ tempClaimForm = (ClaimForm)serializer.Deserialize(reader); } } catch { throw new ApplicationException(Lan.g("FormClaimForm", "Invalid file format")); } int retVal = 0; bool isNew = true; if (tempClaimForm.UniqueID != "") //if it's blank, it's always inserted. { for (int i = 0; i < ClaimForms.ListLong.Length; i++) { if (ClaimForms.ListLong[i].UniqueID == tempClaimForm.UniqueID) { isNew = false; } } } if (isNew) { ClaimForms.Insert(tempClaimForm); //now we have a primary key. retVal = tempClaimForm.ClaimFormNum; for (int j = 0; j < tempClaimForm.Items.Length; j++) { tempClaimForm.Items[j].ClaimFormNum = tempClaimForm.ClaimFormNum; ClaimFormItems.Insert(tempClaimForm.Items[j]); } } else { if (!isUpdateSequence) { if (MessageBox.Show(tempClaimForm.Description + " already exists. Replace?", "", MessageBoxButtons.OKCancel) != DialogResult.OK) { return(0); } } ClaimForms.UpdateByUniqueID(tempClaimForm); } return(retVal); //only if uniqueID }
///<summary>Copy an internal form over to a new custom form.</summary> private void butCopy_Click(object sender, EventArgs e) { if (gridInternal.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select an item from the internal grid to copy over to the custom grid.")); return; } //just insert it into the db. ClaimForm claimFormInternal = (ClaimForm)gridInternal.Rows[gridInternal.GetSelectedIndex()].Tag; long claimFormNum = ClaimForms.Insert(claimFormInternal, true); FillGridCustom(); }
///<summary>Duplicate a custom claim form.</summary> private void butDuplicate_Click(object sender, System.EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a Custom Claim Form first."); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; long oldClaimFormNum = claimFormCur.ClaimFormNum; //claimFormCur.UniqueID="";//designates it as a user added claimform ClaimForms.Insert(claimFormCur, true); //this duplicates the original claimform, but no items. changed = true; FillGridCustom(); }
private void FillGridInternal() { gridInternal.BeginUpdate(); gridInternal.Columns.Clear(); gridInternal.Columns.Add(new ODGridColumn(Lan.g("TableClaimFormsInternal", "ClaimForm"), 150)); gridInternal.Rows.Clear(); foreach (ClaimForm internalForm in ClaimForms.GetInternalClaims()) { ODGridRow row = new ODGridRow(); row.Cells.Add(internalForm.Description); row.Tag = internalForm; gridInternal.Rows.Add(row); } gridInternal.EndUpdate(); }
///<summary>Add a custom claim form.</summary> private void butAdd_Click(object sender, System.EventArgs e) { ClaimForm ClaimFormCur = new ClaimForm(); ClaimForms.Insert(ClaimFormCur, false); ClaimFormCur.IsNew = true; FormClaimFormEdit FormCFE = new FormClaimFormEdit(ClaimFormCur); FormCFE.ShowDialog(); if (FormCFE.DialogResult != DialogResult.OK) { return; } changed = true; FillGridCustom(); }
private void butReassign_Click(object sender, EventArgs e) { if (listClaimForms.SelectedIndex == -1) { MsgBox.Show(this, "Please select a claimform from the list at the left first."); return; } if (comboReassign.SelectedIndex == -1) { MsgBox.Show(this, "Please select a claimform from the list below."); return; } long result = ClaimForms.Reassign(ClaimForms.ListLong[listClaimForms.SelectedIndex].ClaimFormNum, ClaimForms.ListLong[comboReassign.SelectedIndex].ClaimFormNum); MessageBox.Show(result.ToString() + Lan.g(this, " plans changed.")); }
private void butAdd_Click(object sender, System.EventArgs e) { ClaimForm ClaimFormCur = new ClaimForm(); ClaimForms.Insert(ClaimFormCur); FormClaimFormEdit FormCFE = new FormClaimFormEdit(); FormCFE.ClaimFormCur = ClaimFormCur; FormCFE.IsNew = true; FormCFE.ShowDialog(); if (FormCFE.DialogResult != DialogResult.OK) { return; } changed = true; //ClaimFormItems refreshed within FormCFE FillList(); }
///<summary>Reassigns all current insurance plans using the selected claimform to another claimform.</summary> private void butReassign_Click(object sender, EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a claimform from the list at the left first."); return; } if (comboReassign.SelectedIndex == -1) { MsgBox.Show(this, "Please select a claimform from the list below."); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; ClaimForm claimFormNew = ((ODBoxItem <ClaimForm>)comboReassign.SelectedItem).Tag; long result = ClaimForms.Reassign(claimFormCur.ClaimFormNum, claimFormNew.ClaimFormNum); MessageBox.Show(result.ToString() + Lan.g(this, " plans changed.")); }
///<summary></summary> private void FillGridCustom() { ClaimFormItems.RefreshCache(); ClaimForms.RefreshCache(); comboReassign.Items.Clear(); gridCustom.BeginUpdate(); gridCustom.Columns.Clear(); gridCustom.Columns.Add(new ODGridColumn(Lan.g("TableClaimFormsCustom", "ClaimForm"), 145)); gridCustom.Columns.Add(new ODGridColumn(Lan.g("TableClaimFormsCustom", "Default"), 50, HorizontalAlignment.Center)); gridCustom.Columns.Add(new ODGridColumn(Lan.g("TableClaimFormsCustom", "Hidden"), 0, HorizontalAlignment.Center)); gridCustom.Rows.Clear(); string description; foreach (ClaimForm claimFormCur in ClaimForms.GetDeepCopy()) { description = claimFormCur.Description; ODGridRow row = new ODGridRow(); row.Cells.Add(claimFormCur.Description); if (claimFormCur.ClaimFormNum == PrefC.GetLong(PrefName.DefaultClaimForm)) { description += " " + Lan.g(this, "(default)"); row.Cells.Add("X"); } else { row.Cells.Add(""); } if (claimFormCur.IsHidden) { description += " " + Lan.g(this, "(hidden)"); row.Cells.Add("X"); } else { row.Cells.Add(""); } row.Tag = claimFormCur; gridCustom.Rows.Add(row); comboReassign.Items.Add(new ODBoxItem <ClaimForm>(description, claimFormCur)); } gridCustom.EndUpdate(); }
///<summary></summary> private void FillList() { ClaimForms.Refresh(); listClaimForms.Items.Clear(); string description; for (int i = 0; i < ClaimForms.ListLong.Length; i++) { description = ClaimForms.ListLong[i].Description; if (ClaimForms.ListLong[i].IsHidden) { description += " (hidden)"; } if (ClaimForms.ListLong[i].ClaimFormNum == PrefB.GetInt("DefaultClaimForm")) { description += " (default)"; } listClaimForms.Items.Add(description); } }
///<summary>Delete an unusued custom claim form.</summary> private void butDelete_Click(object sender, System.EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select a Custom Claim Form first.")); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete custom claim form?")) { return; } if (!ClaimForms.Delete(claimFormCur)) { MsgBox.Show(this, "Claim form is already in use."); return; } changed = true; FillGridCustom(); }
private void butDelete_Click(object sender, System.EventArgs e) { if (listClaimForms.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select an item first.")); return; } //ClaimForms.Cur=ClaimForms.ListLong[listClaimForms.SelectedIndex]; if (ClaimForms.ListLong[listClaimForms.SelectedIndex].UniqueID != "") { MessageBox.Show(Lan.g(this, "Not allowed to delete a premade claimform, but you can hide it instead.")); return; } if (!ClaimForms.Delete(ClaimForms.ListLong[listClaimForms.SelectedIndex])) { MessageBox.Show(Lan.g(this, "Claim form is already in use.")); return; } changed = true; ClaimFormItems.RefreshCache(); FillList(); }
///<summary></summary> private void FillList() { ClaimForms.RefreshCache(); listClaimForms.Items.Clear(); comboReassign.Items.Clear(); string description; for (int i = 0; i < ClaimForms.ListLong.Length; i++) { description = ClaimForms.ListLong[i].Description; if (ClaimForms.ListLong[i].IsHidden) { description += " (hidden)"; } if (ClaimForms.ListLong[i].ClaimFormNum == PrefC.GetLong(PrefName.DefaultClaimForm)) { description += " (default)"; } listClaimForms.Items.Add(description); comboReassign.Items.Add(description); } }
///<summary>Import an XML file into the custom claim forms list.</summary> private void butImport_Click(object sender, System.EventArgs e) { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath); ClaimForm claimForm; if (openDlg.ShowDialog() != DialogResult.OK) { return; } try{ claimForm = ClaimForms.DeserializeClaimForm(openDlg.FileName, ""); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } ClaimForms.Insert(claimForm, true); //now we have a primary key. MsgBox.Show(this, "Imported"); changed = true; FillGridCustom(); }