コード例 #1
0
        public static double calc_amount_payable(string stud_no, double amount_paying, string type)
        {
            Database      d         = new Database();
            double        tot_payed = 0;
            SqlConnection con2      = new SqlConnection(Credentials.connection);

            if (type == "Diploma")
            {
                con2.Open();
                SqlCommand    cmd = new SqlCommand("SELECT DISTINCT payement_no FROM Dip_stud_modules WHERE stud_no='" + stud_no + "'", con2);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        tot_payed = tot_payed + Convert.ToDouble(d.singleString("SELECT Gross_amount FROM PaymentDetails WHERE Payment_No='" + dr.GetValue(0).ToString() + "'"));
                    }
                    else
                    {
                    }
                }
                tot_payed = tot_payed + amount_paying;
                con2.Close();
                return(Convert.ToDouble(d.singleString("SELECT course_fee_for_batch FROM Batches WHERE Batch_no='" + General_methods.get_batch_no_of_student(stud_no) + "'")) - tot_payed);
            }
            else
            {
                con2.Open();
                SqlCommand    cmd = new SqlCommand("SELECT Gross_amount FROM PaymentDetails WHERE stud_no_org_no='" + stud_no + "'AND Remark='Course fee for Certificate course'", con2);
                SqlDataReader dr  = cmd.ExecuteReader();

                while (dr.Read())
                {
                    tot_payed = tot_payed + Convert.ToDouble(dr.GetValue(0));
                }
                con2.Close();
                tot_payed = tot_payed + amount_paying;
                return(Convert.ToDouble(d.singleString("SELECT course_fee_for_batch FROM Batches WHERE Batch_no='" + General_methods.get_batch_no_of_student(stud_no) + "'")) - tot_payed);
            }
        }