public static bool CreateProd_Order(Prod_Order prod_Order, out string status, out int id) { status = DataConnection.status; DataConnection.command.CommandText = "INSERT INTO PROD_ORDER(pordNumber, pordDateOrdered, pordPaid) " + "OUTPUT INSERTED.ID " + "VALUES(" + "'" + prod_Order.pordNumber + "', " + "'" + prod_Order.pordDateOrdered + "', " + "'" + prod_Order.pordPaid + "' " + ")"; if (DataConnection.Open()) { try { id = (int)DataConnection.command.ExecuteScalar(); status = "Insert successful"; DataConnection.Close(); return(true); } catch (Exception e) { status = "Insert failed\n" + e.Message; } } DataConnection.Close(); id = 0; return(false); }
public static bool UpdateProd_Order(Prod_Order prod_Order, out string status) { status = DataConnection.status; DataConnection.command.CommandText = "UPDATE Prod_Order SET pordNumber '" + prod_Order.pordNumber + "', " + "pordDateOrdered = '" + prod_Order.pordDateOrdered + "', " + "pordPaid = '" + prod_Order.pordPaid + "' " + "WHERE ID = " + prod_Order.id.ToString(); if (DataConnection.Open()) { try { DataConnection.command.ExecuteNonQuery(); status = "Update successful"; DataConnection.Close(); return(true); } catch (Exception e) { status = "Update failed\n" + e.Message; } } DataConnection.Close(); return(false); }
public static bool DeleteProd_Order(Prod_Order prod_Order, out string status) { status = DataConnection.status; DataConnection.command.CommandText = "DELETE FROM Prod_Order WHERE id = " + prod_Order.id.ToString(); if (DataConnection.Open()) { try { DataConnection.command.ExecuteNonQuery(); status = "Delete successful"; DataConnection.Close(); return(true); } catch (Exception e) { status = "Delete failed\n" + e.Message; } } DataConnection.Close(); return(false); }