public int SaveProduct(FinalTable finalTable) { if (GetData(finalTable.SLD_PART).Count() == 0) return Insert(finalTable); else return Update(finalTable); }
private int Insert(FinalTable finalTable) { String Query = "INSERT INTO [Final_Table] ([SLD_SOURCE_ID], [SLD_COST], [SLD_PART], [SLD_IMG1], [SLD_IMG2], [SLD_VENDOR], [SLD_INV], [SLD_DESC], [SLD_TECHDOC], [SLD_LastUpdate])" + "VALUES ('"+ finalTable.SLD_SOURCE_ID +"',"+ finalTable.SLD_COST +" , '"+finalTable.SLD_PART+"', '" +finalTable.SLD_IMG1+"', '"+finalTable.SLD_IMG2+"', '"+finalTable.SLD_VENDOR+"', '" + finalTable.SLD_INV + "', '" + finalTable.SLD_DESC + "', '" + finalTable.SLD_TECHDOC + "', '" + finalTable.SLD_LastUpdate + "')"; OleDbDataManager oDm = new OleDbDataManager(this.ConnectionString, Query, true); return oDm.RunActionQuery(); }
private int Update(FinalTable finalTable) { String Query = "UPDATE [Final_Table] SET [SLD_SOURCE_ID] = '" + finalTable.SLD_SOURCE_ID + "', [SLD_COST] = "+ finalTable.SLD_COST + ", [SLD_IMG1] = '"+ finalTable.SLD_IMG1 + "', [SLD_IMG2] = '"+finalTable.SLD_IMG2 + "', [SLD_VENDOR] = '"+finalTable.SLD_VENDOR + "', [SLD_INV] = '"+finalTable.SLD_INV + "', [SLD_DESC] = '" + finalTable.SLD_DESC + "', [SLD_TECHDOC] = '" + finalTable.SLD_TECHDOC + "', [SLD_LastUpdate] = '"+ finalTable.SLD_LastUpdate + "' WHERE [SLD_PART] = '" + finalTable.SLD_PART + "'"; OleDbDataManager oDm = new OleDbDataManager(this.ConnectionString, Query, true); return oDm.RunActionQuery(); }
private static void ExportProduct(string productCode) { String ConnStr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=True", Settings.GetValue("WebSpiderDB")); InProduct product = new InProduct(); product.Code = productCode; var secLockProduct = new InProductManager(Constants.ConnectionString).GetData(product); if (secLockProduct.Count() == 0) return; product = secLockProduct[0]; FinalTable ft = new FinalTable(); ft.SLD_SOURCE_ID = String.Empty; ft.SLD_COST = product.YourPrice; ft.SLD_PART = product.Code; ft.SLD_IMG1 = product.ImageUrl1; ft.SLD_IMG2 = product.ImageUrl2; ft.SLD_VENDOR = product.ManufacturerName; ft.SLD_INV = product.Stock; ft.SLD_DESC = product.Description; ft.SLD_TECHDOC = product.TechDoc; ft.SLD_LastUpdate = DateTime.Now.ToString(Settings.GetValue("DateFormat")); new FinalTableManager(ConnStr).SaveProduct(ft); }