private bool TestForHHMember() { string[] splitName = tbHHName.Text.Split(','); panel1.Visible = false; lvwPeople.Items.Clear(); HHMembers clsTmpHHM = new HHMembers(CCFBGlobal.connectionString); if (clsTmpHHM.openWhere("WHERE LastName = '" + splitName[0].Trim() + "' AND FirstName = '" + splitName[0].Trim() + "'", true) == true) { for (int i = 0; i < clsTmpHHM.RowCount; i++) { clsTmpHHM.SetRecord(i); ListViewItem lvItm = new ListViewItem(clsTmpHHM.LastName); lvItm.SubItems.Add(clsTmpHHM.FirstName); lvItm.SubItems.Add(clsTmpHHM.Birthdate.ToShortDateString()); lvItm.SubItems.Add(clsTmpHHM.Age.ToString()); lvItm.SubItems.Add(clsTmpHHM.HouseholdID.ToString()); if (i % 2 == 0) { lvItm.BackColor = Color.White; } else { lvItm.BackColor = Color.LightYellow; } lvwPeople.Items.Add(lvItm); //TestForHousehold(clsTmpHHM.HouseholdID); } panel1.Visible = true; return(true); } return(TestForHousehold(0)); }
private bool TestForHHMember() { panel1.Visible = false; HHMembers clsTmpHHM = new HHMembers(CCFBGlobal.connectionString); lvwPeople.Items.Clear(); lvwHouseholds.Items.Clear(); if (clsTmpHHM.openWhere(" Where LastName = '" + tbLastName.Text + "' AND FirstName = '" + tbFirstName.Text + "'", true) == true) { for (int i = 0; i < clsTmpHHM.RowCount; i++) { clsTmpHHM.SetRecord(i); ListViewItem lvItm = new ListViewItem(clsTmpHHM.LastName); lvItm.SubItems.Add(clsTmpHHM.FirstName); lvItm.SubItems.Add(clsTmpHHM.Birthdate.ToShortDateString()); lvItm.SubItems.Add(clsTmpHHM.Age.ToString()); lvItm.SubItems.Add(clsTmpHHM.HouseholdID.ToString()); if (i % 2 == 0) { lvItm.BackColor = Color.White; } else { lvItm.BackColor = Color.LightYellow; } lvwPeople.Items.Add(lvItm); TestForHousehold(clsTmpHHM.HouseholdID); } panel1.Visible = true; return(true); } if (addMember == false) { return(TestForHousehold(0)); } else { return(false); } }
public void createReport(string templatePath) { Application m_oExcelApp; _Workbook m_oBook; _Worksheet m_oSheet; m_oExcelApp = new Application(); m_oExcelApp.WindowState = XlWindowState.xlNormal; m_oExcelApp.Visible = true; m_oSheet = null; object missing = Type.Missing; Object oTemplatePath = templatePath; try { m_oBook = m_oExcelApp.Workbooks.Open(templatePath , false, false, missing, missing, missing, true, missing, missing, true , missing, missing, false, missing, true); Debug.Print(m_oBook.Sheets.Count.ToString()); string saveAs = savePath + "UID" + clsHH.ID.ToString() + ".xls"; if (File.Exists(saveAs) == true) { File.Delete(saveAs.ToString()); } m_oBook.SaveAs(saveAs, XlFileFormat.xlWorkbookNormal, null, null, null, null, XlSaveAsAccessMode.xlShared, null, null, null, null, null); m_oSheet = (_Worksheet)m_oBook.Sheets[1]; string tmpA = "Yes"; string tmpC = "No"; string tmpDislikes = ""; m_oSheet.Cells[1, 2] = CCFBPrefs.FoodBankName + ": Food Order"; m_oSheet.Cells[4, 2] = "( " + clsHH.ID.ToString() + " ) " + clsHH.Name; m_oSheet.Cells[5, 3] = clsTLItm.HHMemID; m_oSheet.Cells[6, 3] = clsTLItm.TotalFamily.ToString(); if (clsTLItm.Homeless == true) { m_oSheet.Cells[7, 3] = tmpA; } else { m_oSheet.Cells[7, 3] = tmpC; } tmpA = ""; tmpC = ""; for (int i = 0; i < clsHH.TotalFamily; i++) { clsHHM.SetRecord(i); if (clsHHM.Inactive == false) { if (clsHHM.Notes != "") { if (tmpDislikes != "") { tmpDislikes += ", "; } tmpDislikes += clsHHM.Notes; } if (clsHHM.Age > 18) { if (tmpA != "") { tmpA += ", "; } tmpA += clsHHM.Age.ToString(); } else { if (tmpC != "") { tmpC += ", "; } tmpC += clsHHM.Age.ToString(); } } } m_oSheet.Cells[8, 3] = tmpA; m_oSheet.Cells[9, 3] = tmpC; m_oSheet.Cells[10, 3] = clsTLItm.FoodSvcList; m_oSheet.Cells[11, 3] = tmpDislikes; if (clsHH.UserFlag9 == true) { m_oSheet.Cells[12, 3] = "Yes"; } else { m_oSheet.Cells[12, 3] = "No"; } m_oSheet.Cells[13, 3] = rptDate; m_oSheet.Calculate(); m_oBook.Save(); m_oBook.PrintOutEx(); m_oExcelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(m_oExcelApp); m_oSheet = null; m_oBook = null; m_oExcelApp = null; error = false; //CCFBGlobal.openDocumentOutsideCCFB(saveAs.ToString()); } catch (Exception ex) { m_oExcelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(m_oExcelApp); CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString()); error = true; m_oSheet = null; m_oBook = null; m_oExcelApp = null; //MessageBox.Show("Error accessing Excel: " + ex.ToString()); } }
public void createReport(string foodBankName, string templatePath) { savePath = CCFBGlobal.pathFamilyCards + DateTime.Today.Year.ToString() + "\\" + idText.Substring(0, 2) + "\\" + idText.Substring(2, 2) + "\\"; CCFBGlobal.verifyPath(savePath); fullsavepath = savePath + "tmp"; if (File.Exists(templatePath) == false) { templatePath = CCFBGlobal.fb3TemplatesPath + "FamilyCardSigPadENG.doc"; } if (File.Exists(templatePath)) { Object missing = System.Reflection.Missing.Value; oWord.Visible = true; Object oTemplatePath = templatePath; try { oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing); oWordDoc.SaveAs2(fullsavepath, ref oMissing); fillBookMark("FoodBankName", foodBankName); fillBookMark("FBName1", foodBankName); fillBookMark("FBName2", foodBankName); fillBookMark("Date", DateTime.Today.ToShortDateString()); fillBookMark("clientID", clsHH.ID.ToString()); Table table = oWordDoc.Tables[1]; //table.Cell(1, 1).Range.Text = clsHH.Name; string fullAddress = clsHH.Address; if (clsHH.AptNbr.Trim() != "") { fullAddress += " Unit " + clsHH.AptNbr.Trim(); } table.Cell(3, 1).Range.Text = fullAddress; table.Cell(5, 1).Range.Text = clsHH.City + ", " + clsHH.State; table.Cell(5, 2).Range.Text = clsHH.Zipcode; int row = 2; Table table2 = oWordDoc.Tables[2]; for (int i = 0; i < clsHhM.RowCount; i++) { clsHhM.SetRecord(i); if (clsHhM.HeadHH == true) { if (clsHhM.UseAge == false) { table.Cell(7, 1).Range.Text = CCFBGlobal.ValidDateString(clsHhM.Birthdate); } else { table.Cell(7, 1).Range.Text = clsHhM.Age.ToString(); } table.Cell(7, 2).Range.Text = clsHhM.Sex; table.Cell(7, 3).Range.Text = clsHH.Phone; table.Cell(1, 3).Range.Text = clsHhM.LastName; table.Cell(1, 1).Range.Text = clsHhM.FirstName; } else { if (clsHhM.Inactive == false) { table2.Cell(row, 1).Range.Text = clsHhM.LastName + ", " + clsHhM.FirstName; if (clsHhM.UseAge == true) { table2.Cell(row, 2).Range.Text = clsHhM.Age.ToString(); } else { table2.Cell(row, 2).Range.Text = CCFBGlobal.ValidDateString(clsHhM.Birthdate); } table2.Cell(row, 3).Range.Text = clsHhM.Sex; if (table2.Columns.Count > 3) { if (clsHhM.IsDisabled == true) { table2.Cell(row, 4).Range.Text = "X"; } if (clsHhM.SpecialDiet == true) { table2.Cell(row, 5).Range.Text = "X"; } } row++; } } } oWordDoc.Save(); if (((_Application)oWord).ActiveWindow.View.SplitSpecial == WdSpecialPane.wdPaneNone) { ((_Application)oWord).ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView; } else { ((_Application)oWord).ActiveWindow.View.Type = WdViewType.wdPrintView; } //CCFBGlobal.openDocumentOutsideCCFB(saveAs.ToString()); } catch (Exception ex) { CCFBGlobal.appendErrorToErrorReport("File Path = " + oTemplatePath.ToString(), ex.GetBaseException().ToString()); ((_Application)oWord).Quit(SaveChanges: false, OriginalFormat: false, RouteDocument: false); System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord); } } else { MessageBox.Show("ERROR: " + templatePath + " Not Found", "Temlate Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); } }