private company FindCompany(string CompanyName)
        {
            try
            {
                company toReturn           = new company();
                string  trimmedCompanyName = CommonFunctions.TrimSpaces(CompanyName);
                toReturn.name = trimmedCompanyName;

                toReturn.SearchType = DataObject.SearchTypes.Exact;
                DataTable results = toReturn.Search("SELECT * FROM companies WHERE name = '" + trimmedCompanyName + "'");
                if (results.Rows.Count > 0)
                {
                    toReturn.Load(results.Rows[0]);
                }

                toReturn.created_on = DateTime.Now;
                toReturn.name       = trimmedCompanyName;

                toReturn.Save();
                return(toReturn);
            }
            catch (Exception err)
            {
                // Somewhat dangerous, but it ensures that the import won't crash
                LoggingHelper.Log("Error in frmImportData.FindCompany", LogSeverity.Critical, err, true);
                return(null);
            }
        }
        private void InitializeCompanyNames()
        {
            company   cmps = new company();
            DataTable dt   = cmps.Search(cmps.SearchSQL + " ORDER BY name");


            foreach (DataRow aCompany in dt.Rows)
            {
                cmps = new company();
                cmps.Load(aCompany);
                DataTable           matches = cmps.Search("SELECT Count(*) FROM claims WHERE company_id = " + cmps.id);
                ComboItemForCompany cifc    = new ComboItemForCompany(cmps, System.Convert.ToInt32(matches.Rows[0][0]));
                cmbCompanyDropdown.Items.Add(cifc);
            }
        }
        /// <summary>
        /// Returns a list of all companies sorted by name
        /// </summary>
        /// <returns></returns>
        internal static List <company> GetSortedList()
        {
            List <company> toReturn       = new List <company>();
            company        workingCompany = new company();

            DataTable allData = workingCompany.GetAllData("name");

            foreach (DataRow aRow in allData.Rows)
            {
                workingCompany = new company();
                workingCompany.Load(aRow);

                toReturn.Add(workingCompany);
            }

            return(toReturn);
        }
Beispiel #4
0
        /// <summary>
        /// Adds all the companies to the Company List
        /// </summary>
        private void InitializeCompanies(int defaultCompanyID)
        {
            company   cmp          = new company();
            DataTable allCompanies = cmp.Search(cmp.SearchSQL + " ORDER BY name");

            foreach (DataRow aRow in allCompanies.Rows)
            {
                cmp = new company();
                cmp.Load(aRow);
                cmbInsuranceCarrier.Items.Add(cmp);

                if (cmp.id == defaultCompanyID)
                {
                    cmbInsuranceCarrier.SelectedItem = cmp;
                }
            }
        }
Beispiel #5
0
        private void InitializeInsuranceDropdown()
        {
            clbInsuranceCompanies.Items.Add("All");

            company c = new company();

            foreach (DataRow aRow in c.GetAllData("name").Rows)
            {
                c = new company();
                c.Load(aRow);

                clbInsuranceCompanies.Items.Add(c);
            }

            DataTable matches = c.Search("SELECT * FROM question_insurance_companies WHERE question_id = " + _formQuestion.id);

            if (matches.Rows.Count > 0)
            {
                foreach (DataRow aMatch in matches.Rows)
                {
                    for (int i = 1; i < clbInsuranceCompanies.Items.Count; i++)
                    {
                        if (((company)clbInsuranceCompanies.Items[i]).id == (int)aMatch["insurance_id"])
                        {
                            clbInsuranceCompanies.SetItemChecked(i, true);

                            break;
                        }
                    }
                }
            }
            else
            {
                clbInsuranceCompanies.SetItemChecked(0, true);
            }
        }