public static void create_EquipmentDemand_In_DB(EquipmentDemand ed) { SqlCommand c = new SqlCommand(); c.CommandText = "EXECUTE dbo.SP_add_EquipmentDemand @id, @Emp, @reason"; c.Parameters.AddWithValue("@id", ed.getId()); if (ed.getCreator() != null) { c.Parameters.AddWithValue("@Emp", ed.getCreator().getId()); } c.Parameters.AddWithValue("@reason", ed.getReason()); Console.WriteLine(c.ToString()); SQL_CON SC = new SQL_CON(); SC.execute_non_query(c); }
public static void init_EquipmentDemands() { //מילוי המערך מתוך בסיס הנתונים SqlCommand c = new SqlCommand(); c.CommandText = "EXECUTE dbo.Get_All_EquipmentDemands"; SQL_CON SC = new SQL_CON(); SqlDataReader rdr = SC.execute_query(c); equipmentDemands = new List <EquipmentDemand>(); while (rdr.Read()) { EquipmentDemand ed = new EquipmentDemand(int.Parse(rdr.GetValue(0).ToString()), getEmployeeObject(rdr.GetValue(1).ToString()), DateTime.Parse((rdr.GetValue(5).ToString())), rdr.GetValue(2).ToString()); equipmentDemands.Add(ed); init_contain(ed.getId()); ed.setStatus(rdr.GetValue(3).ToString()); ed.addApprovalNote(rdr.GetValue(4).ToString()); ed.getCreator().addEquipmentDemand(ed); } }