Example #1
0
 //Gets property through use of just the column name in database as string
 public object GetDataString(string FieldName)
 {
     if (dset.Tables[tbName].Rows.Count > 0)
     {
         int fldIndex = dset.Tables[tbName].Columns.IndexOf(FieldName);
         if (fldIndex >= 0)
         {
             if (dset.Tables[tbName].Columns[fldIndex].DataType.Name == "DateTime")
             {
                 if (drow[FieldName].ToString() != "")
                 {
                     return(CCFBGlobal.ValidDateString(drow[FieldName]));
                 }
                 else
                 {
                     return("");
                 }
             }
             else
             {
                 return(drow[FieldName].ToString());
             }
         }
     }
     return("");
 }
Example #2
0
 public string GetDataString(string FieldName)
 {
     if (FieldName != "")
     {
         try
         {
             if (dset.Tables[0].Columns[FieldName].DataType == System.Type.GetType("System.DateTime"))
             {
                 return(CCFBGlobal.ValidDateString(drow[FieldName]));
             }
             else if (dset.Tables[0].Columns[FieldName].DataType == System.Type.GetType("System.Boolean"))
             {
                 if (drow[FieldName] != null && drow[FieldName].ToString() != "")
                 {
                     return(drow[FieldName].ToString());
                 }
                 else
                 {
                     return("false");
                 }
             }
             else
             {
                 return(drow[FieldName].ToString());
             }
         }
         catch { return(""); }
     }
     else
     {
         return("");
     }
 }
Example #3
0
 /// <summary>
 /// Loads the DataGrid using values obtained in the DataSet
 /// </summary>
 private void rtplnLoadList(DataRow[] dRows)
 {
     rtplntbFindName.Text = "";
     rtplnLastSearchText  = "";
     rtplndgvHDClientList.Rows.Clear();
     progressBar1.Value = 0;
     progressBar1.Show();
     rtplntbFindName.Visible = rtplncboFilter.Visible = lblFilterBy.Visible = false;
     Application.DoEvents();
     progressBar1.Maximum = dRows.Length;
     for (int i = 0; i < dRows.Length; i++)
     {
         rtplndgvHDClientList.Rows.Add();
         rtplndgvHDClientList["clmCnt", i].Value                   = (i + 1).ToString();
         rtplndgvHDClientList["clmRouteID", i].Value               = true;
         rtplndgvHDClientList["clmRouteID", i].Value               = dRows[i]["HDRoute"];
         rtplndgvHDClientList["clmRouteTitle", i].Value            = dRows[i]["RouteTitle"];
         rtplndgvHDClientList["clmID", i].Value                    = dRows[i]["ID"];
         rtplndgvHDClientList["clmName", i].Value                  = dRows[i]["Name"];
         rtplndgvHDClientList["clmAddress", i].Value               = dRows[i]["Address"].ToString() + "\r\n     " + dRows[i]["City"].ToString() + ", " + dRows[i]["ZipCode"].ToString();
         rtplndgvHDClientList["clmApt", i].Value                   = dRows[i]["AptNbr"];
         rtplndgvHDClientList["clmPhone", i].Value                 = CCFBGlobal.FormatPhone(dRows[i]["Phone"].ToString());
         rtplndgvHDClientList["clmFamilySize", i].Value            = dRows[i]["FamilySize"];
         rtplndgvHDClientList["clmComments", i].Value              = dRows[i]["Comments"];
         rtplndgvHDClientList["clmDriverNotes", i].Value           = dRows[i]["DriverNotes"];
         rtplndgvHDClientList["clmSvcItem", i].Value               = dRows[i]["HDItem"];
         rtplndgvHDClientList["clmLastSvc", i].Value               = CCFBGlobal.ValidDateString(dRows[i]["LatestService"]);
         rtplndgvHDClientList[rtplnSortColName, i].Style.BackColor = Color.Azure;
         progressBar1.PerformStep();
     }
     lblRowCnt.Text = "[ " + rtplndgvHDClientList.Rows.Count.ToString() + " ]";
     rtplnrowIndex  = 0;
     foreach (ToolStripButton tsb in toolStrip2.Items)
     {
         rtplndgvHDClientList.Columns[tsb.Tag.ToString()].Visible = tsb.Checked;
     }
     progressBar1.Value      = 0;
     progressBar1.Visible    = false;
     rtplntbFindName.Visible = true;
     if (rtplnFilterColName != "")
     {
         rtplnGetDistincts(rtplnFilterColName);
     }
 }
        private void loadList()
        {
            ListViewItem lvi2;
            DataRow      drow;

            for (int i = 0; i < clsClient.clsHHmem.RowCount; i++)
            {
                drow = clsClient.clsHHmem.DSet.Tables[0].Rows[i];
                if (drow.RowState != DataRowState.Deleted)
                {
                    //Create New item
                    lvi2 = new ListViewItem(drow["LastName"].ToString() + ", " + drow["FirstName"].ToString());

                    //Load subitems
                    lvi2.SubItems.Add(drow["Age"].ToString());
                    lvi2.SubItems.Add(CCFBGlobal.ValidDateString(drow["Birthdate"]));
                    lvi2.SubItems.Add(drow["ID"].ToString());
                    if ((bool)drow["CSFP"] == true)
                    {
                        lvi2.Checked = true;
                        lvi2.SubItems.Add(CCFBGlobal.ValidDateString(drow["CSFPExpiration"]));
                        lvi2.ForeColor = Color.DarkBlue;
                    }
                    else
                    {
                        lvi2.SubItems.Add("");
                    }

                    // Add Item to the list items
                    lvHHMems.Items.Add(lvi2);
                }
            }
            if (lvHHMems.Items.Count > 0)
            {
                lvHHMems.Items[0].Focused = true;
            }
            else
            {
                btnSave.Enabled      = false;
                tbExpireDate.Visible = false;
                label5.Visible       = false;
            }
        }
