public void LoadOldTuitionWithStdIdFromDb(int stdId)
        {
            oldCollect = new List <OldTuitionItem>();
            oldCollect.Clear();

            using (var db = Connection.CreateConnection())
            {
                db.Open();

                var sql = "dbo.spLoadOldTuitionWithStdId";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@StdId", stdId));
                var reader = cmd.ExecuteReader();

                if (!reader.HasRows)
                {
                    return;
                }

                while (reader.Read())
                {
                    var item = new OldTuitionItem();

                    item.OldTuition_Id          = Int32.Parse(reader["OldTuition_Id"].ToString());
                    item.OldTuition_Bill_Id     = Int32.Parse(reader["OldTuition_Bill_Id"].ToString());
                    item.OldTuition_Std_Id      = Int32.Parse(reader["OldTuition_Std_Id"].ToString());
                    item.OldTuition_Description = reader["OldTuition_Description"].ToString();
                    item.OldTuition_Amount      = Decimal.Parse(reader["OldTuition_Amount"].ToString());
                    item.OldTuition_Balance     = Decimal.Parse(reader["OldTuition_Balance"].ToString());
                    item.OldTuition_DatePaid    = reader["OldTuition_DatePaid"].ToString();
                    item.OldTuition_PayMade     = Decimal.Parse(reader["OldTuition_PayMade"].ToString());
                    item.OldTuition_Status      = reader["OldTuition_Status"].ToString();
                    item.OldTuition_Deleted     = reader["OldTuition_Deleted"].ToString();

                    oldCollect.Add(item);
                }
                db.Close();
            }
        }
        public void UpdatOld(OldTuitionItem oldItem)
        {
            using (var db = Connection.CreateConnection())
            {
                db.Open();

                var sql = "dbo.spUpdateOld";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Description", oldItem.OldTuition_Description));
                cmd.Parameters.Add(new SqlParameter("@Amount", oldItem.OldTuition_Amount));
                cmd.Parameters.Add(new SqlParameter("@Balance", oldItem.OldTuition_Balance));
                cmd.Parameters.Add(new SqlParameter("@Paymade", oldItem.OldTuition_PayMade));
                cmd.Parameters.Add(new SqlParameter("@DatePaid", oldItem.OldTuition_DatePaid));
                cmd.Parameters.Add(new SqlParameter("@Status", oldItem.OldTuition_Status));
                cmd.Parameters.Add(new SqlParameter("@OldId", oldItem.OldTuition_Id));

                cmd.ExecuteNonQuery();

                db.Close();
            }
        }
        public void SaveOldTuition(OldTuitionItem oldItem)
        {
            using (var db = Connection.CreateConnection())
            {
                db.Open();

                var sql = "dbo.spInsertOldTuition";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@OldTuitionBillId", oldItem.OldTuition_Bill_Id));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionStdId", oldItem.OldTuition_Std_Id));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionDescription", oldItem.OldTuition_Description));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionAmount", oldItem.OldTuition_Amount));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionBalance", oldItem.OldTuition_Balance));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionDatePaid", oldItem.OldTuition_DatePaid));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionPaymentMade", oldItem.OldTuition_PayMade));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionStatus", oldItem.OldTuition_Status));
                cmd.Parameters.Add(new SqlParameter("@OldTuitionDeleted", oldItem.OldTuition_Deleted));

                cmd.ExecuteNonQuery();

                db.Close();
            }
        }