Example #1
0
        public int PumpEmployees(string Company)
        {
            string sql = "SELECT * FROM Employee WHERE TimeModified > " + CommonProcs.TimeStampString(DateTime.Now.AddDays(-1));

            UpdateStatusBar("Opening Quickbooks", 10);
            List <QBEmployee> employees = new ODBCReaderToModel <QBEmployee>().CreateList(sql, Company);

            if (employees.Count > 0)
            {
                foreach (var QBemp in employees)
                {
                    UpdateStatusBar("Adding " + QBemp.Name, 1);
                    Employee emp = QBemp.ConvertTo <Employee>();
                    emp.QBFile = Company;

                    using (clsDataGetter dg = new clsDataGetter(CommonProcs.WCompanyConnStr))
                    {
                        emp.EmployeeID = dg.GetScalarInteger("SELECT EmployeeID FROM Employee WHERE ListID='" + emp.ListID + "' AND QBFile='" + Company + "'");
                    }
                    new ModelToSQL <Employee>().WriteUpdateToSQL("Employee", emp, "EmployeeID", CommonProcs.WCompanyConnStr);
                }
            }
            UpdateStatusBar("Done", progBar.Maximum);
            return(employees.Count);
        }
        public static int PumpAllEmployees(string Company)
        {
            Console.WriteLine("Employees for Company " + Company);
            string            sql       = "SELECT * FROM Employee";
            List <QBEmployee> employees = new ODBCReaderToModel <QBEmployee>().CreateList(sql, Company);

            using (clsDataGetter dg = new clsDataGetter(CommonProcs.WCompanyConnStr))
            {
                dg.RunCommand("DELETE FROM Employee WHERE QBFile='" + Company + "'");
            }
            if (employees.Count > 0)
            {
                foreach (var QBemp in employees)
                {
                    if (QBemp.PayrollInfoClassRefFullName != null && (QBemp.PayrollInfoClassRefFullName.Contains("00") || QBemp.PayrollInfoClassRefFullName.Contains("01") || QBemp.PayrollInfoClassRefFullName.Contains("02")))
                    {
                        Employee emp = QBemp.ConvertTo <Employee>(true, "Employee");
                        Console.WriteLine("Employee " + emp.LastName + "," + emp.FirstName);
                        emp.Branch = emp.PayrollInfoClassRefFullName.Substring(0, 2);

                        emp.QBFile = Company;
                        new ModelToSQL <Employee>().WriteInsertSQL("Employee", emp, "EmployeeID", CommonProcs.WCompanyConnStr, true);
                    }
                    else
                    {
                        Employee emp = QBemp.ConvertTo <Employee>(true, "Employee");
                        Console.WriteLine("Employee " + emp.LastName + "," + emp.FirstName);
                        emp.Branch = "00";

                        emp.QBFile = Company;
                        new ModelToSQL <Employee>().WriteInsertSQL("Employee", emp, "EmployeeID", CommonProcs.WCompanyConnStr);
                    }
                }
            }
            return(employees.Count);
        }