Example #5
0
 /// <summary>
 /// Loads the DataGrid using values obtained in the DataSet
 /// </summary>
 private void loadList()
 {
     tbFindName.Text = "";
     lastSearchText  = "";
     dgvHD.Rows.Clear();
     progressBar1.Value = 0;
     progressBar1.Show();
     tbFindName.Visible = false;
     Application.DoEvents();
     progressBar1.Maximum = rowCount;
     for (int i = 0; i < rowCount; i++)
     {
         dgvHD.Rows.Add();
         dgvHD["clmRouteID", i].Value     = true;
         dgvHD["clmRouteID", i].Value     = dset.Tables[0].Rows[i]["HDRoute"];
         dgvHD["clmRouteTitle", i].Value  = dset.Tables[0].Rows[i]["RouteTitle"];
         dgvHD["clmID", i].Value          = dset.Tables[0].Rows[i]["ID"];
         dgvHD["clmName", i].Value        = dset.Tables[0].Rows[i]["Name"];
         dgvHD["clmAddress", i].Value     = dset.Tables[0].Rows[i]["Address"].ToString() + "\r\n     " + dset.Tables[0].Rows[i]["City"].ToString() + ", " + dset.Tables[0].Rows[i]["ZipCode"].ToString();
         dgvHD["clmApt", i].Value         = dset.Tables[0].Rows[i]["AptNbr"];
         dgvHD["clmPhone", i].Value       = CCFBGlobal.FormatPhone(dset.Tables[0].Rows[i]["Phone"].ToString());
         dgvHD["clmFamilySize", i].Value  = dset.Tables[0].Rows[i]["FamilySize"];
         dgvHD["clmComments", i].Value    = dset.Tables[0].Rows[i]["Comments"];
         dgvHD["clmDriverNotes", i].Value = dset.Tables[0].Rows[i]["DriverNotes"];
         dgvHD["clmSvcItem", i].Value     = dset.Tables[0].Rows[i]["HDItem"];
         dgvHD["clmLastSvc", i].Value     = CCFBGlobal.ValidDateString(dset.Tables[0].Rows[i]["LatestService"]);
         progressBar1.PerformStep();
     }
     lblRowCnt.Text = "[ " + dgvHD.Rows.Count.ToString() + " ]";
     rowIndex       = 0;
     foreach (ToolStripButton tsb in toolStrip2.Items)
     {
         dgvHD.Columns[tsb.Tag.ToString()].Visible = tsb.Checked;
     }
     progressBar1.Value   = 0;
     progressBar1.Visible = false;
     tbFindName.Visible   = true;
 }
        public void createReport(string foodBankName, string templatePath, bool fillClientInfo)
        //string[] fldNames, string[] fldVals)
        {
            Object oMissing = System.Reflection.Missing.Value;
            Object missing  = System.Reflection.Missing.Value;
            Object oTrue    = true;
            Object oFalse   = false;

            oWord.Visible = true;
            Object oTemplatePath = templatePath;

            try
            {
                oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);

                fillBookMark("FoodBankName", foodBankName);
                fillBookMark("FBName1", foodBankName);
                fillBookMark("FBName2", foodBankName);

                if (fillClientInfo == true)
                {
                    fillBookMark("Date", DateTime.Today.ToShortDateString());
                    fillBookMark("clientID", clsClient.clsHH.ID.ToString());

                    Table table = oWordDoc.Tables[1];
                    //table.Cell(1, 1).Range.Text = clsClient.clsHH.Name;
                    string fullAddress = clsClient.clsHH.Address;
                    if (clsClient.clsHH.AptNbr.Trim() != "")
                    {
                        fullAddress += "  Unit " + clsClient.clsHH.AptNbr.Trim();
                    }
                    table.Cell(3, 1).Range.Text = fullAddress;
                    table.Cell(5, 1).Range.Text = clsClient.clsHH.City + ", " + clsClient.clsHH.State;
                    table.Cell(5, 2).Range.Text = clsClient.clsHH.Zipcode;
                    int   row    = 2;
                    Table table2 = oWordDoc.Tables[2];
                    for (int i = 0; i < clsClient.clsHHmem.RowCount; i++)
                    {
                        clsClient.clsHHmem.SetRecord(i);
                        if (clsClient.clsHHmem.HeadHH == true)
                        {
                            if (clsClient.clsHHmem.UseAge == false)
                            {
                                table.Cell(7, 1).Range.Text = CCFBGlobal.ValidDateString(clsClient.clsHHmem.Birthdate);
                            }
                            else
                            {
                                table.Cell(7, 1).Range.Text = clsClient.clsHHmem.Age.ToString();
                            }

                            table.Cell(7, 2).Range.Text = clsClient.clsHHmem.Sex;
                            table.Cell(7, 3).Range.Text = clsClient.clsHH.Phone;
                            table.Cell(1, 3).Range.Text = clsClient.clsHHmem.LastName;
                            table.Cell(1, 1).Range.Text = clsClient.clsHHmem.FirstName;
                        }
                        else
                        {
                            if (clsClient.clsHHmem.Inactive == false)
                            {
                                table2.Cell(row, 1).Range.Text = clsClient.clsHHmem.LastName + ", " + clsClient.clsHHmem.FirstName;
                                if (clsClient.clsHHmem.UseAge == true)
                                {
                                    table2.Cell(row, 2).Range.Text = clsClient.clsHHmem.Age.ToString();
                                }
                                else
                                {
                                    table2.Cell(row, 2).Range.Text = CCFBGlobal.ValidDateString(clsClient.clsHHmem.Birthdate);
                                }

                                table2.Cell(row, 3).Range.Text = clsClient.clsHHmem.Sex;
                                if (table2.Columns.Count > 3)
                                {
                                    if (clsClient.clsHHmem.IsDisabled == true)
                                    {
                                        table2.Cell(row, 4).Range.Text = "X";
                                    }
                                    if (clsClient.clsHHmem.SpecialDiet == true)
                                    {
                                        table2.Cell(row, 5).Range.Text = "X";
                                    }
                                }
                                row++;
                            }
                        }
                    }
                }

                //table = oWordDoc.Tables[4];
                //table.Cell(1, 3).Range.Text = clsClient.clsHH.Infants.ToString();
                //table.Cell(2, 3).Range.Text = clsClient.clsHH.Youth.ToString();
                //table.Cell(3, 3).Range.Text = clsClient.clsHH.Teens.ToString();
                //table.Cell(4, 3).Range.Text = clsClient.clsHH.Adults.ToString();
                //table.Cell(5, 3).Range.Text = clsClient.clsHH.Seniors.ToString();

                //row = 1;
                //for (int i = 0; i < fldNames.Length; i++)
                //{
                //    if (fldNames[i] != null)
                //    {
                //        table.Cell(row, 4).Range.Text = fldNames[i];

                //        if (fldVals[i] == "True")
                //            table.Cell(row, 5).Range.Text = "Yes";
                //        else
                //            table.Cell(row, 5).Range.Text = "No";

                //        row++;
                //    }
                //}

                //Dialog varDlg = oWord.Application.Dialogs[WdWordDialog.wdDialogFilePrint];
                //int userChoice = varDlg.Show(ref oMissing);

                ////If User did not cancel Print, then Print the document
                //if (userChoice == -1)
                //{
                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.appendErrorToErrorReport(clsClient.clsHH.Name, "Print Clientcard");
                oWord.Options.PrintBackground = false;
                oWordDoc.PrintOut(ref oFalse, ref oFalse, ref oMissing,
                                  ref oMissing, ref oMissing, ref oMissing,
                                  ref oMissing, ref oMissing, ref oMissing,
                                  ref oMissing, ref oMissing, ref oMissing,
                                  ref oMissing, ref oMissing, ref oMissing,
                                  ref oMissing, ref oMissing, ref oMissing);
                //}
                System.Windows.Forms.Application.DoEvents();
                System.Threading.Thread.Sleep(100);
                ((_Application)oWord).Quit(SaveChanges: false, OriginalFormat: false, RouteDocument: false);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);

                //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);
            }
        }
        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);
            }
        }
