public void CreateNewAsset(string name, decimal purchasePrice, string purchaseDate, decimal scrapvalue, int lifeSpan, string isoperative, DecreciationType inDecreciation) { Asset tempAsset = new Asset(name, purchasePrice, purchaseDate, scrapvalue, lifeSpan, isoperative, inDecreciation); DBcontroller.SaveAsset(tempAsset); }
public Asset LoadAsset(int inAssetID) { Asset returnAsset; string tempname = "UNKNOWN/VOID"; decimal tempprice = 1000; string tempdate = "01/01/1000"; decimal scrapvalue = 10; int lifespan = 0; string status = "false"; Domain.DecreciationType type = Domain.DecreciationType.Lineær; // StoredProcedureCall SqlConnection conn = new SqlConnection("Server=ealdb1.eal.local;Database=ejl49_db; User ID = ejl49_usr; Password = Baz1nga49"); try { conn.Open(); //SqlCommand cmd = new SqlCommand(); //cmd.Connection = conn; //cmd.CommandText = "SELECT * from Asset"; SqlCommand comd = new SqlCommand("spCompoundAssDesc", conn); comd.CommandType = CommandType.StoredProcedure; comd.Parameters.Add(new SqlParameter("@AssetId", inAssetID)); SqlDataReader rdr = comd.ExecuteReader(); while (rdr.Read()) { tempname = rdr["AssetName"].ToString(); tempprice = decimal.Parse(rdr["AssetPurchasePrice"].ToString()); tempdate = rdr["AssetPurchaseDate"].ToString(); scrapvalue = decimal.Parse(rdr["AssetScrapValue"].ToString()); lifespan = int.Parse(rdr["AssetLifeSpan"].ToString()); status = rdr["AssetStatus"].ToString(); string inType = rdr["DecreciationType"].ToString(); switch (inType) { case "Lineær": type = Domain.DecreciationType.Lineær; break; case "Saldo": type = Domain.DecreciationType.Saldo; break; case "Annuitet": type = Domain.DecreciationType.Annuitet; break; } // string Asset = "Id: " + rdr.GetInt32(0) + " Name: " + rdr.GetString(1); } } catch (SqlException es) { Console.WriteLine("UPS " + es.Message); Console.ReadLine(); } finally { conn.Close(); } returnAsset = new Asset(tempname, tempprice, tempdate, scrapvalue, lifespan, status, type); return returnAsset; }
public void GetAsset(int assetID) { CurrentAsset = DBcontroller.LoadAsset(assetID); }
public Asset LoadAsset(int inAssetID) { Asset returnAsset; string tempname = "UNKNOWN/VOID"; decimal tempprice = 1000; string tempdate = "01/01/1000"; decimal scrapvalue = 10; int lifespan = 0; string status = "false"; Domain.DecreciationType type = Domain.DecreciationType.Lineær; // StoredProcedureCall SqlConnection conn = new SqlConnection("Server=ealdb1.eal.local;Database=ejl49_db; User ID = ejl49_usr; Password = Baz1nga49"); try { conn.Open(); //SqlCommand cmd = new SqlCommand(); //cmd.Connection = conn; //cmd.CommandText = "SELECT * from Asset"; SqlCommand comd = new SqlCommand("spCompoundAssDesc", conn); comd.CommandType = CommandType.StoredProcedure; comd.Parameters.Add(new SqlParameter("@AssetId", inAssetID)); SqlDataReader rdr = comd.ExecuteReader(); while (rdr.Read()) { tempname = rdr["AssetName"].ToString(); tempprice = decimal.Parse(rdr["AssetPurchasePrice"].ToString()); tempdate = rdr["AssetPurchaseDate"].ToString(); scrapvalue = decimal.Parse(rdr["AssetScrapValue"].ToString()); lifespan = int.Parse(rdr["AssetLifeSpan"].ToString()); status = rdr["AssetStatus"].ToString(); string inType = rdr["DecreciationType"].ToString(); switch (inType) { case "Lineær": type = Domain.DecreciationType.Lineær; break; case "Saldo": type = Domain.DecreciationType.Saldo; break; case "Annuitet": type = Domain.DecreciationType.Annuitet; break; } // string Asset = "Id: " + rdr.GetInt32(0) + " Name: " + rdr.GetString(1); } } catch (SqlException es) { Console.WriteLine("UPS " + es.Message); Console.ReadLine(); } finally { conn.Close(); } returnAsset = new Asset(tempname, tempprice, tempdate, scrapvalue, lifespan, status, type); return(returnAsset); }
public Agreement(Asset asset) { Asset = asset ?? throw new ArgumentNullException(nameof(asset)); }
public void SaveAsset(Asset inAsset) { SqlConnection conn = getConnection(); // StoredProcedureCall try { SqlCommand command = new SqlCommand("sp_Decreciation_insert", conn); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@decType", inAsset.AssetDecreciationList[0].decreciationType.ToString())); command.Parameters.Add(new SqlParameter("@decYear", inAsset.AssetDecreciationList[0].DecreciationYear)); command.Parameters.Add(new SqlParameter("@decValue", inAsset.AssetDecreciationList[0].DecreciationValue)); SqlCommand cmd = new SqlCommand("spInsertAsset", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@AssetName", inAsset.AssetName)); cmd.Parameters.Add(new SqlParameter("@AssetPurchasePrice", inAsset.AssetPurchacePrice)); cmd.Parameters.Add(new SqlParameter("@AssetPurchaseDate", inAsset.AssetPurchaseDate.ToString())); cmd.Parameters.Add(new SqlParameter("@AssetScrapValue", inAsset.AssetScrapValue)); cmd.Parameters.Add(new SqlParameter("@AssetPostedValue", inAsset.AssetPostedValue.ToString())); cmd.Parameters.Add(new SqlParameter("@AssetLifeSpan", inAsset.AssetLifeSpan)); cmd.Parameters.Add(new SqlParameter("@AssetStatus", inAsset.IsOperative.ToString())); command.ExecuteNonQuery(); cmd.ExecuteNonQuery(); } catch (SqlException e) { Console.WriteLine("whooops: " + e.Message); } finally { conn.Close(); conn.Dispose(); } }
public Asset LoadAsset(int inAssetID) { Asset returnAsset; int tempID = 0; string tempname = "UNKNOWN/VOID"; decimal tempprice = 1000; string tempdate = "01/01/1000"; decimal scrapvalue = 10; int lifespan = 0; string status = "false"; Domain.DecreciationType type = Domain.DecreciationType.Lineær; SqlConnection conn = getConnection(); try { SqlCommand comd = new SqlCommand("spCompoundAssDesc", conn); comd.CommandType = CommandType.StoredProcedure; comd.Parameters.Add(new SqlParameter("@AssetId", inAssetID)); SqlDataReader rdr = comd.ExecuteReader(); while (rdr.Read()) { tempID = int.Parse(rdr["AssetId"].ToString()); tempname = rdr["AssetName"].ToString(); tempprice = decimal.Parse(rdr["AssetPurchasePrice"].ToString()); tempdate = rdr["AssetPurchaseDate"].ToString(); scrapvalue = decimal.Parse(rdr["AssetScrapValue"].ToString()); lifespan = int.Parse(rdr["AssetLifeSpan"].ToString()); status = rdr["AssetStatus"].ToString(); string inType = rdr["DecreciationType"].ToString(); switch (inType) { case "Lineær": type = Domain.DecreciationType.Lineær; break; case "Saldo": type = Domain.DecreciationType.Saldo; break; case "Annuitet": type = Domain.DecreciationType.Annuitet; break; } } } catch (SqlException es) { Console.WriteLine("UPS " + es.Message); Console.ReadLine(); } finally { conn.Close(); } returnAsset = new Asset(tempname, tempprice, tempdate, scrapvalue, lifespan, status, type); returnAsset.SetID(tempID); return returnAsset; }