public static int PumpAllClass(string Company) { Console.WriteLine("Classes for Company " + Company); string sql = "SELECT * FROM Class"; List <QBClass> clsItems = new ODBCReaderToModel <QBClass>().CreateList(sql, Company); using (clsDataGetter dg = new clsDataGetter(CommonProcs.WCompanyConnStr)) { dg.RunCommand("DELETE FROM Clss WHERE QBFile='" + Company + "'"); } if (clsItems.Count > 0) { foreach (var QBclass in clsItems) { if (QBclass.Name.Contains("00") || QBclass.Name.Contains("01") || QBclass.Name.Contains("02")) { Clss clss = QBclass.ConvertTo <Clss>(); Console.WriteLine("Class " + clss.Name); clss.QBFile = Company; clss.Branch = clss.Name.Substring(0, 2); new ModelToSQL <Clss>().WriteInsertSQL("Clss", clss, "ClassID", CommonProcs.WCompanyConnStr); } } } return(clsItems.Count); }
public int PumpClass(string Company) { string sql = "SELECT * FROM Class WHERE TimeModified > " + CommonProcs.TimeStampString(DateTime.Now.AddDays(-1)); UpdateStatusBar("Opening Quickbooks", 10); List <QBClass> clsItems = new ODBCReaderToModel <QBClass>().CreateList(sql, Company); if (clsItems.Count > 0) { foreach (var QBclass in clsItems) { if (QBclass.Name.Contains("00") || QBclass.Name.Contains("01") || QBclass.Name.Contains("02")) { UpdateStatusBar("Adding " + QBclass.Name, 1); Clss clss = QBclass.ConvertTo <Clss>(); clss.QBFile = Company; clss.Branch = clss.Name.Substring(0, 2); using (clsDataGetter dg = new clsDataGetter(CommonProcs.WCompanyConnStr)) { clss.ClassID = dg.GetScalarInteger("SELECT ClassID FROM Clss WHERE ListID='" + clss.ListID + "' AND QBFile='" + Company + "'"); } new ModelToSQL <Clss>().WriteUpdateToSQL("Clss", clss, "ClassID", CommonProcs.WCompanyConnStr); } } } UpdateStatusBar("Done", progBar.Maximum); return(clsItems.Count); }