Example #8
0
        private bool TestHHMName(int iMode, ListView lvwGrid)
        {
            int    lvwIndex = -1;
            string sWhereClause;
            bool   bIsExactMatch = false;

            lvwGrid.Items.Clear();
            //tpg.Text = "Loading ..";
            Application.DoEvents();
            switch (iMode)
            {
            case 1:
                sWhereClause = "SoundEx(LastName) = SoundEx('" + tbLastName.Text + "') AND SoundEx(FirstName) = SoundEx('" + tbFirstName.Text + "')";
                break;

            default:
                sWhereClause = "SoundEx(LastName) = SoundEx('" + tbLastName.Text + "')";
                break;
            }
            //Font ft = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            string sqlText = "SELECT LastName, FirstName, hhm.HouseholdID HHId, hhm.Inactive HHMInactive, hhm.BirthDate"
                             + ", hh.name, hh.address, hh.City, hh.Zipcode, hh.Inactive HHInactive"
                             + ", (SELECT Count(*) FROM TrxLog WHERE HouseholdId = hhm.HouseholdId"
                             + " AND TrxDate Between '" + CCFBGlobal.CurrentFiscalStartDate() + "' AND '" + CCFBGlobal.CurrentFiscalEndDate() + "') NbrSvcs"
                             + ", hhm.id HHMID"
                             + " FROM HouseholdMembers hhm INNER JOIN Household hh ON hhm.HouseholdID = hh.ID"
                             + " WHERE " + sWhereClause + " ORDER BY hhm.LastName, hhm.FirstName, hh.Name";

            DataTable dtblwrk = csdgdataaccess.TransferDataToLocalDataTable(sqlText);

            if (dtblwrk.Rows.Count > 0)
            {
                //tpg.Text = " [ " + dtblwrk.Rows.Count.ToString() + " ] " + tpg.Tag.ToString();
                lvwGrid.Visible   = true;
                lvwGrid.BackColor = Color.Ivory;
                string nameTest = tbLastName.Text.ToUpper() + ", " + tbFirstName.Text.ToUpper();
                foreach (DataRow drow in dtblwrk.Rows)
                {
                    ListViewItem lvItm = new ListViewItem(drow.Field <string>("LastName"));
                    lvItm.SubItems.Add(drow.Field <string>("FirstName"));
                    lvItm.SubItems.Add(CCFBGlobal.ValidDateString(drow["BirthDate"]));
                    //lvItm.SubItems.Add(CCFBGlobal.IsInactiveString(Convert.ToBoolean(drow["HHMInactive"])));
                    lvItm.SubItems.Add(drow.Field <string>("Name"));
                    if (drow.Field <string>("Name") == nameTest)
                    {
                        if (CCFBPrefs.AllowDuplicateHHNames == false)
                        {
                            lblDupHHError.Visible = true;
                        }
                    }
                    lvItm.SubItems.Add(drow["NbrSvcs"].ToString());
                    lvItm.SubItems.Add(CCFBGlobal.IsInactiveString(Convert.ToBoolean(drow["HHInactive"])));
                    lvItm.SubItems.Add(drow.Field <string>("Address"));
                    lvItm.SubItems.Add(drow.Field <string>("City"));
                    lvItm.SubItems.Add(drow.Field <string>("ZipCode"));
                    lvItm.SubItems.Add(Convert.ToInt32(drow["HHId"]).ToString());
                    if (Convert.ToBoolean(drow["HHInactive"]) == true)
                    {
                        //lvItm.Font = ft;
                        //for (int i = 3; i < lvwGrid.Columns.Count; i++)
                        //{
                        //    lvItm.SubItems[i].Font = ft;
                        //    lvItm.SubItems[i].ForeColor = Color.Maroon;
                        //}
                        lvItm.ForeColor = Color.Maroon;
                    }
                    if (nameMatches(iMode, drow) == true)
                    {
                        if (newHHMID == Convert.ToInt32(drow["HHMID"]))
                        {
                            lvItm.BackColor = Color.LightGreen;
                        }
                        else
                        {
                            lvItm.BackColor = Color.LightCoral;
                            if (lvwIndex < 0)
                            {
                                lvwIndex = lvwGrid.Items.Count;
                            }
                            bIsExactMatch = true;
                        }
                    }
                    lvwGrid.Items.Add(lvItm);
                    if (lvwIndex == lvwGrid.Items.Count - 1)
                    {
                        lvwGrid.Items[lvwIndex].Selected = true;
                        lvwGrid.Items[lvwIndex].EnsureVisible();
                    }
                    needToSetTab = true;
                }
            }
            else
            {
                //tpg.Text = "no matches";
                needToSetTab = false;
            }
            //tabControl1.SelectedTab = tpg;
            return(bIsExactMatch);
        }