private void populateDocumentList() { lstDocuments.Items.Clear(); student = StudentAdapter.Instance.GetStudent(studentID); if (student.StudentFound) { txtName.Text = student.Fullname; lblDocumentNo.Enabled = true; txtDocumentNo.Enabled = true; transactions = TransactionAdapter.Instance.GetTransactionsByStudentID(student.StudentID); if (transactions.Count > 0) { foreach (Transaction t in transactions) { if (t.DocumentNumber.ToUpper().StartsWith(txtDocumentNo.Text.ToUpper())) { t.RecomputeTotals(config["Tuition_Fee"].ToString() , config["Miscellaneous_Fee"].ToString() , config["Miscellaneous_Fee_Optional"].ToString() , config["Direct_Cost"].ToString() , config["Direct_Cost_Optional"].ToString() , config["Additional_Fee"].ToString()); lstDocuments.Items.Add(new ListViewItem( new string[] { t.DocumentNumber, Enum.GetName(typeof(Transaction_Type), t.TransactionType), t.DocumentDate.ToShortDateString(), t.GradeLevel, t.CurrencyID, String.Format("{0}-{1}", Convert.ToString(t.SYFrom), Convert.ToString(t.SYTo)), Convert.ToString(t.Subtotal), Convert.ToString(t.TotalDiscounts), Convert.ToString(t.TotalAmount) } )); } } } } else { txtName.Clear(); lblDocumentNo.Enabled = false; txtDocumentNo.Clear(); txtDocumentNo.Enabled = false; } }
public Transactions GetTransactionsByStudentID(string studentID) { Transactions transactions = new Transactions(); try { using (SqlConnection conn = new SqlConnection(connString)) using (SqlCommand comm = new SqlCommand("usp_GetAssessmentByCustomerID", conn)) { comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add(new SqlParameter("@Customer_ID", studentID)); conn.Open(); using (SqlDataReader dr = comm.ExecuteReader()) { while (dr.Read()) { Transaction t = new Transaction(); t.DocumentNumber = dr["Assessment No"].ToString(); t.TransactionType = (Transaction_Type)Convert.ToInt32(dr["SOP Type"]); t.StudentID = dr["Student No"].ToString(); t.StudentName = dr["Student Name"].ToString(); t.PriceLevel = dr["Level"].ToString(); t.GradeLevel = dr["Grade Level"].ToString(); t.CurrencyID = dr["Currency"].ToString(); t.BatchID = dr["Batch No"].ToString(); t.DocumentDate = Convert.ToDateTime(dr["Document Date"].ToString()); t.Plan = PlanData.Instance.GetPlan(dr["Plan"].ToString()); t.SYFrom = Convert.ToInt32(dr["SY From"].ToString()); t.SYTo = Convert.ToInt32(dr["SY To"].ToString()); t.Comments = dr["Comments"].ToString(); t.InstallmentFee = Convert.ToDecimal(dr["Installment Fee"]); t.Items = ItemData.Instance.GetAssessmentItems(t.DocumentNumber, t.TransactionType); t.AppliedDiscounts = DiscountData.Instance.GetAssessmentDiscountsByDocID(t.DocumentNumber, t.TransactionType); t.Schedule = PlanData.Instance.GetAssessmentSchedule(t.DocumentNumber, t.TransactionType); t.ReservationFee = Convert.ToDecimal(dr["Reservation Fee"]); transactions.Add(t); } } } } catch (Exception ex) { log.Error(ex); throw; } return transactions; }