public static bool AssetOnHold(string num, string b) { num = ParseBarCode(num); foreach (var asset in GetAllAssets()) { if (asset.AssetNumber == num) { try { asset.OnHold = Convert.ToBoolean(b); SQL_Request req = new SQL_Request().OpenConnection(); req.UpdateAsset(asset); if (req.Success == true) { return(true); } else { return(false); } } catch { return(false); } } } return(false); }
protected void SendSQL_Click(object sender, EventArgs e) { try { SQL_Request req = new SQL_Request().OpenConnection(); //request all assets req.GetAllAssets(false); //merge all assets //post merged assets as new master DB if (req.Tag != null) { var cloud = req.Tag as List <Asset>; //upload assets foreach (Asset a in Global.Library.Assets) { try { var lookup = cloud.FindAssetByNumber(a.AssetNumber); if (lookup == null) { req.AddAsset(a, false); } else if (lookup.AssetNumber == a.AssetNumber) { req.UpdateAsset(a, false); } } catch { //PopNotify("Error", "Error Pushing Library To SQL"); } } //upload settings //upload history //upload notifications //upload Calibrations } req.CloseConnection(); } catch { //PopNotify("Error", "Error Pushing Library To SQL"); } //PopNotify("Complete", "Library Pushed To SQL"); }
public static Task <bool> LibraryAsync() { return(Task.Run(() => { try { SQL_Request req = new SQL_Request().OpenConnection(); //request all assets req.GetAssets(false); //merge all assets //post merged assets as new master DB if (req.Tag != null) { var cloud = req.Tag as List <Asset>; //upload assets foreach (Asset a in Global.AssetCache) { try { var lookup = cloud.FindAssetByNumber(a.AssetNumber); if (lookup == null) { req.AddAsset(a, false); } else if (lookup.AssetNumber == a.AssetNumber) { req.UpdateAsset(a, false); } } catch { //PopNotify("Error", "Error Pushing Library To SQL"); } } } req.CloseConnection(); return true; } catch { return false; } })); }
public static bool UpdateAsset(Asset asset) { try { SQL_Request req = new SQL_Request().OpenConnection(); req.UpdateAsset(asset); if (req.Success == true) { return(true); } else { return(false); } } catch { return(false); } }