///<summary>Fills ListShort and ListLong with all claimforms from the db. Also attaches corresponding claimformitems to each.</summary> public static void Refresh() { string command = "SELECT * FROM claimform"; DataTable table = General.GetTable(command); ListLong = new ClaimForm[table.Rows.Count]; ArrayList tempAL = new ArrayList(); for (int i = 0; i < table.Rows.Count; i++) { ListLong[i] = new ClaimForm(); ListLong[i].ClaimFormNum = PIn.PInt(table.Rows[i][0].ToString()); ListLong[i].Description = PIn.PString(table.Rows[i][1].ToString()); ListLong[i].IsHidden = PIn.PBool(table.Rows[i][2].ToString()); ListLong[i].FontName = PIn.PString(table.Rows[i][3].ToString()); ListLong[i].FontSize = PIn.PFloat(table.Rows[i][4].ToString()); ListLong[i].UniqueID = PIn.PString(table.Rows[i][5].ToString()); ListLong[i].PrintImages = PIn.PBool(table.Rows[i][6].ToString()); ListLong[i].OffsetX = PIn.PInt(table.Rows[i][7].ToString()); ListLong[i].OffsetY = PIn.PInt(table.Rows[i][8].ToString()); ListLong[i].Items = ClaimFormItems.GetListForForm(ListLong[i].ClaimFormNum); if (!ListLong[i].IsHidden) { tempAL.Add(ListLong[i]); } } ListShort = new ClaimForm[tempAL.Count]; for (int i = 0; i < ListShort.Length; i++) { ListShort[i] = (ClaimForm)tempAL[i]; } }
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>Updates all claimforms with this unique id including all attached items.</summary> public static void UpdateByUniqueID(ClaimForm cf) { //first get a list of the ClaimFormNums with this UniqueId string command = "SELECT ClaimFormNum FROM claimform WHERE UniqueID ='" + cf.UniqueID.ToString() + "'"; DataTable table = General.GetTable(command); int[] claimFormNums = new int[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { claimFormNums[i] = PIn.PInt(table.Rows[i][0].ToString()); } //loop through each matching claimform for (int i = 0; i < claimFormNums.Length; i++) { cf.ClaimFormNum = claimFormNums[i]; Update(cf); command = "DELETE FROM claimformitem " + "WHERE ClaimFormNum = '" + POut.PInt(claimFormNums[i]) + "'"; General.NonQ(command); for (int j = 0; j < cf.Items.Length; j++) { cf.Items[j].ClaimFormNum = claimFormNums[i]; ClaimFormItems.Insert(cf.Items[j]); } } }
///<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></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(); }
private void butImport_Click(object sender, System.EventArgs e) { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath); if (openDlg.ShowDialog() != DialogResult.OK) { return; } try{ ImportForm(openDlg.FileName, false, ""); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } MessageBox.Show("Imported"); ClaimFormItems.RefreshCache(); changed = true; FillList(); }
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(); }
private void SaveAndClose() { CFIcur.ImageFileName = textImageFileName.Text; CFIcur.FormatString = textFormatString.Text; if (listFieldName.SelectedIndex == -1) { CFIcur.FieldName = ""; } else { CFIcur.FieldName = FieldNames[listFieldName.SelectedIndex]; } if (IsNew) { ClaimFormItems.Insert(CFIcur); } else { ClaimFormItems.Update(CFIcur); } DialogResult = DialogResult.OK; }
private void FormClaimForms_Load(object sender, System.EventArgs e) { ClaimFormItems.RefreshCache(); FillList(); }
private void butDelete_Click(object sender, System.EventArgs e) { ClaimFormItems.Delete(CFIcur); DialogResult = DialogResult.OK; }