public static void CreateNewPayment(List<string> paymentDetails) { //Create payment object and assign values infoPayment nPayment = new infoPayment(); nPayment.paymentFolio = paymentDetails[0]; nPayment.payedAmount = double.Parse(paymentDetails[1]); nPayment.paymentDate = DateTime.Parse(paymentDetails[2]); nPayment.paymentComplete = bool.Parse(paymentDetails[3]); nPayment.studentID = Int32.Parse(paymentDetails[4]); nPayment.conceptID = int.Parse(paymentDetails[5]); DAL.InsertPayment(nPayment); }
/// <summary> /// Creates new record that represents payment of a student /// </summary> /// <param name="nPayment"></param> public static void InsertPayment(infoPayment nPayment) { SqlCeConnection sqlConnection = new SqlCeConnection(connectionString); sqlConnection.Open(); SqlCeCommand newPaymentCommand = new SqlCeCommand("INSERT INTO Payment (Folio, Amount, Date, Completed, Student_ID, Concept_ID) " + "VALUES (@pFolio, @pAmount, @pDate, @pComplete, @pStudentID, @pConceptID)", sqlConnection); newPaymentCommand.Parameters.AddWithValue("@pFolio", nPayment.paymentFolio); newPaymentCommand.Parameters.AddWithValue("@pAmount", nPayment.payedAmount); newPaymentCommand.Parameters.AddWithValue("@pDate", nPayment.paymentDate); newPaymentCommand.Parameters.AddWithValue("@pComplete", nPayment.paymentComplete); newPaymentCommand.Parameters.AddWithValue("@pStudentID", nPayment.studentID); newPaymentCommand.Parameters.AddWithValue("@pConceptID", nPayment.conceptID); newPaymentCommand.CommandType = System.Data.CommandType.Text; try { newPaymentCommand.ExecuteNonQuery(); } catch (Exception e) { throw e; } finally { sqlConnection.Close(); sqlConnection.Dispose(); } }