示例#1
0
        public Student GetStudent(string customerNo)
        {
            Student student = new Student();

            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetCustomerByID", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;

                    comm.Parameters.Clear();
                    comm.Parameters.Add(new SqlParameter("@Customer_ID", customerNo));

                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        student.StudentFound = false;
                        while (dr.Read())
                        {
                            student = new Student(dr["Customer Number"].ToString()
                                                    , dr["Customer Name"].ToString()
                                                    , dr["Price Level"].ToString()
                                                    , dr["Customer Class"].ToString()
                                                    , dr["Currency ID"].ToString()
                                                    , dr["Grade Level"].ToString()
                                                    , dr["Status"].ToString());

                            student.Plan = PlanData.Instance.GetPlan(dr["Plan"].ToString());

                            student.StudentFound = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }

            return student;
        }
        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;
            }
        }
示例#3
0
        public Students GetStudents()
        {
            Students students = new Students();

            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetActiveCustomers", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;
                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Student stud = new Student(dr["Customer Number"].ToString(),
                                dr["Customer Name"].ToString(),
                                dr["Price Level"].ToString(),
                                dr["Customer Class"].ToString(),
                                dr["Currency ID"].ToString(),
                                dr["Grade Level"].ToString(),
                                dr["Status"].ToString());

                            students.Add(stud);
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return students;
        }
示例#4
0
 public int IndexOf(Student student)
 {
     return List.IndexOf(student);
 }
示例#5
0
 public void Delete(Student student)
 {
     List.Remove(student);
 }
示例#6
0
 public void Add(Student student)
 {
     List.Add(student);
 }
示例#7
0
        private void assess()
        {
            //Header
            student = StudentAdapter.Instance.GetStudent(studentID);
            if (student.StudentFound)
            {
                btnAddItem.Enabled = true;
                cboPlan.Enabled = true;
                //populateHeader();

                //assessment
                transaction.StudentID = student.StudentID;
                transaction.StudentName = student.Fullname;
                if (student.Currency.Trim().Length > 0)
                {
                    transaction.CurrencyID = student.Currency;
                }
                else
                {
                    transaction.CurrencyID = config["Default_Currency"].ToString(); //added 20110426 use default currency in config if customer has no currency specified
                }

                transaction.GradeLevel = student.GradeLevel;

                populateHeader(); //moved 20110426 display default currency

                if (transaction.TransactionType == Transaction_Type.Assessment)
                {
                    if (student.Plan.PlanID.Length > 0)
                    {
                        transaction.Plan = student.Plan;
                    }
                    else //if customer has no plan
                    {
                        transaction.Plan =
                            PlanAdapter.Instance.GetPlan(config["Default_Plan"].ToString());
                    }
                } //20100524
                else
                {
                    transaction.Plan = PlanAdapter.Instance.GetPlan(config["Default_Plan"].ToString());

                    cboPlan.Enabled = false; //20100527
                } //20100519
                cboPlan.Text = transaction.Plan.PlanID;

                transaction.PriceLevel = config["Default_Price_Level"].ToString();

                transaction.DocumentDate = dtpDocumentDate.Value;

                //retrieve customer discounts
                //20100512
                if (transaction.TransactionType == Transaction_Type.Assessment)
                {
                    if (chkDiscountEnabled.Checked == true)
                    {
                        transaction.AppliedDiscounts = new Discounts();
                        transaction.AvailableDiscounts =
                            DiscountAdapter.Instance.GetCustomerDiscounts
                            (transaction.StudentID);

                        transaction.AvailableDiscounts.SortByPercentage();
                    }
                    else if (chkDiscountEnabled.Checked == false)
                    {
                        transaction.AvailableDiscounts = new Discounts();
                        transaction.AppliedDiscounts = new Discounts();
                    }
                }

                //Details
                populateDetails();
                //Totals
                populateTotals();
            }
        }